Skip to content

Commit

Permalink
little osmosis test tube fixes and examples/Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Kayanski committed Jul 8, 2023
1 parent 91c09b9 commit 3b4c049
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ impl<Chain: CwEnv> Example<Chain> {

### Testing with OsmosisTestTube

OsmosisTestTube is available for testing in cw-orchestrator. In order to use it, you may need to install [clang] and [go] to compile the osmosis blockchain that serves as the backend for this env.
OsmosisTestTube is available for testing in cw-orchestrator. In order to use it, you may need to install [clang] and [go] to compile the osmosis blockchain that serves as the backend for this env. This compilation is taken care of by cargo directly but if you don't have the right dependencies installed, weird errors may arise. Visit https://docs.osmosis.zone/osmosis-core/osmosisd for a comprehensive list of dependencies.

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion contracts/counter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ counter-contract = { path = ".", features = ["interface"] }
# Deps for deployment
dotenv = { version = "0.15.0" }
env_logger = { version = "0.10.0" }
cw-orch = { path = "../../cw-orch", features = ["daemon", "test-tube"] }
cw-orch = { path = "../../cw-orch", features = ["daemon", "osmosis-test-tube"] }
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use counter_contract::{
msg::{GetCountResponse, InstantiateMsg, QueryMsg},
CounterContract,
};
use cw_orch::test_tube::OsmosisTestTube;
use cw_orch::osmosis_test_tube::OsmosisTestTube;
// Use prelude to get all the necessary imports
use cw_orch::prelude::*;

Expand Down
10 changes: 9 additions & 1 deletion cw-orch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ name = "mock_test"
name = "daemon_test"
required-features = ["daemon"]

[[example]]
name = "osmosis_test_tube"
required-features = ["osmosis-test-tube"]

[[example]]
name = "injective"
required-features = ["eth"]

[features]
default = []
# enable node-backed tests (ensure Docker is running)
Expand Down Expand Up @@ -52,7 +60,7 @@ daemon = [
"dep:prost",
]
eth = ["daemon", "dep:ethers-signers", "dep:ethers-core", "dep:snailquote"]
test-tube = ["dep:osmosis-test-tube"]
osmosis-test-tube = ["dep:osmosis-test-tube"]

[dependencies]
# Default deps
Expand Down
25 changes: 25 additions & 0 deletions cw-orch/examples/osmosis_test_tube.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use cosmwasm_std::coins;
use counter_contract::{
contract::CounterContract,
msg::{ExecuteMsg, GetCountResponse, InstantiateMsg, QueryMsg},
};
use cw_orch::prelude::OsmosisTestTube;
use cw_orch::prelude::{CwOrchExecute, CwOrchInstantiate, CwOrchQuery, CwOrchUpload};

pub fn main() {
let chain = OsmosisTestTube::new(coins(1_000_000_000_000, "uosmo"));

let contract_counter = CounterContract::new("mock:contract_counter", chain);

let upload_res = contract_counter.upload();
assert!(upload_res.is_ok());

let init_res = contract_counter.instantiate(&InstantiateMsg { count: 0 }, None, None);
assert!(init_res.is_ok());

let exec_res = contract_counter.execute(&ExecuteMsg::Increment {}, None);
assert!(exec_res.is_ok());

let query_res = contract_counter.query::<GetCountResponse>(&QueryMsg::GetCount {});
assert!(query_res.is_ok());
}
2 changes: 1 addition & 1 deletion cw-orch/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub enum CwOrchError {
#[cfg(feature = "daemon")]
#[error(transparent)]
DaemonError(#[from] DaemonError),
#[cfg(feature = "test-tube")]
#[cfg(feature = "osmosis-test-tube")]
#[error(transparent)]
TestTubeError(#[from] osmosis_test_tube::RunnerError),
#[error("JSON Conversion Error")]
Expand Down
4 changes: 2 additions & 2 deletions cw-orch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ mod interface_traits;
#[cfg(feature = "daemon")]
mod keys;
pub mod mock;
#[cfg(feature = "osmosis-test-tube")]
pub mod osmosis_test_tube;
mod paths;
#[cfg(feature = "test-tube")]
pub mod test_tube;

pub mod state;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ pub use osmosis_test_tube;
/// ## Example
/// ```
/// # use cosmwasm_std::{Addr, coins, Uint128};
/// use cw_orch::test_tube::OsmosisTestTube;
/// use crate::cw_orch::test_tube::osmosis_test_tube::Account;
/// use cw_orch::osmosis_test_tube::OsmosisTestTube;
/// use cw_orch::osmosis_test_tube::osmosis_test_tube::Account;
///
/// // Creates an app, creates a sender with an initial balance
/// let tube: OsmosisTestTube = OsmosisTestTube::new(coins(1_000_000_000_000, "uosmo"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Integration testing execution environment backed by a [test-tube](test_tube) App.
//! Integration testing execution environment backed by a [osmosis-test-tube](osmosis_test_tube) App.
//! It has an associated state that stores deployment information for easy retrieval and contract interactions.

mod core;
Expand Down
4 changes: 4 additions & 0 deletions cw-orch/src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ pub use crate::environment::{CwEnv, TxHandler, TxResponse};
// Mock for testing
pub use crate::mock::Mock;

// OsmosisTestTube for testing
#[cfg(feature = "osmosis-test-tube")]
pub use crate::osmosis_test_tube::OsmosisTestTube;

// error
pub use crate::error::CwOrchError;

Expand Down

0 comments on commit 3b4c049

Please sign in to comment.