Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🦖 fix e2e test, account for contract initial free balance #1777

Merged
merged 2 commits into from
May 12, 2023
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
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