test/commands/test_taxes.rb in zold-0.16.8 vs test/commands/test_taxes.rb in zold-0.16.9
- old
+ new
@@ -40,45 +40,37 @@
def test_pays_taxes
FakeHome.new(log: test_log).run do |home|
wallets = home.wallets
wallet = home.create_wallet
fund = Zold::Amount.new(zld: 19.99)
- wallet.add(
- Zold::Txn.new(
- 1,
- Time.now - 24 * 60 * 60 * 365 * 300,
- fund,
- 'NOPREFIX', Zold::Id.new, '-'
+ 10.times do |i|
+ wallet.add(
+ Zold::Txn.new(
+ i + 1,
+ Time.now - 24 * 60 * 60 * 365 * 300,
+ fund,
+ 'NOPREFIX', Zold::Id.new, '-'
+ )
)
- )
+ end
remotes = home.remotes
score = Zold::Score.new(host: 'localhost', port: 80, strength: 1, invoice: 'NOPREFIX@0000000000000000')
Zold::Tax::EXACT_SCORE.times { score = score.next }
remotes.add(score.host, score.port)
stub_request(:get, "http://#{score.host}:#{score.port}/").to_return(
status: 200,
body: {
score: score.to_h
}.to_json
)
+ before = wallet.balance
+ tax = Zold::Tax.new(wallet, ignore_score_weakness: true)
+ debt = tax.debt
Zold::Taxes.new(wallets: wallets, remotes: remotes, log: test_log).run(
['taxes', '--private-key=fixtures/id_rsa', '--ignore-score-weakness', 'pay', wallet.id.to_s]
)
- assert_equal(fund - Zold::Tax::MAX_PAYMENT, wallet.balance)
- wallet.add(
- Zold::Txn.new(
- 2,
- Time.now - 24 * 60 * 60 * 365 * 300,
- fund,
- 'NOPREFIX', Zold::Id.new, '-'
- )
- )
- Zold::Taxes.new(wallets: wallets, remotes: remotes, log: test_log).run(
- [
- 'taxes', '--private-key=fixtures/id_rsa', '--ignore-score-weakness',
- '--ignore-nodes-absence', 'pay', wallet.id.to_s
- ]
- )
- assert_equal(fund + fund - Zold::Tax::MAX_PAYMENT, wallet.balance)
+ wallet.flush
+ assert(tax.paid.positive?, tax.paid)
+ assert_equal(before - debt, wallet.balance)
end
end
end