Skip to content

Commit

Permalink
update existing tests with new submit tx ep
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotr Stachyra authored and paweljakubas committed Jan 18, 2022
1 parent 598115e commit 517139b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
28 changes: 18 additions & 10 deletions test/e2e/spec/e2e_spec.rb
Expand Up @@ -23,7 +23,7 @@
# @wid_rnd = "12cbebfdc4521766e63a7e07c4825b24deb4176c"
# @wid_ic = "f5da82c1eb3e391a535dd5ba2867fe9bdaf2f313"
# @wid = "2269611a3c10b219b0d38d74b004c298b76d16a9"
# @target_id = "8d0fc5d4450d7430a822f2102a84ac2ca1bc1bf1"
# @target_id = "84cbdf1ff57e5f18433c5e38a395a66e2953ae22"
# 1f82e83772b7579fc0854bd13db6a9cce21ccd95
# 2269611a3c10b219b0d38d74b004c298b76d16a9
# a042bafdaf98844cfa8f6d4b1dc47519b21a4d95
Expand Down Expand Up @@ -269,8 +269,9 @@ def run_contract(contract_setup, scripts)
}]
tx_constructed = SHELLEY.transactions.construct(@wid, payment)
tx_signed = SHELLEY.transactions.sign(@wid, PASS, tx_constructed['transaction'])
tx_submitted = PROXY.submit_external_transaction(Base64.decode64(tx_signed['transaction']))
tx_submitted = SHELLEY.transactions.submit(@wid, tx_signed['transaction'])
tx_id = tx_submitted['id']
expect(SHELLEY.transactions.get(@wid, tx_id)['status']).to eq 'pending'

wait_for_tx_in_ledger(@wid, tx_id)

Expand Down Expand Up @@ -302,9 +303,10 @@ def run_contract(contract_setup, scripts)
tx_signed = SHELLEY.transactions.sign(@wid, PASS, tx_constructed['transaction'])
expect(tx_signed).to be_correct_and_respond 202

tx_submitted = PROXY.submit_external_transaction(Base64.decode64(tx_signed['transaction']))
tx_submitted = SHELLEY.transactions.submit(@wid, tx_signed['transaction'])
expect(tx_submitted).to be_correct_and_respond 202
tx_id = tx_submitted['id']
expect(SHELLEY.transactions.get(@wid, tx_id)['status']).to eq 'pending'

wait_for_tx_in_ledger(@wid, tx_id)

Expand Down Expand Up @@ -343,9 +345,10 @@ def run_contract(contract_setup, scripts)
tx_signed = SHELLEY.transactions.sign(@wid, PASS, tx_constructed['transaction'])
expect(tx_signed).to be_correct_and_respond 202

tx_submitted = PROXY.submit_external_transaction(Base64.decode64(tx_signed['transaction']))
tx_submitted = SHELLEY.transactions.submit(@wid, tx_signed['transaction'])
expect(tx_submitted).to be_correct_and_respond 202
tx_id = tx_submitted['id']
expect(SHELLEY.transactions.get(@wid, tx_id)['status']).to eq 'pending'

wait_for_tx_in_ledger(@wid, tx_id)

Expand Down Expand Up @@ -390,9 +393,10 @@ def run_contract(contract_setup, scripts)
tx_signed = SHELLEY.transactions.sign(@wid, PASS, tx_constructed['transaction'])
expect(tx_signed).to be_correct_and_respond 202

tx_submitted = PROXY.submit_external_transaction(Base64.decode64(tx_signed['transaction']))
tx_submitted = SHELLEY.transactions.submit(@wid, tx_signed['transaction'])
expect(tx_submitted).to be_correct_and_respond 202
tx_id = tx_submitted['id']
expect(SHELLEY.transactions.get(@wid, tx_id)['status']).to eq 'pending'

wait_for_tx_in_ledger(@wid, tx_id)

Expand Down Expand Up @@ -427,9 +431,10 @@ def run_contract(contract_setup, scripts)
tx_signed = SHELLEY.transactions.sign(@wid, PASS, tx_constructed['transaction'])
expect(tx_signed).to be_correct_and_respond 202

tx_submitted = PROXY.submit_external_transaction(Base64.decode64(tx_signed['transaction']))
tx_submitted = SHELLEY.transactions.submit(@wid, tx_signed['transaction'])
expect(tx_submitted).to be_correct_and_respond 202
tx_id = tx_submitted['id']
expect(SHELLEY.transactions.get(@wid, tx_id)['status']).to eq 'pending'

wait_for_tx_in_ledger(@wid, tx_id)

Expand Down Expand Up @@ -459,9 +464,10 @@ def run_contract(contract_setup, scripts)
tx_signed = SHELLEY.transactions.sign(@wid, PASS, tx_constructed['transaction'])
expect(tx_signed).to be_correct_and_respond 202

tx_submitted = PROXY.submit_external_transaction(Base64.decode64(tx_signed['transaction']))
tx_submitted = SHELLEY.transactions.submit(@wid, tx_signed['transaction'])
expect(tx_submitted).to be_correct_and_respond 202
tx_id = tx_submitted['id']
expect(SHELLEY.transactions.get(@wid, tx_id)['status']).to eq 'pending'

wait_for_tx_in_ledger(@wid, tx_id)

Expand Down Expand Up @@ -503,9 +509,10 @@ def run_contract(contract_setup, scripts)
tx_signed = SHELLEY.transactions.sign(@wid, PASS, tx_constructed['transaction'])
expect(tx_signed).to be_correct_and_respond 202

tx_submitted = PROXY.submit_external_transaction(Base64.decode64(tx_signed['transaction']))
tx_submitted = SHELLEY.transactions.submit(@wid, tx_signed['transaction'])
expect(tx_submitted).to be_correct_and_respond 202
tx_id = tx_submitted['id']
expect(SHELLEY.transactions.get(@wid, tx_id)['status']).to eq 'pending'

wait_for_tx_in_ledger(@wid, tx_id)

Expand Down Expand Up @@ -622,7 +629,7 @@ def run_contract(contract_setup, scripts)


target_after = get_shelley_balances(@target_id)

# verify balances are correct on target wallet
assets_to_check = ["#{ASSETS[0]["policy_id"]}#{ASSETS[0]["asset_name"]}",
"#{ASSETS[1]["policy_id"]}#{ASSETS[1]["asset_name"]}"]
Expand Down Expand Up @@ -1165,9 +1172,10 @@ def test_byron_assets_tx(source_id, target_id)
tx_signed = SHELLEY.transactions.sign(@wid, PASS, tx_constructed['transaction'])
expect(tx_signed).to be_correct_and_respond 202

tx_submitted = PROXY.submit_external_transaction(Base64.decode64(tx_signed['transaction']))
tx_submitted = SHELLEY.transactions.submit(@wid, tx_signed['transaction'])
expect(tx_submitted).to be_correct_and_respond 202
tx_id = tx_submitted['id']
expect(SHELLEY.transactions.get(@wid, tx_id)['status']).to eq 'pending'

wait_for_tx_in_ledger(@wid, tx_id)

Expand Down
9 changes: 5 additions & 4 deletions test/e2e/spec/spec_helper.rb
Expand Up @@ -294,7 +294,7 @@ def teardown
##
# return asset total or available balance for comparison
# @param [Hash] assets - asset balance Hash from the wallet (output of get_wallet_balances['assets_*'])
# @param [Hash] options -
# @param [Hash] options -
# options[:delta] [Int] - received/sent assets that we are expecting (default: 0)
# options[:assets_to_check] [Array] - limit looking up balance to only assets in the array ["#{policy_id}#{asset_name}",...] (default: nil)
# @return [Set] Set of Hashes {"#{policy_id}#{asset_name}" => balance}
Expand Down Expand Up @@ -365,10 +365,10 @@ def verify_ada_balance(src_after, src_before, target_after, target_before, amt,
# @params src_after, src_before, target_after, target_before - src and target wallet balances before and after tx
# @param [Int] amt - amt of assets sent in tx
# @param [Array] assets_to_check - array of assets sent in the tx in the form of ["#{policy_id}#{asset_name}",...]
def verify_asset_balance(src_after, src_before, target_after, target_before, amt,
def verify_asset_balance(src_after, src_before, target_after, target_before, amt,
assets_to_check = ["#{ASSETS[0]['policy_id']}#{ASSETS[0]['asset_name']}",
"#{ASSETS[1]['policy_id']}#{ASSETS[1]['asset_name']}"])

target_total_after = assets_balance(target_after['assets_total'], {assets_to_check: assets_to_check})
target_avail_after = assets_balance(target_after['assets_available'], {assets_to_check: assets_to_check})
target_total_expected = assets_balance(target_before['assets_total'], {assets_to_check: assets_to_check, delta: (+amt)})
Expand Down Expand Up @@ -442,8 +442,9 @@ def balance_sign_submit(wid, payload)
tx_signed = SHELLEY.transactions.sign(wid, PASS, tx_balanced['transaction'])
expect(tx_signed).to be_correct_and_respond 202

tx_submitted = PROXY.submit_external_transaction(Base64.decode64(tx_signed['transaction']))
tx_submitted = SHELLEY.transactions.submit(wid, tx_signed['transaction'])
expect(tx_submitted).to be_correct_and_respond 202
expect(SHELLEY.transactions.get(wid, tx_submitted['id'])['status']).to eq 'pending'

[tx_balanced, tx_signed, tx_submitted]
end
Expand Down

0 comments on commit 517139b

Please sign in to comment.