Skip to content

Commit

Permalink
🦖 fix e2e test, account for contract initial free balance (#1777)
Browse files Browse the repository at this point in the history
* 🦖 fix e2e test, account for contract initial free balance

* fmt
  • Loading branch information
ascjones authored May 12, 2023
1 parent 522ed48 commit 79051da
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 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,10 @@ pub mod e2e_call_runtime {
.call_dry_run(&ink_e2e::alice(), &get_balance, 0, None)
.await;

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

Ok(())
}
Expand Down

0 comments on commit 79051da

Please sign in to comment.