Skip to content

Commit

Permalink
chore: Added description about mock for callee (#306)
Browse files Browse the repository at this point in the history
* Added description about mock for callee

* chore: fix the comment that clearly states that test is the target

* comment: fix as pointed out

* fix: fix ambiguous comment for dynamic link mock

* fix: typo
  • Loading branch information
Kynea0b authored Jul 11, 2023
1 parent 80f98b8 commit 9c673da
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions contracts/dynamic-caller-contract/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ struct CalleeContract {
address: Addr,
}

// When `user_defined_mock = true`, user can and must write mock implement
// with `#[cfg(not(target_arch = "wasm32"))]` for test of the trait for specified struct.
#[dynamic_link(CalleeContract, user_defined_mock = true)]
trait Callee: Contract {
fn pong(&self, ping_num: u64) -> u64;
Expand All @@ -44,6 +46,8 @@ trait Callee: Contract {
fn pong_with_stdresult_err(&self) -> StdResult<u64>;
}

// This is the mock implementation for test.
// So, this is specified by `#[cfg(not(target_arch = "wasm32"))]`.
#[cfg(not(target_arch = "wasm32"))]
impl Callee for CalleeContract {
fn pong(&self, ping_num: u64) -> u64 {
Expand Down

0 comments on commit 9c673da

Please sign in to comment.