From 53b452df9a8198c4fe286d80a8bc7194613312cc Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Fri, 12 May 2023 09:54:05 +0100 Subject: [PATCH 1/2] :t-rex: fix e2e test, account for contract initial free balance --- integration-tests/e2e-call-runtime/lib.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/integration-tests/e2e-call-runtime/lib.rs b/integration-tests/e2e-call-runtime/lib.rs index 07fa4cf87a7..f7c80a1a488 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,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(()) } From ec23f38f1bc8fe12391e83eee8046f2fc404d85d Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Fri, 12 May 2023 09:59:58 +0100 Subject: [PATCH 2/2] fmt --- integration-tests/e2e-call-runtime/lib.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/integration-tests/e2e-call-runtime/lib.rs b/integration-tests/e2e-call-runtime/lib.rs index f7c80a1a488..5b64d93b2d3 100644 --- a/integration-tests/e2e-call-runtime/lib.rs +++ b/integration-tests/e2e-call-runtime/lib.rs @@ -70,7 +70,10 @@ pub mod e2e_call_runtime { .call_dry_run(&ink_e2e::alice(), &get_balance, 0, None) .await; - assert_eq!(get_balance_res.return_value(), pre_balance + transfer_amount); + assert_eq!( + get_balance_res.return_value(), + pre_balance + transfer_amount + ); Ok(()) }