Skip to content

Commit

Permalink
fix: update multitestrunner
Browse files Browse the repository at this point in the history
  • Loading branch information
ApolloGie committed Jul 14, 2024
1 parent 2559858 commit bc35aa0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
10 changes: 6 additions & 4 deletions src/multi_test/runner.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use crate::{traits::CwItRunner, ContractType};
use anyhow::bail;
use apollo_cw_multi_test::BankKeeper;
use apollo_cw_multi_test::{BankSudo, BasicAppBuilder};
use cosmrs::{crypto::secp256k1::SigningKey, proto::cosmos::base::abci::v1beta1::GasInfo};
use cosmwasm_std::{
Expand All @@ -20,11 +22,10 @@ use std::str::FromStr;
use test_tube::{
Account, DecodeError, EncodeError, FeeSetting, Runner, RunnerError, SigningAccount,
};
use cosmwasm_std::testing::MockApi;

use crate::{traits::CwItRunner, ContractType};

pub struct MultiTestRunner<'a> {
pub app: apollo_cw_multi_test::App,
pub struct MultiTestRunner<'a, B = BankKeeper, A = MockApi> {
pub app: apollo_cw_multi_test::App<B, A>,
pub address_prefix: &'a str,
}

Expand Down Expand Up @@ -660,3 +661,4 @@ mod tests {
assert_eq!(app.app.block_info().time.seconds(), time.seconds() + 69);
}
}

15 changes: 8 additions & 7 deletions src/test_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use std::{
};

use crate::{traits::CwItRunner, ContractType};
use apollo_cw_multi_test::BankKeeper;
use cw_multi_test::MockApiBech32;
use serde::de::DeserializeOwned;
use test_tube::{Runner, SigningAccount};

Expand All @@ -21,29 +23,27 @@ use osmosis_test_tube::OsmosisTestApp;
/// runners.
#[derive(strum::EnumVariantNames)]
#[strum(serialize_all = "kebab_case")]
pub enum OwnedTestRunner<'a> {
// Needed to keep lifetime when rpc-runner and multitest features are off
pub enum OwnedTestRunner<'a, B = BankKeeper, A = MockApiBech32> {
PhantomData(&'a ()),
#[cfg(feature = "osmosis-test-tube")]
OsmosisTestApp(OsmosisTestApp),
#[cfg(feature = "rpc-runner")]
RpcRunner(RpcRunner),
#[cfg(feature = "multi-test")]
MultiTest(MultiTestRunner<'a>),
MultiTest(MultiTestRunner<'a, B, A>),
}

/// A version of TestRunner which borrows the runner instead of owning it. This is useful for
/// passing a TestRunner to a function which needs to own it, but we don't want to give up ownership
/// of the runner.
pub enum TestRunner<'a> {
// Needed to keep lifetime when rpc-runner and multitest features are off
pub enum TestRunner<'a, B = BankKeeper, A = MockApiBech32> {
PhantomData(&'a ()),
#[cfg(feature = "osmosis-test-tube")]
OsmosisTestApp(&'a OsmosisTestApp),
#[cfg(feature = "rpc-runner")]
RpcRunner(&'a RpcRunner),
#[cfg(feature = "multi-test")]
MultiTest(&'a MultiTestRunner<'a>),
MultiTest(&'a MultiTestRunner<'a, B, A>),
}

impl<'a> OwnedTestRunner<'a> {
Expand Down Expand Up @@ -382,7 +382,7 @@ mod tests {

#[test]
fn test_runner_from_and_to_str() {
for str in OwnedTestRunner::VARIANTS {
for str in OwnedTestRunner::<BankKeeper, MockApiBech32>::VARIANTS {
match *str {
"phantom-data" => continue,
"rpc-runner" => match OwnedTestRunner::from_str(str) {
Expand All @@ -397,3 +397,4 @@ mod tests {
}
}
}

0 comments on commit bc35aa0

Please sign in to comment.