Skip to content

Commit 7de0fd8

Browse files
authored
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 8f3ab31. * fmt
1 parent 8808da0 commit 7de0fd8

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use super::basic_contract_caller::*;
2+
use ink_e2e::ContractsBackend;
3+
4+
type E2EResult<T> = std::result::Result<T, Box<dyn std::error::Error>>;
5+
6+
#[ink_e2e::test]
7+
async fn flip_and_get<Client: E2EBackend>(mut client: Client) -> E2EResult<()> {
8+
// given
9+
let other_contract_code = client
10+
.upload("other-contract", &ink_e2e::alice())
11+
.submit()
12+
.await
13+
.expect("other_contract upload failed");
14+
15+
let mut constructor = BasicContractCallerRef::new(other_contract_code.code_hash);
16+
let contract = client
17+
.instantiate("basic-contract-caller", &ink_e2e::alice(), &mut constructor)
18+
.submit()
19+
.await
20+
.expect("basic-contract-caller instantiate failed");
21+
let mut call_builder = contract.call_builder::<BasicContractCaller>();
22+
let call = call_builder.flip_and_get();
23+
24+
// when
25+
let result = client
26+
.call(&ink_e2e::alice(), &call)
27+
.submit()
28+
.await
29+
.expect("Calling `flip_and_get` failed")
30+
.return_value();
31+
32+
assert_eq!(result, false);
33+
34+
Ok(())
35+
}

integration-tests/basic-contract-caller/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ mod basic_contract_caller {
3939
}
4040
}
4141
}
42+
43+
#[cfg(all(test, feature = "e2e-tests"))]
44+
mod e2e_tests;

0 commit comments

Comments
 (0)