From bab2e0a0fa78c7b1e539b43a578625a41e90e5b8 Mon Sep 17 00:00:00 2001 From: Andrew Jones Date: Wed, 31 Jan 2024 12:42:41 +0000 Subject: [PATCH] Add `basic-contract-caller` E2E test (#2085) * add e2e tests to basic-contract-caller example * Fix basic-contract-caller e2e tests * Remove `call_builder` change * Remove `basic_contract_caller` integration test, moved to #1909 * Revert "Remove `basic_contract_caller` integration test, moved to #1909" This reverts commit 8f3ab318035735545af513893556658b709c5244. * fmt --- .../basic-contract-caller/e2e_tests.rs | 35 +++++++++++++++++++ .../basic-contract-caller/lib.rs | 3 ++ 2 files changed, 38 insertions(+) create mode 100644 integration-tests/basic-contract-caller/e2e_tests.rs diff --git a/integration-tests/basic-contract-caller/e2e_tests.rs b/integration-tests/basic-contract-caller/e2e_tests.rs new file mode 100644 index 0000000000..e9ce86d4bc --- /dev/null +++ b/integration-tests/basic-contract-caller/e2e_tests.rs @@ -0,0 +1,35 @@ +use super::basic_contract_caller::*; +use ink_e2e::ContractsBackend; + +type E2EResult = std::result::Result>; + +#[ink_e2e::test] +async fn flip_and_get(mut client: Client) -> E2EResult<()> { + // given + let other_contract_code = client + .upload("other-contract", &ink_e2e::alice()) + .submit() + .await + .expect("other_contract upload failed"); + + let mut constructor = BasicContractCallerRef::new(other_contract_code.code_hash); + let contract = client + .instantiate("basic-contract-caller", &ink_e2e::alice(), &mut constructor) + .submit() + .await + .expect("basic-contract-caller instantiate failed"); + let mut call_builder = contract.call_builder::(); + let call = call_builder.flip_and_get(); + + // when + let result = client + .call(&ink_e2e::alice(), &call) + .submit() + .await + .expect("Calling `flip_and_get` failed") + .return_value(); + + assert_eq!(result, false); + + Ok(()) +} diff --git a/integration-tests/basic-contract-caller/lib.rs b/integration-tests/basic-contract-caller/lib.rs index f988caabf4..78c999d7c2 100755 --- a/integration-tests/basic-contract-caller/lib.rs +++ b/integration-tests/basic-contract-caller/lib.rs @@ -39,3 +39,6 @@ mod basic_contract_caller { } } } + +#[cfg(all(test, feature = "e2e-tests"))] +mod e2e_tests;