Skip to content

Commit

Permalink
Merge branch 'master' into aj/e2e-improve-call
Browse files Browse the repository at this point in the history
  • Loading branch information
ascjones committed May 17, 2023
2 parents d4c9570 + 79051da commit ece5722
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 ece5722

Please # to comment.