Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
🦖 fix e2e test, account for contract initial free balance
  • Loading branch information
ascjones committed May 12, 2023
commit 53b452df9a8198c4fe286d80a8bc7194613312cc
16 changes: 11 additions & 5 deletions integration-tests/e2e-call-runtime/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,25 @@ pub mod e2e_call_runtime {
.expect("instantiate failed")
.account_id;

let transfer_amount = 100_000_000_000u128;

// when
let call_data = vec![
// A value representing a `MultiAddress<AccountId32, _>`. We want the
// "Id" variant, and that will ultimately contain the
// bytes for our destination address
Value::unnamed_variant("Id", [Value::from_bytes(&contract_acc_id)]),
// A value representing the amount we'd like to transfer.
Value::u128(100_000_000_000u128),
Value::u128(transfer_amount),
];

let get_balance = build_message::<ContractRef>(contract_acc_id.clone())
.call(|contract| contract.get_contract_balance());
let pre_balance = client
.call_dry_run(&ink_e2e::alice(), &get_balance, 0, None)
.await
.return_value();

// Send funds from Alice to the contract using Balances::transfer
client
.runtime_call(&ink_e2e::alice(), "Balances", "transfer", call_data)
Expand All @@ -61,10 +70,7 @@ pub mod e2e_call_runtime {
.call_dry_run(&ink_e2e::alice(), &get_balance, 0, None)
.await;

assert!(matches!(
get_balance_res.return_value(),
100_000_000_000u128
));
assert_eq!(get_balance_res.return_value(), pre_balance + transfer_amount);

Ok(())
}
Expand Down