Skip to content

Commit

Permalink
Add basic-contract-caller E2E test (#2085)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
ascjones committed Feb 1, 2024
1 parent a0813f9 commit bab2e0a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
35 changes: 35 additions & 0 deletions integration-tests/basic-contract-caller/e2e_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
use super::basic_contract_caller::*;
use ink_e2e::ContractsBackend;

type E2EResult<T> = std::result::Result<T, Box<dyn std::error::Error>>;

#[ink_e2e::test]
async fn flip_and_get<Client: E2EBackend>(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::<BasicContractCaller>();
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(())
}
3 changes: 3 additions & 0 deletions integration-tests/basic-contract-caller/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ mod basic_contract_caller {
}
}
}

#[cfg(all(test, feature = "e2e-tests"))]
mod e2e_tests;

0 comments on commit bab2e0a

Please sign in to comment.