Skip to content

Commit

Permalink
fix doc.rs errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kwtalley committed Apr 26, 2024
1 parent 407846a commit a2752e4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 40 deletions.
75 changes: 38 additions & 37 deletions packages/provwasm-test-tube/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,21 @@ Here is how to setup the test:

```rust
use cosmwasm_std::Coin;
use provwasm_test_tube::ProvwasmTestApp;

// create new provenance appchain instance.
let app = ProvwasmTestApp::new();

// create new account with initial funds
let accs = app
.init_accounts(
&[
Coin::new(1_000_000_000_000, "nhash"),
],
2,
)?;
use provwasm_test_tube::{ProvwasmTestApp, RunnerError};

#[test]
fn test() -> Result<(), RunnerError> {
// create new provenance appchain instance.
let app = ProvwasmTestApp::new();

// create new account with initial funds
let accs = app.init_accounts(&[Coin::new(1_000_000_000_000, "nhash")], 2)?;

let admin = &accs[0];
let new_admin = &accs[1];
let admin = &accs[0];
let new_admin = &accs[1];

Ok(())
}
```

Now we have the appchain instance and accounts that have some initial balances and can interact with the appchain.
Expand All @@ -55,13 +54,15 @@ If you want to create just one account, you can use `init_account` instead.

```rust
use cosmwasm_std::Coin;
use provwasm_test_tube::ProvwasmTestApp;
use provwasm_test_tube::{ProvwasmTestApp, RunnerError};

fn test() -> Result<(), RunnerError> {
let app = ProvwasmTestApp::new();

let app = ProvwasmTestApp::new();
let account = app.init_account(&[Coin::new(1_000_000_000_000, "nhash")])?;

let account = app.init_account(&[
Coin::new(1_000_000_000_000, "nhash"),
])?;
Ok(())
}
```

Now if we want to test a provwasm contract, we need to
Expand All @@ -73,21 +74,22 @@ Now if we want to test a provwasm contract, we need to
Then we can start interacting with our contract

```rust
use cosmwasm_std::{Coin, Uint128};
use provwasm_test_tube::wasm::Wasm;
use provwasm_test_tube::{Account, ProvwasmTestApp};

use marker::msg::{ExecuteMsg, InitMsg, QueryMsg};
use marker::types::Marker;
use cosmwasm_std::Coin;
use provwasm_test_tube::wasm::Wasm;
use provwasm_test_tube::{Module, ProvwasmTestApp, RunnerError};

let app = ProvwasmTestApp::default();
let accs = app.init_accounts(&[Coin::new(100_000_000_000_000, "nhash")], 1)?;
let admin = &accs[0];

let wasm = Wasm::new(&app);
let wasm_byte_code = std::fs::read("../contracts/marker/artifacts/marker.wasm").unwrap();
let store_res = wasm.store_code(&wasm_byte_code, None, admin);
let code_id = store_res?.data.code_id;
fn test() -> Result<(), RunnerError> {
let app = ProvwasmTestApp::default();
let accs = app.init_accounts(&[Coin::new(100_000_000_000_000, "nhash")], 1)?;
let admin = &accs[0];

let wasm = Wasm::new(&app);
let wasm_byte_code = std::fs::read("../contracts/marker/artifacts/marker.wasm").unwrap();
let store_res = wasm.store_code(&wasm_byte_code, None, admin);
let code_id = store_res?.data.code_id;

Ok(())
}
```

Now let's execute the contract and verify that the contract's state is updated properly.
Expand Down Expand Up @@ -216,11 +218,10 @@ use provwasm_std::types::provenance::marker::v1::{
#[test]
fn create_and_withdraw() -> Result<(), RunnerError> {
let app = ProvwasmTestApp::default();
let accs = app
.init_accounts(&[Coin::new(100_000_000_000_000, "nhash")], 1)?;
let accs = app.init_accounts(&[Coin::new(100_000_000_000_000, "nhash")], 1)?;
let admin = &accs[0];

let marker_module = provwasm_test_tube::module::marker::Marker::new(&app);
let marker_module = provwasm_test_tube::marker::Marker::new(&app);
marker_module.add_marker(
MsgAddMarkerRequest {
amount: Some(
Expand Down
6 changes: 3 additions & 3 deletions packages/provwasm-test-tube/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#![doc = include_str!("../README.md")]

mod module;
mod runner;

pub use cosmrs;
pub use provwasm_std;

Expand All @@ -10,6 +13,3 @@ pub use test_tube_prov::runner::error::{DecodeError, EncodeError, RunnerError};
pub use test_tube_prov::runner::result::{ExecuteResponse, RunnerExecuteResult, RunnerResult};
pub use test_tube_prov::runner::Runner;
pub use test_tube_prov::{fn_execute, fn_query};

pub mod module;
pub mod runner;

0 comments on commit a2752e4

Please sign in to comment.