Skip to content

Commit

Permalink
Fix E2E expectations by using structured value infos. (#4378)
Browse files Browse the repository at this point in the history
- [x] I have replaced expectations based on the substring search with
the direct equality test that uses fields of structured error infos.
- [x] Adjusted rspec setting to avoid compacting expected values in
error reports.

### Issue Number

ADP-3249
  • Loading branch information
paolino authored Dec 28, 2023
2 parents 2253b4c + 110d99a commit 87e66d5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
22 changes: 12 additions & 10 deletions test/e2e/spec/e2e_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2077,8 +2077,9 @@ def script_hash
burn)
expect(tx_constructed).to be_correct_and_respond 403
expect(tx_constructed['code'].to_s).to eq 'not_enough_money'
expect(tx_constructed['info']['shortfall'].to_s).to include "assetName: #{asset_name('AmazingNFTIdontHave')}"
expect(tx_constructed['info']['shortfall'].to_s).to include 'quantity: 1'
shortfall = tx_constructed['info']['shortfall']['assets'][0]
expect(shortfall['asset_name']).to eq asset_name('AmazingNFTIdontHave')
expect(shortfall['quantity']).to eq 1
end

##
Expand Down Expand Up @@ -2115,8 +2116,9 @@ def script_hash

expect(tx_constructed).to be_correct_and_respond 403
expect(tx_constructed['code'].to_s).to eq 'not_enough_money'
expect(tx_constructed['info']['shortfall'].to_s).to include "assetName: #{asset_name('MintIt')}"
expect(tx_constructed['info']['shortfall'].to_s).to include 'quantity: 1000'
shortfall = tx_constructed['info']['shortfall']['assets'][0]
expect(shortfall['asset_name']).to eq asset_name('MintIt')
expect(shortfall['quantity']).to eq 1000

# - correct policy_script but too much
burn2 = [burn(asset_name('MintIt'), 1022, policy_script)]
Expand All @@ -2129,8 +2131,9 @@ def script_hash

expect(tx_constructed).to be_correct_and_respond 403
expect(tx_constructed['code'].to_s).to eq 'not_enough_money'
expect(tx_constructed['info']['shortfall'].to_s).to include "assetName: #{asset_name('MintIt')}"
expect(tx_constructed['info']['shortfall'].to_s).to include 'quantity: 22'
shortfall = tx_constructed['info']['shortfall']['assets'][0]
expect(shortfall['asset_name']).to eq asset_name('MintIt')
expect(shortfall['quantity']).to eq 22

# Burn it:
burn3 = [burn(asset_name('MintIt'), 1000, policy_script)]
Expand Down Expand Up @@ -2200,8 +2203,9 @@ def script_hash
burn)
expect(tx_constructed).to be_correct_and_respond 403
expect(tx_constructed['code'].to_s).to eq 'not_enough_money'
expect(tx_constructed['info']['shortfall'].to_s).to include "assetName: #{assets_name}"
expect(tx_constructed['info']['shortfall'].to_s).to include "quantity: #{assets_quantity}"
shortfall = tx_constructed['info']['shortfall']['assets'][0]
expect(shortfall['asset_name']).to eq assets_name
expect(shortfall['quantity']).to eq assets_quantity

# Send them back to src wallet:
src_address = SHELLEY.addresses.list(@wid).first['id']
Expand Down Expand Up @@ -2274,8 +2278,6 @@ def script_hash
mint)
expect(tx_constructed).to be_correct_and_respond code
expect(tx_constructed['code'].to_s).to eq message
# expect(tx_constructed['info']['shortfall'].to_s).to include "assetName: #{asset_name('AmazingNFTIdontHave')}"
# expect(tx_constructed['info']['shortfall'].to_s).to include "quantity: 1"
end

it "Cannot burn #{quantity} assets" do
Expand Down
1 change: 1 addition & 0 deletions test/e2e/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

config.expect_with :rspec do |c|
c.syntax = :expect
c.max_formatted_output_length = nil
end
end

Expand Down

0 comments on commit 87e66d5

Please sign in to comment.