From 484526d659f1aaac8d6470536ff1b046c0877ad1 Mon Sep 17 00:00:00 2001 From: kokeshiM0chi Date: Wed, 14 Jun 2023 19:55:26 +0900 Subject: [PATCH 1/5] Added description about mock for callee --- contracts/dynamic-caller-contract/src/contract.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contracts/dynamic-caller-contract/src/contract.rs b/contracts/dynamic-caller-contract/src/contract.rs index 9b53faf62..66014966e 100644 --- a/contracts/dynamic-caller-contract/src/contract.rs +++ b/contracts/dynamic-caller-contract/src/contract.rs @@ -24,6 +24,8 @@ struct CalleeContract { address: Addr, } +// When `user_defined_mock = true`, user can and must write mock implement +// of the trait for specified struct with `#[cfg(not(target_arch = "wasm32"))]`. #[dynamic_link(CalleeContract, user_defined_mock = true)] trait Callee: Contract { fn pong(&self, ping_num: u64) -> u64; @@ -38,6 +40,7 @@ trait Callee: Contract { fn call_caller_address_of(&self, addr: Addr) -> Addr; } +// This is the mock implementation specified by `#[cfg(not(target_arch = "wasm32"))]`. #[cfg(not(target_arch = "wasm32"))] impl Callee for CalleeContract { fn pong(&self, ping_num: u64) -> u64 { From 6dcd02af5cf18536ba8fe6d384b67c81610a90f3 Mon Sep 17 00:00:00 2001 From: kokeshiM0chi Date: Thu, 15 Jun 2023 15:30:25 +0900 Subject: [PATCH 2/5] chore: fix the comment that clearly states that test is the target --- contracts/dynamic-caller-contract/src/contract.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/contracts/dynamic-caller-contract/src/contract.rs b/contracts/dynamic-caller-contract/src/contract.rs index 66014966e..7025aea9d 100644 --- a/contracts/dynamic-caller-contract/src/contract.rs +++ b/contracts/dynamic-caller-contract/src/contract.rs @@ -24,8 +24,8 @@ struct CalleeContract { address: Addr, } -// When `user_defined_mock = true`, user can and must write mock implement -// of the trait for specified struct with `#[cfg(not(target_arch = "wasm32"))]`. +// When a trait is specified with `user_defined_mock = true`, user can and must write mock implement for test. +// Such a trait is the trait for the struct specified by `#[cfg(not(target_arch = "wasm32"))]`. #[dynamic_link(CalleeContract, user_defined_mock = true)] trait Callee: Contract { fn pong(&self, ping_num: u64) -> u64; @@ -40,7 +40,8 @@ trait Callee: Contract { fn call_caller_address_of(&self, addr: Addr) -> Addr; } -// This is the mock implementation specified by `#[cfg(not(target_arch = "wasm32"))]`. +// 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 { From 1f71de2c03fe31306d63ef31c2740583da390be3 Mon Sep 17 00:00:00 2001 From: kokeshiM0chi Date: Mon, 26 Jun 2023 15:10:27 +0900 Subject: [PATCH 3/5] comment: fix as pointed out --- contracts/dynamic-caller-contract/src/contract.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/dynamic-caller-contract/src/contract.rs b/contracts/dynamic-caller-contract/src/contract.rs index 7025aea9d..85f02afd3 100644 --- a/contracts/dynamic-caller-contract/src/contract.rs +++ b/contracts/dynamic-caller-contract/src/contract.rs @@ -24,8 +24,8 @@ struct CalleeContract { address: Addr, } -// When a trait is specified with `user_defined_mock = true`, user can and must write mock implement for test. -// Such a trait is the trait for the struct specified by `#[cfg(not(target_arch = "wasm32"))]`. +// When `user_defined_mock = true`, user can and must write mock implement for test +// of the trait for specified struct with `#[cfg(not(target_arch = "wasm32"))]`. #[dynamic_link(CalleeContract, user_defined_mock = true)] trait Callee: Contract { fn pong(&self, ping_num: u64) -> u64; From 4f26a419b669f91e942316f3ca4c2d8e3fbbe8b7 Mon Sep 17 00:00:00 2001 From: kokeshiM0chi Date: Tue, 11 Jul 2023 16:19:48 +0900 Subject: [PATCH 4/5] fix: fix ambiguous comment for dynamic link mock --- contracts/dynamic-caller-contract/src/contract.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/dynamic-caller-contract/src/contract.rs b/contracts/dynamic-caller-contract/src/contract.rs index 85f02afd3..49bfcc84f 100644 --- a/contracts/dynamic-caller-contract/src/contract.rs +++ b/contracts/dynamic-caller-contract/src/contract.rs @@ -24,8 +24,8 @@ struct CalleeContract { address: Addr, } -// When `user_defined_mock = true`, user can and must write mock implement for test -// of the trait for specified struct with `#[cfg(not(target_arch = "wasm32"))]`. +// 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; From 995b15419f0c5706c3628479eef0713f65cc6b81 Mon Sep 17 00:00:00 2001 From: kokeshiM0chi Date: Tue, 11 Jul 2023 20:14:21 +0900 Subject: [PATCH 5/5] fix: typo --- contracts/dynamic-caller-contract/src/contract.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/dynamic-caller-contract/src/contract.rs b/contracts/dynamic-caller-contract/src/contract.rs index 49bfcc84f..2948a0f83 100644 --- a/contracts/dynamic-caller-contract/src/contract.rs +++ b/contracts/dynamic-caller-contract/src/contract.rs @@ -25,7 +25,7 @@ struct CalleeContract { } // 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 . +// 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;