Initial commit
This commit is contained in:
14
spec/factories/account.rb
Normal file
14
spec/factories/account.rb
Normal file
@@ -0,0 +1,14 @@
|
||||
# encoding: UTF-8
|
||||
# frozen_string_literal: true
|
||||
|
||||
module AccountFactory
|
||||
def create_account(*arguments)
|
||||
currency = Symbol === arguments.first ? arguments.first : :usd
|
||||
attributes = arguments.extract_options!
|
||||
attributes.delete(:member) { create(:member) }.get_account(currency).tap do |account|
|
||||
account.update!(attributes)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.configure { |config| config.include AccountFactory }
|
||||
15
spec/factories/adjustment.rb
Normal file
15
spec/factories/adjustment.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
# encoding: UTF-8
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :adjustment do
|
||||
reason { Faker::Coffee.blend_name }
|
||||
description { Faker::Coffee.notes }
|
||||
category { 'asset_registration' }
|
||||
amount { Faker::Number.positive }
|
||||
currency_id { Currency.ids.sample }
|
||||
creator { create(:member) }
|
||||
asset_account_code { 102 }
|
||||
receiving_account_number { "BTC-#{[402, 302].sample}" }
|
||||
end
|
||||
end
|
||||
40
spec/factories/beneficiaries.rb
Normal file
40
spec/factories/beneficiaries.rb
Normal file
@@ -0,0 +1,40 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
sequence(:coin_beneficiary_data) do
|
||||
{ address: Faker::Blockchain::Ethereum.address }
|
||||
end
|
||||
|
||||
sequence(:fiat_beneficiary_data) do
|
||||
{ full_name: Faker::Name.name_with_middle,
|
||||
address: Faker::Address.full_address,
|
||||
country: Faker::Address.country,
|
||||
account_number: Faker::Bank.account_number,
|
||||
account_type: %w[saving checking money-market CDs retirement].sample,
|
||||
bank_name: Faker::Bank.name,
|
||||
bank_address: Faker::Address.full_address,
|
||||
bank_country: Faker::Address.country,
|
||||
bank_swift_code: Faker::Bank.swift_bic,
|
||||
intermediary_bank_name: Faker::Bank.name,
|
||||
intermediary_bank_address: Faker::Address.full_address,
|
||||
intermediary_bank_country: Faker::Address.country,
|
||||
intermediary_bank_swift_code: Faker::Bank.swift_bic }
|
||||
end
|
||||
|
||||
factory :beneficiary do
|
||||
member { create(:member) }
|
||||
currency { Currency.all.sample }
|
||||
name { Faker::Company.name }
|
||||
description { Faker::Company.catch_phrase }
|
||||
state { 'pending' }
|
||||
|
||||
data do
|
||||
# Use save navigation operator for cases when currency is nil.
|
||||
if currency&.coin?
|
||||
generate(:coin_beneficiary_data)
|
||||
elsif currency&.fiat?
|
||||
generate(:fiat_beneficiary_data).merge(currency: currency.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
63
spec/factories/blockchains.rb
Normal file
63
spec/factories/blockchains.rb
Normal file
@@ -0,0 +1,63 @@
|
||||
# encoding: UTF-8
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :blockchain do
|
||||
|
||||
trait 'eth-rinkeby' do
|
||||
key { 'eth-rinkeby' }
|
||||
name { 'Ethereum Rinkeby' }
|
||||
client { 'geth' }
|
||||
server { 'http://127.0.0.1:8545' }
|
||||
height { 2500000 }
|
||||
min_confirmations { 6 }
|
||||
explorer_address { 'https://etherscan.io/address/#{address}' }
|
||||
explorer_transaction { 'https://etherscan.io/tx/#{txid}' }
|
||||
status { 'active' }
|
||||
end
|
||||
|
||||
trait 'eth-kovan' do
|
||||
key { 'eth-kovan' }
|
||||
name { 'Ethereum Kovan' }
|
||||
client { 'parity' }
|
||||
server { 'http://127.0.0.1:8545' }
|
||||
height { 2500000 }
|
||||
min_confirmations { 6 }
|
||||
explorer_address { 'https://kovan.etherscan.io/address/#{address}' }
|
||||
explorer_transaction { 'https://kovan.etherscan.io/tx/#{txid}' }
|
||||
status { 'active' }
|
||||
end
|
||||
|
||||
trait 'eth-mainet' do
|
||||
key { 'eth-mainet' }
|
||||
name { 'Ethereum Mainet' }
|
||||
client { 'geth' }
|
||||
server { 'http://127.0.0.1:8545' }
|
||||
height { 2500000 }
|
||||
min_confirmations { 4 }
|
||||
explorer_address { 'https://etherscan.io/address/#{address}' }
|
||||
explorer_transaction { 'https://etherscan.io/tx/#{txid}' }
|
||||
status { 'disabled' }
|
||||
end
|
||||
|
||||
trait 'btc-testnet' do
|
||||
key { 'btc-testnet' }
|
||||
name { 'Bitcoin Testnet' }
|
||||
client { 'bitcoin' }
|
||||
server { 'http://127.0.0.1:18332' }
|
||||
height { 1350000 }
|
||||
min_confirmations { 1 }
|
||||
explorer_address { 'https://blockchain.info/address/#{address}' }
|
||||
explorer_transaction { 'https://blockchain.info/tx/#{txid}' }
|
||||
status { 'active' }
|
||||
end
|
||||
|
||||
trait 'fake-testnet' do
|
||||
key { 'fake-testnet' }
|
||||
name { 'Fake Testnet' }
|
||||
client { 'fake' }
|
||||
height { 1 }
|
||||
status { 'active' }
|
||||
end
|
||||
end
|
||||
end
|
||||
139
spec/factories/currencies.rb
Normal file
139
spec/factories/currencies.rb
Normal file
@@ -0,0 +1,139 @@
|
||||
# encoding: UTF-8
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :currency do
|
||||
trait :usd do
|
||||
code { 'usd' }
|
||||
name { 'US Dollar' }
|
||||
type { 'fiat' }
|
||||
precision { 2 }
|
||||
withdraw_limit_24h { 100 }
|
||||
withdraw_limit_72h { 1000 }
|
||||
withdraw_fee { 0.1 }
|
||||
position { 1 }
|
||||
options { {} }
|
||||
end
|
||||
|
||||
trait :eur do
|
||||
code { 'eur' }
|
||||
name { 'Euro' }
|
||||
type { 'fiat' }
|
||||
precision { 8 }
|
||||
withdraw_limit_24h { 100 }
|
||||
withdraw_limit_72h { 1000 }
|
||||
withdraw_fee { 0.1 }
|
||||
position { 2 }
|
||||
visible { false }
|
||||
options { {} }
|
||||
end
|
||||
|
||||
trait :btc do
|
||||
blockchain_key { 'btc-testnet' }
|
||||
code { 'btc' }
|
||||
name { 'Bitcoin' }
|
||||
type { 'coin' }
|
||||
base_factor { 100_000_000 }
|
||||
withdraw_limit_24h { 0.1 }
|
||||
withdraw_limit_72h { 1 }
|
||||
withdraw_fee { 0.01 }
|
||||
position { 3 }
|
||||
options { {} }
|
||||
end
|
||||
|
||||
trait :eth do
|
||||
blockchain_key { 'eth-rinkeby' }
|
||||
code { 'eth' }
|
||||
name { 'Ethereum' }
|
||||
type { 'coin' }
|
||||
base_factor { 1_000_000_000_000_000_000 }
|
||||
withdraw_limit_24h { 0.1 }
|
||||
withdraw_limit_72h { 1 }
|
||||
withdraw_fee { 0.025 }
|
||||
position { 4 }
|
||||
options do
|
||||
{ gas_limit: 21_000,
|
||||
gas_price: 1_000_000_000 }
|
||||
end
|
||||
end
|
||||
|
||||
trait :trst do
|
||||
blockchain_key { 'eth-rinkeby' }
|
||||
code { 'trst' }
|
||||
name { 'WeTrust' }
|
||||
type { 'coin' }
|
||||
parent_id { 'eth' }
|
||||
base_factor { 1_000_000 }
|
||||
withdraw_limit_24h { 100 }
|
||||
withdraw_limit_72h { 1000 }
|
||||
withdraw_fee { 0.025 }
|
||||
position { 5 }
|
||||
options do
|
||||
{ gas_limit: 90_000,
|
||||
gas_price: 1_000_000_000,
|
||||
erc20_contract_address: '0x87099adD3bCC0821B5b151307c147215F839a110' }
|
||||
end
|
||||
end
|
||||
|
||||
trait :tom do
|
||||
blockchain_key { 'eth-rinkeby' }
|
||||
code { 'tom' }
|
||||
name { 'TOM' }
|
||||
type { 'coin' }
|
||||
parent_id { 'eth' }
|
||||
base_factor { 1_000_000 }
|
||||
withdraw_limit_24h { 100 }
|
||||
withdraw_limit_72h { 1000 }
|
||||
withdraw_fee { 0.025 }
|
||||
position { 5 }
|
||||
options do
|
||||
{ gas_limit: 90_000,
|
||||
gas_price: 1_000_000_000,
|
||||
erc20_contract_address: '0xf7970499814654cd13cb7b6e7634a12a7a8a9abc' }
|
||||
end
|
||||
end
|
||||
|
||||
trait :ring do
|
||||
blockchain_key { 'eth-kovan' }
|
||||
code { 'ring' }
|
||||
name { 'Evolution Land Global Token' }
|
||||
type { 'coin' }
|
||||
parent_id { 'eth' }
|
||||
base_factor { 1_000_000 }
|
||||
withdraw_limit_24h { 100 }
|
||||
withdraw_limit_72h { 1000 }
|
||||
withdraw_fee { 0.025 }
|
||||
position { 6 }
|
||||
options \
|
||||
{ { erc20_contract_address: '0xf8720eb6ad4a530cccb696043a0d10831e2ff60e' } }
|
||||
end
|
||||
|
||||
trait :fake do
|
||||
blockchain_key { 'fake-testnet' }
|
||||
code { 'fake' }
|
||||
name { 'Fake Coin' }
|
||||
type { 'coin' }
|
||||
base_factor { 1_000_000 }
|
||||
withdraw_limit_24h { 100 }
|
||||
withdraw_limit_72h { 1000 }
|
||||
withdraw_fee { 0.02 }
|
||||
position { 7 }
|
||||
options { {} }
|
||||
end
|
||||
|
||||
trait :xagm_cx do
|
||||
blockchain_key { 'eth-rinkeby' }
|
||||
code { 'xagm.cx' }
|
||||
name { 'XAGm.cx' }
|
||||
type { 'coin' }
|
||||
parent_id { 'eth' }
|
||||
base_factor { 1_000_000 }
|
||||
withdraw_limit_24h { 100 }
|
||||
withdraw_limit_72h { 1000 }
|
||||
withdraw_fee { 0.02 }
|
||||
position { 8 }
|
||||
visible { true }
|
||||
options { {} }
|
||||
end
|
||||
end
|
||||
end
|
||||
0
spec/factories/currencies_wallets.rb
Normal file
0
spec/factories/currencies_wallets.rb
Normal file
56
spec/factories/deposits.rb
Normal file
56
spec/factories/deposits.rb
Normal file
@@ -0,0 +1,56 @@
|
||||
# encoding: UTF-8
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :deposit do
|
||||
member { create(:member, :level_3) }
|
||||
amount { Kernel.rand(100..10_000).to_d }
|
||||
|
||||
factory :deposit_btc, class: Deposits::Coin do
|
||||
currency { Currency.find(:btc) }
|
||||
address { Faker::Blockchain::Bitcoin.address }
|
||||
txid { Faker::Lorem.characters(64) }
|
||||
txout { 0 }
|
||||
block_number { rand(1..1349999) }
|
||||
end
|
||||
|
||||
factory :deposit_usd, class: Deposits::Fiat do
|
||||
currency { Currency.find(:usd) }
|
||||
end
|
||||
|
||||
trait :deposit_btc do
|
||||
type { Deposits::Coin }
|
||||
currency { Currency.find(:btc) }
|
||||
address { Faker::Blockchain::Bitcoin.address }
|
||||
txid { Faker::Lorem.characters(64) }
|
||||
txout { 0 }
|
||||
end
|
||||
|
||||
trait :deposit_eth do
|
||||
type { Deposits::Coin }
|
||||
currency { Currency.find(:eth) }
|
||||
member { create(:member, :level_3, :barong) }
|
||||
address { Faker::Blockchain::Bitcoin.address }
|
||||
txid { Faker::Lorem.characters(64) }
|
||||
txout { 0 }
|
||||
end
|
||||
|
||||
trait :deposit_trst do
|
||||
type { Deposits::Coin }
|
||||
currency { Currency.find(:trst) }
|
||||
member { create(:member, :level_3, :barong) }
|
||||
address { Faker::Blockchain::Bitcoin.address }
|
||||
txid { Faker::Lorem.characters(64) }
|
||||
txout { 0 }
|
||||
end
|
||||
|
||||
trait :deposit_ring do
|
||||
type { Deposits::Coin }
|
||||
currency { Currency.find(:ring) }
|
||||
member { create(:member, :level_3, :barong) }
|
||||
address { Faker::Blockchain::Bitcoin.address }
|
||||
txid { Faker::Lorem.characters(64) }
|
||||
txout { 0 }
|
||||
end
|
||||
end
|
||||
end
|
||||
9
spec/factories/engine.rb
Normal file
9
spec/factories/engine.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :engine do
|
||||
name { Faker::Company.unique.bs.strip.downcase }
|
||||
driver { 'peatio' }
|
||||
state { 'online' }
|
||||
end
|
||||
end
|
||||
35
spec/factories/internal_transfer.rb
Normal file
35
spec/factories/internal_transfer.rb
Normal file
@@ -0,0 +1,35 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :internal_transfer_btc, class: InternalTransfer do
|
||||
trait :with_deposit_liability do
|
||||
before(:create) do |internal_tranfer|
|
||||
deposit = create(:deposit_btc, member: internal_tranfer.sender, amount: internal_tranfer.amount)
|
||||
deposit.accept!
|
||||
deposit.process!
|
||||
deposit.dispatch!
|
||||
end
|
||||
end
|
||||
|
||||
currency { Currency.find(:btc) }
|
||||
amount { 10.to_d }
|
||||
sender { create(:member, :level_3) }
|
||||
receiver { create(:member, :level_3) }
|
||||
state { 'completed' }
|
||||
end
|
||||
|
||||
factory :internal_transfer_usd, class: InternalTransfer do
|
||||
trait :with_deposit_liability do
|
||||
before(:create) do |internal_tranfer|
|
||||
create(:deposit_usd, member: internal_tranfer.sender, amount: internal_tranfer.amount)
|
||||
.accept!
|
||||
end
|
||||
end
|
||||
|
||||
currency { Currency.find(:usd) }
|
||||
amount { 1000.to_d }
|
||||
sender { create(:member, :level_3) }
|
||||
receiver { create(:member, :level_3) }
|
||||
state { 'completed' }
|
||||
end
|
||||
end
|
||||
79
spec/factories/market.rb
Normal file
79
spec/factories/market.rb
Normal file
@@ -0,0 +1,79 @@
|
||||
# encoding: UTF-8
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :market do
|
||||
engine { create(:engine) }
|
||||
trait :btcusd do
|
||||
id { 'btcusd' }
|
||||
base_currency { 'btc' }
|
||||
quote_currency { 'usd' }
|
||||
amount_precision { 8 }
|
||||
price_precision { 2 }
|
||||
min_price { 0.01 }
|
||||
min_amount { 0.00000001 }
|
||||
position { 1 }
|
||||
state { :enabled }
|
||||
end
|
||||
|
||||
trait :btceth do
|
||||
id { 'btceth' }
|
||||
base_currency { 'btc' }
|
||||
quote_currency { 'eth' }
|
||||
amount_precision { 4 }
|
||||
price_precision { 6 }
|
||||
min_price { 0.000001 }
|
||||
min_amount { 0.0001 }
|
||||
position { 2 }
|
||||
state { :enabled }
|
||||
end
|
||||
|
||||
trait :btceur do
|
||||
id { 'btceur' }
|
||||
base_currency { 'btc' }
|
||||
quote_currency { 'eur' }
|
||||
amount_precision { 8 }
|
||||
price_precision { 2 }
|
||||
min_price { 0.01 }
|
||||
min_amount { 0.00000001 }
|
||||
position { 3 }
|
||||
state { :enabled }
|
||||
end
|
||||
|
||||
trait :ethusd do
|
||||
id { 'ethusd' }
|
||||
base_currency { 'eth' }
|
||||
quote_currency { 'usd' }
|
||||
amount_precision { 6 }
|
||||
price_precision { 4 }
|
||||
min_price { 0.01 }
|
||||
min_amount { 0.0001 }
|
||||
position { 4 }
|
||||
state { :enabled }
|
||||
end
|
||||
|
||||
trait :btctrst do
|
||||
id { 'btctrst' }
|
||||
base_currency { 'btc' }
|
||||
quote_currency { 'trst' }
|
||||
amount_precision { 6 }
|
||||
price_precision { 4 }
|
||||
min_price { 0.01 }
|
||||
min_amount { 0.0001 }
|
||||
position { 5 }
|
||||
state { :enabled }
|
||||
end
|
||||
|
||||
trait :xagm_cxusd do
|
||||
id { 'xagm.cxusd' }
|
||||
base_currency { 'xagm.cx' }
|
||||
quote_currency { 'usd' }
|
||||
amount_precision { 6 }
|
||||
price_precision { 4 }
|
||||
min_price { 0.01 }
|
||||
min_amount { 0.0001 }
|
||||
position { 4 }
|
||||
state { :enabled }
|
||||
end
|
||||
end
|
||||
end
|
||||
39
spec/factories/member.rb
Normal file
39
spec/factories/member.rb
Normal file
@@ -0,0 +1,39 @@
|
||||
# encoding: UTF-8
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :member do
|
||||
email { Faker::Internet.email }
|
||||
level { 0 }
|
||||
uid { "ID#{Faker::Number.unique.hexadecimal(10)}".upcase }
|
||||
role { "member" }
|
||||
group { "vip-0" }
|
||||
state { "active" }
|
||||
|
||||
trait :level_3 do
|
||||
level { 3 }
|
||||
end
|
||||
|
||||
trait :level_2 do
|
||||
level { 2 }
|
||||
end
|
||||
|
||||
trait :level_1 do
|
||||
level { 1 }
|
||||
end
|
||||
|
||||
trait :level_0 do
|
||||
level { 0 }
|
||||
end
|
||||
|
||||
trait :admin do
|
||||
role { "admin" }
|
||||
end
|
||||
|
||||
trait :barong do
|
||||
level { 3 }
|
||||
end
|
||||
|
||||
factory :admin_member, traits: %i[admin]
|
||||
end
|
||||
end
|
||||
58
spec/factories/operations.rb
Normal file
58
spec/factories/operations.rb
Normal file
@@ -0,0 +1,58 @@
|
||||
# encoding: UTF-8
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :operation do
|
||||
currency { Currency.all.sample }
|
||||
|
||||
credit { Kernel.rand(10..1000).to_d }
|
||||
|
||||
trait :debit do
|
||||
debit { Kernel.rand(10..1000).to_d }
|
||||
credit { 0 }
|
||||
end
|
||||
|
||||
reference_type { %w[order deposit trade].sample }
|
||||
|
||||
created_at { Faker::Date.between(3.days.ago, Date.today) }
|
||||
end
|
||||
|
||||
factory :asset, class: Operations::Asset, parent: :operation do
|
||||
code do
|
||||
Operations::Account.find_by(type: :asset,
|
||||
currency_type: currency.type).code
|
||||
end
|
||||
end
|
||||
|
||||
factory :expense, class: Operations::Expense, parent: :operation do
|
||||
code do
|
||||
Operations::Account.find_by(type: :expense,
|
||||
currency_type: currency.type).code
|
||||
end
|
||||
end
|
||||
|
||||
factory :revenue, class: Operations::Revenue, parent: :operation do
|
||||
code do
|
||||
Operations::Account.find_by(type: :revenue,
|
||||
currency_type: currency.type).code
|
||||
end
|
||||
end
|
||||
|
||||
factory :liability, class: Operations::Liability, parent: :operation do
|
||||
code do
|
||||
Operations::Account.find_by(type: :liability,
|
||||
currency_type: currency.type,
|
||||
kind: :main).code
|
||||
end
|
||||
trait :with_member do
|
||||
member { create(:member, :level_3) }
|
||||
|
||||
# Update legacy balance.
|
||||
after(:create) do |liability|
|
||||
acc = liability.member.get_account(liability.currency)
|
||||
acc.plus_funds(liability.credit) unless liability.credit.zero?
|
||||
acc.sub_funds(liability.debit) unless liability.debit.zero?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
97
spec/factories/operations_account.rb
Normal file
97
spec/factories/operations_account.rb
Normal file
@@ -0,0 +1,97 @@
|
||||
# encoding: UTF-8
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
# TODO: Rename this factory to account once we drop legacy accounts.
|
||||
factory :operations_account, class: Operations::Account do
|
||||
trait '101' do
|
||||
code { 101 }
|
||||
type { :asset }
|
||||
kind { :main }
|
||||
currency_type { :fiat }
|
||||
description { 'Main Fiat Assets Account' }
|
||||
scope { :platform }
|
||||
end
|
||||
|
||||
trait '102' do
|
||||
code { 102 }
|
||||
type { :asset }
|
||||
kind { :main }
|
||||
currency_type { :coin }
|
||||
description { 'Main Crypto Assets Account' }
|
||||
scope { :platform }
|
||||
end
|
||||
|
||||
trait '201' do
|
||||
code { 201 }
|
||||
type { :liability }
|
||||
kind { :main }
|
||||
currency_type { :fiat }
|
||||
description { 'Main Fiat Liabilities Account' }
|
||||
scope { :member }
|
||||
end
|
||||
|
||||
trait '202' do
|
||||
code { 202 }
|
||||
type { :liability }
|
||||
kind { :main }
|
||||
currency_type { :coin }
|
||||
description { 'Main Crypto Liabilities Account' }
|
||||
scope { :member }
|
||||
end
|
||||
|
||||
trait '211' do
|
||||
code { 211 }
|
||||
type { :liability }
|
||||
kind { :locked }
|
||||
currency_type { :fiat }
|
||||
description { 'Locked Fiat Liabilities Account' }
|
||||
scope { :member }
|
||||
end
|
||||
|
||||
trait '212' do
|
||||
code { 212 }
|
||||
type { :liability }
|
||||
kind { :locked }
|
||||
currency_type { :coin }
|
||||
description { 'Locked Crypto Liabilities Account' }
|
||||
scope { :member }
|
||||
end
|
||||
|
||||
trait '301' do
|
||||
code { 301 }
|
||||
type { :revenue }
|
||||
kind { :main }
|
||||
currency_type { :fiat }
|
||||
description { 'Main Fiat Revenues Account' }
|
||||
scope { :platform }
|
||||
end
|
||||
|
||||
trait '302' do
|
||||
code { 302 }
|
||||
type { :revenue }
|
||||
kind { :main }
|
||||
currency_type { :coin }
|
||||
description { 'Main Crypto Revenues Account' }
|
||||
scope { :platform }
|
||||
end
|
||||
|
||||
trait '401' do
|
||||
code { 401 }
|
||||
type { :expense }
|
||||
kind { :main }
|
||||
currency_type { :fiat }
|
||||
description { 'Main Fiat Expenses Account' }
|
||||
scope { :platform }
|
||||
end
|
||||
|
||||
trait '402' do
|
||||
code { 402 }
|
||||
type { :expense }
|
||||
kind { :main }
|
||||
currency_type { :coin }
|
||||
description { 'Main Crypto Expenses Account' }
|
||||
scope { :platform }
|
||||
end
|
||||
end
|
||||
end
|
||||
110
spec/factories/orders.rb
Normal file
110
spec/factories/orders.rb
Normal file
@@ -0,0 +1,110 @@
|
||||
# encoding: UTF-8
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :order_bid do
|
||||
|
||||
# Create liability history by passing with_deposit_liability trait.
|
||||
trait :with_deposit_liability do
|
||||
before(:create) do |order|
|
||||
deposit = create(:deposit_usd, member: order.member, amount: order.locked)
|
||||
deposit.accept!
|
||||
deposit.process!
|
||||
deposit.dispatch!
|
||||
end
|
||||
|
||||
bid { :usd }
|
||||
ask { :btc }
|
||||
market { Market.find(:btcusd) }
|
||||
state { :wait }
|
||||
ord_type { 'limit' }
|
||||
price { '1'.to_d }
|
||||
volume { '1'.to_d }
|
||||
origin_volume { volume.to_d }
|
||||
locked { price.to_d * volume.to_d }
|
||||
origin_locked { locked.to_d }
|
||||
member { create(:member) }
|
||||
end
|
||||
|
||||
trait :btcusd do
|
||||
bid { :usd }
|
||||
ask { :btc }
|
||||
market { Market.find(:btcusd) }
|
||||
state { :wait }
|
||||
ord_type { 'limit' }
|
||||
price { '1'.to_d }
|
||||
volume { '1'.to_d }
|
||||
origin_volume { volume.to_d }
|
||||
locked { price.to_d * volume.to_d }
|
||||
origin_locked { locked.to_d }
|
||||
member { create(:member) }
|
||||
end
|
||||
|
||||
trait :btceth do
|
||||
bid { :eth }
|
||||
ask { :btc }
|
||||
market { Market.find(:btceth) }
|
||||
state { :wait }
|
||||
ord_type { 'limit' }
|
||||
price { '1'.to_d }
|
||||
volume { '1'.to_d }
|
||||
origin_volume { volume.to_d }
|
||||
locked { price.to_d * volume.to_d }
|
||||
origin_locked { locked.to_d }
|
||||
member { create(:member) }
|
||||
end
|
||||
end
|
||||
|
||||
factory :order_ask do
|
||||
|
||||
# Create liability history by passing with_deposit_liability trait.
|
||||
trait :with_deposit_liability do
|
||||
before(:create) do |order|
|
||||
deposit = create(:deposit_btc, member: order.member, amount: order.locked)
|
||||
deposit.accept!
|
||||
deposit.process!
|
||||
deposit.dispatch!
|
||||
end
|
||||
|
||||
bid { :usd }
|
||||
ask { :btc }
|
||||
market { Market.find(:btcusd) }
|
||||
state { :wait }
|
||||
ord_type { 'limit' }
|
||||
price { '1'.to_d }
|
||||
volume { '1'.to_d }
|
||||
origin_volume { volume.to_d }
|
||||
locked { volume.to_d }
|
||||
origin_locked { locked.to_d }
|
||||
member { create(:member) }
|
||||
end
|
||||
|
||||
trait :btcusd do
|
||||
bid { :usd }
|
||||
ask { :btc }
|
||||
market { Market.find(:btcusd) }
|
||||
state { :wait }
|
||||
ord_type { 'limit' }
|
||||
price { '1'.to_d }
|
||||
volume { '1'.to_d }
|
||||
origin_volume { volume.to_d }
|
||||
locked { volume.to_d }
|
||||
origin_locked { locked.to_d }
|
||||
member { create(:member) }
|
||||
end
|
||||
|
||||
trait :btceth do
|
||||
bid { :eth }
|
||||
ask { :btc }
|
||||
market { Market.find(:btceth) }
|
||||
state { :wait }
|
||||
ord_type { 'limit' }
|
||||
price { '1'.to_d }
|
||||
volume { '1'.to_d }
|
||||
origin_volume { volume.to_d }
|
||||
locked { volume.to_d }
|
||||
origin_locked { locked.to_d }
|
||||
member { create(:member) }
|
||||
end
|
||||
end
|
||||
end
|
||||
40
spec/factories/payment_addresses.rb
Normal file
40
spec/factories/payment_addresses.rb
Normal file
@@ -0,0 +1,40 @@
|
||||
# encoding: UTF-8
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :payment_address do
|
||||
address { Faker::Blockchain::Bitcoin.address }
|
||||
member { create(:member, :level_3) }
|
||||
wallet { Wallet.joins(:currencies).find_by(currencies: { id: 'usd' }) }
|
||||
|
||||
trait :btc_address do
|
||||
member { create(:member, :level_3) }
|
||||
wallet { Wallet.joins(:currencies).find_by(currencies: { id: 'btc' }) }
|
||||
end
|
||||
|
||||
trait :eth_address do
|
||||
member { create(:member, :level_3) }
|
||||
wallet { Wallet.joins(:currencies).find_by(currencies: { id: 'eth' }) }
|
||||
end
|
||||
|
||||
trait :trst_address do
|
||||
member { create(:member, :level_3) }
|
||||
wallet { Wallet.joins(:currencies).find_by(currencies: { id: 'trst' }) }
|
||||
end
|
||||
|
||||
trait :ring_address do
|
||||
member { create(:member, :level_3) }
|
||||
wallet { Wallet.joins(:currencies).find_by(currencies: { id: 'ring' }) }
|
||||
end
|
||||
|
||||
trait :ltc_address do
|
||||
member { create(:member, :level_3) }
|
||||
wallet { Wallet.joins(:currencies).find_by(currencies: { id: 'ltc' }) }
|
||||
end
|
||||
|
||||
factory :btc_payment_address, traits: [:btc_address]
|
||||
factory :eth_payment_address, traits: [:eth_address]
|
||||
factory :trst_payment_address, traits: [:trst_address]
|
||||
factory :ring_payment_address, traits: [:ring_address]
|
||||
end
|
||||
end
|
||||
18
spec/factories/stats_member_pnl.rb
Normal file
18
spec/factories/stats_member_pnl.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
# encoding: UTF-8
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :stats_member_pnl do
|
||||
member { create(:member, :level_3) }
|
||||
currency_id { Currency.ids.sample }
|
||||
pnl_currency_id { Currency.ids.sample }
|
||||
total_credit { 0 }
|
||||
total_debit_fees { 0 }
|
||||
total_credit_fees { 0 }
|
||||
total_debit { 0 }
|
||||
total_credit_value { 0 }
|
||||
total_debit_value { 0 }
|
||||
total_balance_value { 0 }
|
||||
average_balance_price { 0 }
|
||||
end
|
||||
end
|
||||
34
spec/factories/trade.rb
Normal file
34
spec/factories/trade.rb
Normal file
@@ -0,0 +1,34 @@
|
||||
# encoding: UTF-8
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :trade do
|
||||
trait :btcusd do
|
||||
price { '10.0'.to_d }
|
||||
amount { '1.0'.to_d }
|
||||
total { price.to_d * amount.to_d }
|
||||
market { Market.find(:btcusd) }
|
||||
maker_order { create(:order_ask, :btcusd) }
|
||||
taker_order { create(:order_bid, :btcusd) }
|
||||
maker { maker_order.member }
|
||||
taker { taker_order.member }
|
||||
end
|
||||
|
||||
trait :btceth do
|
||||
price { '10.0'.to_d }
|
||||
amount { '1.0'.to_d }
|
||||
total { price.to_d * amount.to_d }
|
||||
market { Market.find(:btceth) }
|
||||
maker_order { create(:order_ask, :btceth) }
|
||||
taker_order { create(:order_bid, :btceth) }
|
||||
maker { maker_order.member }
|
||||
taker { taker_order.member }
|
||||
end
|
||||
|
||||
# Create liability history for orders by passing with_deposit_liability trait.
|
||||
trait :with_deposit_liability do
|
||||
maker_order { create(:order_ask, :with_deposit_liability) }
|
||||
taker_order { create(:order_bid, :with_deposit_liability) }
|
||||
end
|
||||
end
|
||||
end
|
||||
22
spec/factories/trading_fees.rb
Normal file
22
spec/factories/trading_fees.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
# encoding: UTF-8
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
sequence(:fee) do
|
||||
Kernel.rand(TradingFee::MIN_FEE..TradingFee::MAX_FEE).to_d
|
||||
end
|
||||
|
||||
sequence(:group) do |n|
|
||||
"vip-#{n}"
|
||||
end
|
||||
|
||||
factory :trading_fee do
|
||||
maker { generate(:fee) }
|
||||
taker { generate(:fee) }
|
||||
group { generate(:group) }
|
||||
|
||||
trait :with_market do
|
||||
market { Market.all.sample }
|
||||
end
|
||||
end
|
||||
end
|
||||
11
spec/factories/transaction.rb
Normal file
11
spec/factories/transaction.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :transaction do
|
||||
currency { Currency.all.sample }
|
||||
txid { Faker::Lorem.characters(64) }
|
||||
from_address { Faker::Blockchain::Bitcoin.address }
|
||||
to_address { Faker::Blockchain::Bitcoin.address }
|
||||
amount { Kernel.rand(100..10_000).to_d }
|
||||
end
|
||||
end
|
||||
51
spec/factories/transfer.rb
Normal file
51
spec/factories/transfer.rb
Normal file
@@ -0,0 +1,51 @@
|
||||
# encoding: UTF-8
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
sequence :transfer_key do
|
||||
"transfer_#{Faker::Number.unique.number(5).to_i}"
|
||||
end
|
||||
|
||||
factory :transfer do
|
||||
key { generate(:transfer_key) }
|
||||
category { Transfer::CATEGORIES.sample }
|
||||
description { "#{category} for #{Time.now.to_date}" }
|
||||
|
||||
trait :with_assets do
|
||||
after(:create) do |t|
|
||||
assets_number = Faker::Number.between(1, 5).to_i
|
||||
create_list(:asset, assets_number, reference: t)
|
||||
end
|
||||
end
|
||||
|
||||
trait :with_expenses do
|
||||
after(:create) do |t|
|
||||
expense_number = Faker::Number.between(1, 5).to_i
|
||||
create_list(:expense, expense_number, reference: t)
|
||||
end
|
||||
end
|
||||
|
||||
trait :with_liabilities do
|
||||
after(:create) do |t|
|
||||
liabilities_number = Faker::Number.between(1, 5).to_i
|
||||
create_list(:liability, liabilities_number, :with_member, reference: t)
|
||||
end
|
||||
end
|
||||
|
||||
trait :with_revenues do
|
||||
after(:create) do |t|
|
||||
revenues_number = Faker::Number.between(1, 5).to_i
|
||||
create_list(:revenue, revenues_number, reference: t)
|
||||
end
|
||||
end
|
||||
|
||||
trait :with_operations do
|
||||
with_assets
|
||||
with_expenses
|
||||
with_liabilities
|
||||
with_revenues
|
||||
end
|
||||
|
||||
factory :transfer_with_operations, traits: %i[with_operations]
|
||||
end
|
||||
end
|
||||
10
spec/factories/triggers.rb
Normal file
10
spec/factories/triggers.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
# encoding: UTF-8
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :trigger do
|
||||
order { create(:order_ask, :with_deposit_liability, :btcusd)}
|
||||
order_type { Trigger::TYPES.keys.sample }
|
||||
value { 1.1.to_d }
|
||||
end
|
||||
end
|
||||
213
spec/factories/wallet.rb
Normal file
213
spec/factories/wallet.rb
Normal file
@@ -0,0 +1,213 @@
|
||||
# encoding: UTF-8
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :wallet do
|
||||
|
||||
trait :eth_deposit do
|
||||
after(:create) do |w|
|
||||
CurrencyWallet.create(currency_id: 'eth', wallet_id: w.id)
|
||||
end
|
||||
blockchain_key { 'eth-rinkeby' }
|
||||
name { 'Ethereum Deposit Wallet' }
|
||||
address { '0x828058628DF254Ebf252e0b1b5393D1DED91E369' }
|
||||
kind { 'deposit' }
|
||||
max_balance { 0.0 }
|
||||
status { 'active' }
|
||||
gateway { 'geth' }
|
||||
uri { 'http://127.0.0.1:8545' }
|
||||
secret { 'changeme' }
|
||||
end
|
||||
|
||||
trait :eth_hot do
|
||||
after(:create) do |w|
|
||||
CurrencyWallet.create(currency_id: 'eth', wallet_id: w.id)
|
||||
end
|
||||
blockchain_key { 'eth-rinkeby' }
|
||||
name { 'Ethereum Hot Wallet' }
|
||||
address { '0xb6a61c43DAe37c0890936D720DC42b5CBda990F9' }
|
||||
kind { 'hot' }
|
||||
max_balance { 100.0 }
|
||||
status { 'active' }
|
||||
gateway { 'geth' }
|
||||
uri { 'http://127.0.0.1:8545' }
|
||||
secret { 'changeme' }
|
||||
end
|
||||
|
||||
trait :eth_warm do
|
||||
after(:create) do |w|
|
||||
CurrencyWallet.create(currency_id: 'eth', wallet_id: w.id)
|
||||
end
|
||||
blockchain_key { 'eth-rinkeby' }
|
||||
name { 'Ethereum Warm Wallet' }
|
||||
address { '0x2b9fBC10EbAeEc28a8Fc10069C0BC29E45eBEB9C' }
|
||||
kind { 'warm' }
|
||||
max_balance { 1000.0 }
|
||||
status { 'active' }
|
||||
gateway { 'geth' }
|
||||
uri { 'http://127.0.0.1:8545' }
|
||||
secret { 'changeme' }
|
||||
end
|
||||
|
||||
trait :eth_cold do
|
||||
after(:create) do |w|
|
||||
CurrencyWallet.create(currency_id: 'eth', wallet_id: w.id)
|
||||
end
|
||||
blockchain_key { 'eth-rinkeby' }
|
||||
name { 'Ethereum Cold Wallet' }
|
||||
address { '0x2b9fBC10EbAeEc28a8Fc10069C0BC29E45eBEB9C' }
|
||||
kind { 'cold' }
|
||||
max_balance { 1000.0 }
|
||||
status { 'active' }
|
||||
gateway { 'geth' }
|
||||
uri { 'http://127.0.0.1:8545' }
|
||||
secret { 'changeme' }
|
||||
end
|
||||
|
||||
trait :eth_fee do
|
||||
after(:create) do |w|
|
||||
CurrencyWallet.create(currency_id: 'eth', wallet_id: w.id)
|
||||
end
|
||||
blockchain_key { 'eth-rinkeby' }
|
||||
name { 'Ethereum Fee Wallet' }
|
||||
address { '0x45a31b15a2ab8a8477375b36b6f5a0c63733dce8' }
|
||||
kind { 'fee' }
|
||||
max_balance { 1000.0 }
|
||||
status { 'active' }
|
||||
gateway { 'geth' }
|
||||
uri { 'http://127.0.0.1:8545' }
|
||||
secret { 'changeme' }
|
||||
end
|
||||
|
||||
trait :trst_deposit do
|
||||
after(:create) do |w|
|
||||
CurrencyWallet.create(currency_id: 'trst', wallet_id: w.id)
|
||||
end
|
||||
blockchain_key { 'eth-rinkeby' }
|
||||
name { 'Trust Coin Deposit Wallet' }
|
||||
address { '0x828058628DF254Ebf252e0b1b5393D1DED91E369' }
|
||||
kind { 'deposit' }
|
||||
max_balance { 0.0 }
|
||||
status { 'active' }
|
||||
gateway { 'geth' }
|
||||
uri { 'http://127.0.0.1:8545' }
|
||||
secret { 'changeme' }
|
||||
end
|
||||
|
||||
trait :trst_hot do
|
||||
after(:create) do |w|
|
||||
CurrencyWallet.create(currency_id: 'trst', wallet_id: w.id)
|
||||
end
|
||||
blockchain_key { 'eth-rinkeby' }
|
||||
name { 'Trust Coin Hot Wallet' }
|
||||
address { '0xb6a61c43DAe37c0890936D720DC42b5CBda990F9' }
|
||||
kind { 'hot' }
|
||||
max_balance { 100.0 }
|
||||
status { 'active' }
|
||||
gateway { 'geth' }
|
||||
uri { 'http://127.0.0.1:8545' }
|
||||
secret { 'changeme' }
|
||||
end
|
||||
|
||||
trait :btc_deposit do
|
||||
after(:create) do |w|
|
||||
CurrencyWallet.create(currency_id: 'btc', wallet_id: w.id)
|
||||
end
|
||||
blockchain_key { 'btc-testnet' }
|
||||
name { 'Bitcoin Deposit Wallet' }
|
||||
address { '3DX3Ak4751ckkoTFbYSY9FEQ6B7mJ4furT' }
|
||||
kind { 'deposit' }
|
||||
max_balance { 0.0 }
|
||||
status { 'active' }
|
||||
gateway { 'bitcoind' }
|
||||
uri { 'http://127.0.0.1:18332' }
|
||||
secret { 'changeme' }
|
||||
end
|
||||
|
||||
trait :btc_hot do
|
||||
after(:create) do |w|
|
||||
CurrencyWallet.create(currency_id: 'btc', wallet_id: w.id)
|
||||
end
|
||||
blockchain_key { 'btc-testnet' }
|
||||
name { 'Bitcoin Hot Wallet' }
|
||||
address { '3NwYr8JxjHG2MBkgdBiHCxStSWDzyjS5U8' }
|
||||
kind { 'hot' }
|
||||
max_balance { 500.0 }
|
||||
status { 'active' }
|
||||
gateway { 'bitcoind' }
|
||||
uri { 'http://127.0.0.1:18332' }
|
||||
secret { 'changeme' }
|
||||
end
|
||||
|
||||
trait :fake_deposit do
|
||||
after(:create) do |w|
|
||||
CurrencyWallet.create(currency_id: 'fake', wallet_id: w.id)
|
||||
end
|
||||
blockchain_key { 'fake-testnet' }
|
||||
name { 'Fake Currency Deposit Wallet' }
|
||||
address { 'fake-deposit' }
|
||||
kind { 'deposit' }
|
||||
max_balance { 0.0 }
|
||||
status { 'active' }
|
||||
gateway { 'fake' }
|
||||
uri { 'http://127.0.0.1:18881' }
|
||||
end
|
||||
|
||||
trait :fake_hot do
|
||||
after(:create) do |w|
|
||||
CurrencyWallet.create(currency_id: 'fake', wallet_id: w.id)
|
||||
end
|
||||
blockchain_key { 'fake-testnet' }
|
||||
name { 'Fake Currency Hot Wallet' }
|
||||
address { 'fake-hot' }
|
||||
kind { 'hot' }
|
||||
max_balance { 10.0 }
|
||||
status { 'active' }
|
||||
gateway { 'fake' }
|
||||
uri { 'http://127.0.0.1:18881' }
|
||||
end
|
||||
|
||||
trait :fake_warm do
|
||||
after(:create) do |w|
|
||||
CurrencyWallet.create(currency_id: 'fake', wallet_id: w.id)
|
||||
end
|
||||
blockchain_key { 'fake-testnet' }
|
||||
name { 'Fake Currency Warm Wallet' }
|
||||
address { 'fake-warm' }
|
||||
kind { 'warm' }
|
||||
max_balance { 100.0 }
|
||||
status { 'active' }
|
||||
gateway { 'fake' }
|
||||
uri { 'http://127.0.0.1:18881' }
|
||||
end
|
||||
|
||||
trait :fake_cold do
|
||||
after(:create) do |w|
|
||||
CurrencyWallet.create(currency_id: 'fake', wallet_id: w.id)
|
||||
end
|
||||
blockchain_key { 'fake-testnet' }
|
||||
name { 'Fake Currency Cold Wallet' }
|
||||
address { 'fake-cold' }
|
||||
kind { 'cold' }
|
||||
max_balance { 1000.0 }
|
||||
status { 'active' }
|
||||
gateway { 'fake' }
|
||||
uri { 'http://127.0.0.1:18881' }
|
||||
end
|
||||
|
||||
trait :fake_fee do
|
||||
after(:create) do |w|
|
||||
CurrencyWallet.create(currency_id: 'fake', wallet_id: w.id)
|
||||
end
|
||||
blockchain_key { 'fake-testnet' }
|
||||
name { 'Fake Currency Fee Wallet' }
|
||||
address { 'fake-fee' }
|
||||
kind { 'fee' }
|
||||
max_balance { 1000.0 }
|
||||
status { 'active' }
|
||||
gateway { 'fake' }
|
||||
uri { 'http://127.0.0.1:8545' }
|
||||
secret { 'changeme' }
|
||||
end
|
||||
end
|
||||
end
|
||||
41
spec/factories/whitelisted_smart_contracts.rb
Normal file
41
spec/factories/whitelisted_smart_contracts.rb
Normal file
@@ -0,0 +1,41 @@
|
||||
# encoding: UTF-8
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :whitelisted_smart_contract do
|
||||
trait :address_1 do
|
||||
id { 1 }
|
||||
blockchain_key { 'eth-rinkeby' }
|
||||
address { '0xbbd602bb278edff65cbc967b9b62095ad5be23a3' }
|
||||
state { 'active' }
|
||||
end
|
||||
|
||||
trait :address_2 do
|
||||
id { 2 }
|
||||
blockchain_key { 'eth-rinkeby' }
|
||||
address { '0xe3cb6897d83691a8eb8458140a1941ce1d6e6dac' }
|
||||
state { 'active' }
|
||||
end
|
||||
|
||||
trait :address_3 do
|
||||
id { 3 }
|
||||
blockchain_key { 'eth-rinkeby' }
|
||||
address { '0x4b6a630ff1f66604d31952bdce2e4950efc99821' }
|
||||
state { 'active' }
|
||||
end
|
||||
|
||||
trait :address_4 do
|
||||
id { 4 }
|
||||
blockchain_key { 'eth-rinkeby' }
|
||||
address { '0xc4d276bf32b71cdddb18f3b4d258f057a5ffda03' }
|
||||
state { 'active' }
|
||||
end
|
||||
|
||||
trait :address_5 do
|
||||
id { 5 }
|
||||
blockchain_key { 'eth-rinkeby' }
|
||||
address { '0x87099add3bcc0821b5b151307c147215f839a110' }
|
||||
state { 'active' }
|
||||
end
|
||||
end
|
||||
end
|
||||
67
spec/factories/withdraw.rb
Normal file
67
spec/factories/withdraw.rb
Normal file
@@ -0,0 +1,67 @@
|
||||
# encoding: UTF-8
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Legacy withdraw factories are deprecated because they update
|
||||
# account balance in database without creating liability operation.
|
||||
#
|
||||
# Use new withdraw factories instead.
|
||||
# You can create liability history by passing with_deposit_liability trait.
|
||||
#
|
||||
# TODO: Add new factories for all currencies.
|
||||
FactoryBot.define do
|
||||
factory :btc_withdraw, class: Withdraws::Coin do
|
||||
|
||||
# We need to have valid Liability-based balance to spend funds.
|
||||
trait :with_deposit_liability do
|
||||
before(:create) do |withdraw|
|
||||
deposit = create(:deposit_btc, member: withdraw.member, amount: withdraw.sum)
|
||||
deposit.accept!
|
||||
deposit.process!
|
||||
deposit.dispatch!
|
||||
end
|
||||
end
|
||||
|
||||
trait :with_beneficiary do
|
||||
beneficiary do
|
||||
create(:beneficiary,
|
||||
currency: currency,
|
||||
member: member,
|
||||
state: :active)
|
||||
end
|
||||
rid { nil }
|
||||
end
|
||||
|
||||
currency { Currency.find(:btc) }
|
||||
member { create(:member, :level_3) }
|
||||
rid { Faker::Blockchain::Bitcoin.address }
|
||||
sum { 10.to_d }
|
||||
type { 'Withdraws::Coin' }
|
||||
end
|
||||
|
||||
factory :usd_withdraw, class: Withdraws::Fiat do
|
||||
|
||||
# We need to have valid Liability-based balance to spend funds.
|
||||
trait :with_deposit_liability do
|
||||
before(:create) do |withdraw|
|
||||
create(:deposit_usd, member: withdraw.member, amount: withdraw.sum)
|
||||
.accept!
|
||||
end
|
||||
end
|
||||
|
||||
trait :with_beneficiary do
|
||||
beneficiary do
|
||||
create(:beneficiary,
|
||||
currency: currency,
|
||||
member: member,
|
||||
state: :active)
|
||||
end
|
||||
rid { nil }
|
||||
end
|
||||
|
||||
member { create(:member, :level_3) }
|
||||
currency { Currency.find(:usd) }
|
||||
rid { Faker::Bank.iban }
|
||||
sum { 1000.to_d }
|
||||
type { 'Withdraws::Fiat' }
|
||||
end
|
||||
end
|
||||
11
spec/factories/withdraw_limits.rb
Normal file
11
spec/factories/withdraw_limits.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
# encoding: UTF-8
|
||||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :withdraw_limit do
|
||||
group { 'any' }
|
||||
kyc_level { 'any' }
|
||||
limit_24_hour { 9999.to_d }
|
||||
limit_1_month { 999_999.to_d }
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user