Skip to content

Commit 717366e

Browse files
committed
feat: injective-testing 1.1.13-1
1 parent 58f324a commit 717366e

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

packages/injective-testing/src/multi_test/address_generator.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const ADDRESS_BYTE_INDEX: usize = KECCAK_OUTPUT_BYTES - ADDRESS_BYTES;
1313
pub struct InjectiveAddressGenerator();
1414

1515
impl AddressGenerator for InjectiveAddressGenerator {
16-
fn contract_address(&self, _api: &dyn cosmwasm_std::Api, _storage: &mut dyn Storage, _code_id: u64, _instance_id: u64) -> anyhow::Result<Addr> {
16+
fn contract_address(&self, _api: &dyn cosmwasm_std::Api, _storage: &mut dyn Storage, _code_id: u64, _instance_id: u64) -> Result<Addr, cosmwasm_std::StdError> {
1717
Ok(generate_inj_address())
1818
}
1919

@@ -26,7 +26,7 @@ impl AddressGenerator for InjectiveAddressGenerator {
2626
checksum: &[u8],
2727
creator: &cosmwasm_std::CanonicalAddr,
2828
salt: &[u8],
29-
) -> anyhow::Result<Addr> {
29+
) -> Result<Addr, cosmwasm_std::StdError> {
3030
let canonical_addr = cosmwasm_std::instantiate2_address(checksum, creator, salt)?;
3131
Ok(api.addr_humanize(&canonical_addr)?)
3232
}
@@ -45,7 +45,7 @@ impl Default for StorageAwareInjectiveAddressGenerator {
4545
}
4646

4747
impl AddressGenerator for StorageAwareInjectiveAddressGenerator {
48-
fn contract_address(&self, _api: &dyn cosmwasm_std::Api, storage: &mut dyn Storage, _code_id: u64, _instance_id: u64) -> anyhow::Result<Addr> {
48+
fn contract_address(&self, _api: &dyn cosmwasm_std::Api, storage: &mut dyn Storage, _code_id: u64, _instance_id: u64) -> Result<Addr, cosmwasm_std::StdError>{
4949
let generated_address = generate_inj_address();
5050
let key = self.key.as_bytes();
5151
let stored = storage.get(key);

packages/injective-testing/src/multi_test/chain_mock.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
use crate::multi_test::address_generator::InjectiveAddressGenerator;
2-
3-
use anyhow::{bail, Result as AnyResult};
4-
use cosmwasm_std::{testing::MockApi, Addr, Api, Binary, BlockInfo, Coin, CustomQuery, Empty, MemoryStorage, Querier, Storage};
5-
use cosmwasm_std::{to_json_binary, StdError};
2+
use cosmwasm_std::{testing::{MockApi, MockStorage}, Addr, Api, Binary, BlockInfo, Coin, CustomQuery, Empty, Querier, Storage, to_json_binary, StdError};
63
use cw_multi_test::{
74
no_init, AddressGenerator, App, AppResponse, BankKeeper, BasicAppBuilder, CosmosRouter, Module, StargateAccepting, StargateFailing, WasmKeeper,
85
};
@@ -19,7 +16,7 @@ pub enum StargateT {
1916
Failing(StargateFailing),
2017
}
2118

22-
pub type MockedInjectiveApp = App<BankKeeper, MockApi, MemoryStorage, CustomInjectiveHandler, WasmKeeper<InjectiveMsgWrapper, InjectiveQueryWrapper>>;
19+
pub type MockedInjectiveApp = App<BankKeeper, MockApi, MockStorage, CustomInjectiveHandler, WasmKeeper<InjectiveMsgWrapper, InjectiveQueryWrapper>>;
2320

2421
#[derive(Clone)]
2522
pub struct InitialBalance {
@@ -194,7 +191,7 @@ impl Module for CustomInjectiveHandler {
194191
_block: &BlockInfo,
195192
_sender: Addr,
196193
msg: Self::ExecT,
197-
) -> AnyResult<AppResponse> {
194+
) -> Result<AppResponse, StdError> {
198195
let mut exec_calls_count = self.state.execs.borrow().len();
199196

200197
if !self.assertions.executes.is_empty()
@@ -230,11 +227,11 @@ impl Module for CustomInjectiveHandler {
230227
}),
231228
&None => Ok(AppResponse::default()),
232229
},
233-
Err(e) => Err(anyhow::Error::new(StdError::generic_err(e.to_string()))),
230+
Err(e) => Err(StdError::msg(e.to_string())),
234231
}
235232
}
236233

237-
fn query(&self, _api: &dyn Api, _storage: &dyn Storage, _querier: &dyn Querier, _block: &BlockInfo, request: Self::QueryT) -> AnyResult<Binary> {
234+
fn query(&self, _api: &dyn Api, _storage: &dyn Storage, _querier: &dyn Querier, _block: &BlockInfo, request: Self::QueryT) -> Result<Binary, StdError> {
238235
let mut query_calls_count = self.state.queries.borrow().len();
239236

240237
if !self.assertions.queries.is_empty()
@@ -263,7 +260,7 @@ impl Module for CustomInjectiveHandler {
263260
// and that's the reason why I'm manually copying the underlying [u8] in order to return owned data
264261
match &stored_result {
265262
Ok(optional_data) => Ok(copy_binary(optional_data)),
266-
Err(e) => Err(anyhow::Error::new(StdError::generic_err(e.to_string()))),
263+
Err(e) => Err(StdError::msg(e.to_string())),
267264
}
268265
}
269266
}
@@ -275,8 +272,8 @@ impl Module for CustomInjectiveHandler {
275272
_router: &dyn CosmosRouter<ExecC = ExecC, QueryC = QueryC>,
276273
_block: &BlockInfo,
277274
msg: Self::SudoT,
278-
) -> AnyResult<AppResponse> {
279-
bail!("Unexpected sudo msg {:?}", msg)
275+
) -> Result<AppResponse, StdError> {
276+
Err(StdError::msg(format!("Unexpected sudo msg {:?}", msg)))
280277
}
281278
}
282279

0 commit comments

Comments
 (0)