Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump cw-orch to 0.24.0 #4

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 33 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "clone-cw-multi-test"
version = "0.4.0"
version = "0.5.0"
authors = ["Ethan Frey <ethanfrey@users.noreply.github.com>"]
edition = "2021"
description = "Testing tools for multi-contract interactions. Helps simulating chain behavior with on-chain storage locally"
Expand Down Expand Up @@ -36,7 +36,7 @@ thiserror = "1.0.50"

# Clone testing deps
## Network
cw-orch = { version = "0.23.0", features = ["daemon"] }
cw-orch = { version = "0.24.1", features = ["daemon"] }
tokio = "1.28.2"
tonic = "0.10.2"

Expand Down
15 changes: 3 additions & 12 deletions src/queries/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,14 @@ pub struct WasmRemoteQuerier;

impl WasmRemoteQuerier {
pub fn code_info(remote: RemoteChannel, code_id: u64) -> AnyResult<CodeInfoResponse> {
let wasm_querier = CosmWasm {
channel: remote.channel,
rt_handle: Some(remote.rt.clone()),
};
let wasm_querier = CosmWasm::new_sync(remote.channel, &remote.rt);

let code_info = remote.rt.block_on(wasm_querier._code(code_id))?;
Ok(code_info)
}

pub fn load_distant_contract(remote: RemoteChannel, address: &Addr) -> AnyResult<ContractData> {
let wasm_querier = CosmWasm {
channel: remote.channel,
rt_handle: Some(remote.rt.clone()),
};
let wasm_querier = CosmWasm::new_sync(remote.channel, &remote.rt);

let code_info = remote
.rt
Expand All @@ -46,10 +40,7 @@ impl WasmRemoteQuerier {
contract_addr: String,
key: Binary,
) -> AnyResult<Vec<u8>> {
let wasm_querier = CosmWasm {
channel: remote.channel,
rt_handle: Some(remote.rt.clone()),
};
let wasm_querier = CosmWasm::new_sync(remote.channel, &remote.rt);
let query_result = remote
.rt
.block_on(wasm_querier._contract_raw_state(contract_addr, key.to_vec()))
Expand Down
12 changes: 4 additions & 8 deletions src/wasm_emulation/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,8 @@ impl WasmContract {
match self {
WasmContract::Local(LocalWasmContract { code, .. }) => Ok(code.clone()),
WasmContract::DistantContract(DistantContract { contract_addr }) => {
let wasm_querier = CosmWasm {
channel: fork_state.remote.channel.clone(),
rt_handle: Some(fork_state.remote.rt.clone()),
};
let wasm_querier =
CosmWasm::new_sync(fork_state.remote.channel.clone(), &fork_state.remote.rt);

let code_info = fork_state
.remote
Expand All @@ -136,10 +134,8 @@ impl WasmContract {
Ok(code)
}
WasmContract::DistantCodeId(DistantCodeId { code_id }) => {
let wasm_querier = CosmWasm {
channel: fork_state.remote.channel.clone(),
rt_handle: Some(fork_state.remote.rt.clone()),
};
let wasm_querier =
CosmWasm::new_sync(fork_state.remote.channel.clone(), &fork_state.remote.rt);

let code = fork_state
.remote
Expand Down
4 changes: 2 additions & 2 deletions src/wasm_emulation/query/mock_querier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ impl<
self.staking = StakingQuerier::new(denom, validators, delegations);
}

pub fn with_custom_handler<CH: 'static>(mut self, handler: CH) -> Self
pub fn with_custom_handler<CH>(mut self, handler: CH) -> Self
where
CH: Fn(&QueryC) -> QueryResultWithGas,
CH: Fn(&QueryC) -> QueryResultWithGas + 'static,
{
self.custom_handler = Box::from(handler);
self
Expand Down
8 changes: 4 additions & 4 deletions src/wasm_emulation/storage/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ impl StorageAnalyzer {
}

pub fn compare_all_readable_contract_storage(&self) {
let wasm_querier = cw_orch::daemon::queriers::CosmWasm {
channel: self.remote.channel.clone(),
rt_handle: Some(self.remote.rt.clone()),
};
let wasm_querier = cw_orch::daemon::queriers::CosmWasm::new_sync(
self.remote.channel.clone(),
&self.remote.rt,
);
self.all_contract_storage()
.into_iter()
.for_each(|(contract_addr, key, value)| {
Expand Down
13 changes: 5 additions & 8 deletions src/wasm_emulation/storage/dual_std_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ impl<'i> Iterator for Iter<'i> {
&& (self.distant_iter.position == 0
|| !self.distant_iter.key.clone().unwrap().is_empty())
{
let wasm_querier = CosmWasm {
channel: self.distant_iter.remote.channel.clone(),
rt_handle: Some(self.distant_iter.remote.rt.clone()),
};
let wasm_querier = CosmWasm::new_sync(
self.distant_iter.remote.channel.clone(),
&self.distant_iter.remote.rt,
);
let new_keys = self
.distant_iter
.remote
Expand Down Expand Up @@ -160,10 +160,7 @@ impl<'a> Storage for DualStorage<'a> {
let mut value = self.local_storage.get(key);
// If it's not available, we query it online if it was not removed locally
if !self.removed_keys.contains(key) && value.as_ref().is_none() {
let wasm_querier = CosmWasm {
channel: self.remote.channel.clone(),
rt_handle: Some(self.remote.rt.clone()),
};
let wasm_querier = CosmWasm::new_sync(self.remote.channel.clone(), &self.remote.rt);

let distant_result = self.remote.rt.block_on(
wasm_querier._contract_raw_state(self.contract_addr.clone(), key.to_vec()),
Expand Down
10 changes: 2 additions & 8 deletions src/wasm_emulation/storage/dual_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,7 @@ impl Storage for DualStorage {
// If it's not available, we query it online if it was not removed locally
if !self.removed_keys.contains(key) && value.as_ref().unwrap().is_none() {
log::debug!(target: CLONE_TESTING_STORAGE_LOG, "Value not set locally, fetching remote key");
let wasm_querier = CosmWasm {
channel: self.remote.channel.clone(),
rt_handle: Some(self.remote.rt.clone()),
};
let wasm_querier = CosmWasm::new_sync(self.remote.channel.clone(), &self.remote.rt);

let distant_result = self.remote.rt.block_on(
wasm_querier._contract_raw_state(self.contract_addr.clone(), key.to_vec()),
Expand Down Expand Up @@ -200,10 +197,7 @@ impl Storage for DualStorage {
if iterator.distant_iter.position == iterator.distant_iter.data.len()
&& iterator.distant_iter.key.is_some()
{
let wasm_querier = CosmWasm {
channel: self.remote.channel.clone(),
rt_handle: Some(self.remote.rt.clone()),
};
let wasm_querier = CosmWasm::new_sync(self.remote.channel.clone(), &self.remote.rt);
let new_keys = self
.remote
.rt
Expand Down