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

refactor: remove unused INSTNACE_CACHE #296

Merged
merged 1 commit into from
Apr 25, 2023
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
13 changes: 0 additions & 13 deletions packages/vm/src/testing/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@ use cosmwasm_std::testing::{digit_sum, riffle_shuffle};
use cosmwasm_std::{
Addr, BlockInfo, Coin, ContractInfo, Env, MessageInfo, Timestamp, TransactionInfo,
};
use std::cell::RefCell;
use std::collections::HashMap;
use std::sync::RwLock;
use std::thread_local;
use wasmer::Module;

use super::querier::MockQuerier;
use super::storage::MockStorage;
use crate::instance::Instance;
use crate::{Backend, BackendApi, BackendError, BackendResult, GasInfo};

pub const MOCK_CONTRACT_ADDR: &str = "cosmos2contract";
Expand Down Expand Up @@ -39,13 +33,6 @@ pub fn mock_backend_with_balances(
}
}

type MockInstance = Instance<MockApi, MockStorage, MockQuerier>;
thread_local! {
// INSTANCE_CACHE and MODULE_CACHE are intended to replace wasmvm's cache layer in the mock.
// Unlike wasmvm, you have to initialize them yourself in the place where you test the dynamic call.
pub static INSTANCE_CACHE: RwLock<HashMap<String, RefCell<MockInstance>>> = RwLock::new(HashMap::new());
pub static MODULE_CACHE: RwLock<HashMap<String, RefCell<Module>>> = RwLock::new(HashMap::new());
}
/// Length of canonical addresses created with this API. Contracts should not make any assumtions
/// what this value is.
/// The value here must be restorable with `SHUFFLES_ENCODE` + `SHUFFLES_DECODE` in-shuffles.
Expand Down
3 changes: 1 addition & 2 deletions packages/vm/src/testing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ pub use instance::{
test_io, MockInstanceOptions,
};
pub use mock::{
mock_backend, mock_backend_with_balances, mock_env, mock_info, MockApi, INSTANCE_CACHE,
MOCK_CONTRACT_ADDR,
mock_backend, mock_backend_with_balances, mock_env, mock_info, MockApi, MOCK_CONTRACT_ADDR,
};
pub use querier::MockQuerier;
pub use result::{TestingError, TestingResult};
Expand Down