Skip to content

Commit

Permalink
Tests for withdrawRewards param
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Stachyra committed Jul 6, 2020
1 parent 07f9317 commit 8223a63
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/cardano_wallet/shelley.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def list(wid, q = {})
def create(wid, passphrase, payments, q = {})
payments_formatted = Utils.format_payments(payments)
q.empty? ? query = '' : query = Utils.to_query(q)
self.class.post("/wallets/#{wid}/transactions#{q}",
self.class.post("/wallets/#{wid}/transactions#{query}",
:body => { :payments => payments_formatted,
:passphrase => passphrase
}.to_json,
Expand Down
29 changes: 29 additions & 0 deletions spec/shelley_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,24 @@
end
end

it "I can send transaction using 'withdrawRewards' flag and funds are received", :nightly => true do
amt = 1
wid = create_fixture_shelley_wallet
wait_for_shelley_wallet_to_sync(wid)
target_id = create_shelley_wallet
wait_for_shelley_wallet_to_sync(target_id)
address = SHELLEY.addresses.list(target_id)[0]['id']

tx_sent = SHELLEY.transactions.create(wid, PASS, {address => amt}, {withdrawRewards: true})
expect(tx_sent.code).to eq 202

eventually "Funds are on target wallet: #{target_id}" do
available = SHELLEY.wallets.get(target_id)['balance']['available']['quantity']
total = SHELLEY.wallets.get(target_id)['balance']['total']['quantity']
(available == amt) && (total == amt)
end
end

it "I could create transaction - if I had money" do
id = create_shelley_wallet
target_id = create_shelley_wallet
Expand All @@ -228,6 +246,17 @@
expect(tx_sent.code).to eq 403
end

it "I could create transaction using rewards - if I had money" do
id = create_shelley_wallet
target_id = create_shelley_wallet
address = SHELLEY.addresses.list(target_id)[0]['id']
txs = SHELLEY.transactions

tx_sent = txs.create(id, PASS, {address => 1000000}, {withdrawRewards: true})
expect(tx_sent).to include "not_enough_money"
expect(tx_sent.code).to eq 403
end

it "I could estimate transaction fee - if I had money" do
id = create_shelley_wallet
target_id = create_shelley_wallet
Expand Down

0 comments on commit 8223a63

Please sign in to comment.