From 79051da301ce9e6e857bc65daf357ed8ad8ebb30 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Fri, 12 May 2023 10:27:20 +0100 Subject: [PATCH] :t-rex: fix e2e test, account for contract initial free balance (#1777) * :t-rex: fix e2e test, account for contract initial free balance * fmt --- integration-tests/e2e-call-runtime/lib.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/integration-tests/e2e-call-runtime/lib.rs b/integration-tests/e2e-call-runtime/lib.rs index 07fa4cf87a7..5b64d93b2d3 100644 --- a/integration-tests/e2e-call-runtime/lib.rs +++ b/integration-tests/e2e-call-runtime/lib.rs @@ -38,6 +38,8 @@ 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`. We want the @@ -45,9 +47,16 @@ pub mod e2e_call_runtime { // 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::(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) @@ -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(()) }