Skip to content

Commit

Permalink
virtual-staking tests work
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanfrey committed May 13, 2024
1 parent 7a04da5 commit d0b6a22
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
3 changes: 1 addition & 2 deletions contracts/consumer/converter/src/multitest.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
mod virtual_staking_mock;

use cosmwasm_std::{coin, coins, Addr, Decimal, StdError, Uint128, Validator};
use cw_multi_test::no_init;
use cw_multi_test::AppBuilder;
use cw_multi_test::{no_init, AppBuilder};
use mesh_apis::converter_api::sv::mt::ConverterApiProxy;
use mesh_apis::converter_api::RewardInfo;
use mesh_simple_price_feed::contract::sv::mt::CodeId as PriceFeedCodeId;
Expand Down
3 changes: 3 additions & 0 deletions contracts/consumer/remote-price-feed/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ impl RemotePriceFeedContract {

impl PriceFeedApi for RemotePriceFeedContract {
type Error = ContractError;
// FIXME: make these under a feature flag if we need virtual-staking multitest compatibility
type ExecC = cosmwasm_std::Empty;
type QueryC = cosmwasm_std::Empty;

/// Return the price of the foreign token. That is, how many native tokens
/// are needed to buy one foreign token.
Expand Down
4 changes: 2 additions & 2 deletions contracts/consumer/virtual-staking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ serde = { workspace = true }
thiserror = { workspace = true }

[dev-dependencies]
mesh-simple-price-feed = { workspace = true, features = ["mt"] }
mesh-converter = { workspace = true, features = ["mt"] }
mesh-simple-price-feed = { workspace = true, features = ["mt", "fake-custom"] }
mesh-converter = { workspace = true, features = ["mt", "fake-custom"] }
cw-multi-test = { workspace = true }
test-case = { workspace = true }
derivative = { workspace = true }
Expand Down
26 changes: 13 additions & 13 deletions contracts/consumer/virtual-staking/src/multitest.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use cosmwasm_std::{Addr, Decimal, Validator};
use cw_multi_test::{no_init, AppBuilder};
use mesh_apis::virtual_staking_api::sv::mt::VirtualStakingApiProxy;
use sylvia::multitest::Proxy;

use mesh_converter::contract::sv::mt::ConverterContractProxy;

use crate::contract;
use crate::contract::sv::mt::VirtualStakingContractProxy;
use crate::contract::sv::ContractSudoMsg;

const JUNO: &str = "ujuno";

Expand All @@ -29,6 +30,10 @@ struct SetupResponse<'a> {
virtual_staking: Proxy<'a, MtApp, contract::VirtualStakingContract<'a>>,
}

fn new_app() -> App {
App::new(AppBuilder::new_custom().build(no_init))
}

fn setup<'a>(app: &'a App, args: SetupArgs<'a>) -> SetupResponse<'a> {
let SetupArgs {
owner,
Expand Down Expand Up @@ -73,7 +78,7 @@ fn setup<'a>(app: &'a App, args: SetupArgs<'a>) -> SetupResponse<'a> {

#[test]
fn instantiation() {
let app = App::default();
let app = new_app();

let owner = "sunny"; // Owner of the staking contract (i. e. the vault contract)
let admin = "theman";
Expand Down Expand Up @@ -114,9 +119,10 @@ fn instantiation() {
}

#[test]
#[ignore] // FIXME: Enable / finish this test once custom query support is added to sylvia
// FIXME: Enable / finish this test once custom query support is added to sylvia
#[ignore = "IBC Messages not supported yet"]
fn valset_update_sudo() {
let app = App::<MtApp>::default();
let app = new_app();

let owner = "sunny"; // Owner of the staking contract (i. e. the vault contract)
let admin = "theman";
Expand Down Expand Up @@ -154,8 +160,8 @@ fn valset_update_sudo() {
];
let rems = vec!["cosmosval2".to_string()];
let tombs = vec!["cosmosval3".to_string()];
// See this as an example how we can make working directly with these genertaed enums nicer
let inner = mesh_apis::virtual_staking_api::sv::VirtualStakingApiSudoMsg::handle_valset_update(

let res = virtual_staking.handle_valset_update(
Some(adds),
Some(rems),
None,
Expand All @@ -164,12 +170,6 @@ fn valset_update_sudo() {
Some(tombs),
None,
);
let msg = ContractSudoMsg::VirtualStakingApi(inner);

let res = app
.app_mut()
.wasm_sudo(virtual_staking.contract_addr, &msg)
.unwrap();

println!("res: {:?}", res);
res.unwrap();
}

0 comments on commit d0b6a22

Please sign in to comment.