Skip to content

Commit d0b6a22

Browse files
committed
virtual-staking tests work
1 parent 7a04da5 commit d0b6a22

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

contracts/consumer/converter/src/multitest.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
mod virtual_staking_mock;
22

33
use cosmwasm_std::{coin, coins, Addr, Decimal, StdError, Uint128, Validator};
4-
use cw_multi_test::no_init;
5-
use cw_multi_test::AppBuilder;
4+
use cw_multi_test::{no_init, AppBuilder};
65
use mesh_apis::converter_api::sv::mt::ConverterApiProxy;
76
use mesh_apis::converter_api::RewardInfo;
87
use mesh_simple_price_feed::contract::sv::mt::CodeId as PriceFeedCodeId;

contracts/consumer/remote-price-feed/src/contract.rs

+3
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ impl RemotePriceFeedContract {
8484

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

8891
/// Return the price of the foreign token. That is, how many native tokens
8992
/// are needed to buy one foreign token.

contracts/consumer/virtual-staking/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ serde = { workspace = true }
3535
thiserror = { workspace = true }
3636

3737
[dev-dependencies]
38-
mesh-simple-price-feed = { workspace = true, features = ["mt"] }
39-
mesh-converter = { workspace = true, features = ["mt"] }
38+
mesh-simple-price-feed = { workspace = true, features = ["mt", "fake-custom"] }
39+
mesh-converter = { workspace = true, features = ["mt", "fake-custom"] }
4040
cw-multi-test = { workspace = true }
4141
test-case = { workspace = true }
4242
derivative = { workspace = true }

contracts/consumer/virtual-staking/src/multitest.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
use cosmwasm_std::{Addr, Decimal, Validator};
2+
use cw_multi_test::{no_init, AppBuilder};
3+
use mesh_apis::virtual_staking_api::sv::mt::VirtualStakingApiProxy;
24
use sylvia::multitest::Proxy;
35

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

68
use crate::contract;
79
use crate::contract::sv::mt::VirtualStakingContractProxy;
8-
use crate::contract::sv::ContractSudoMsg;
910

1011
const JUNO: &str = "ujuno";
1112

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

33+
fn new_app() -> App {
34+
App::new(AppBuilder::new_custom().build(no_init))
35+
}
36+
3237
fn setup<'a>(app: &'a App, args: SetupArgs<'a>) -> SetupResponse<'a> {
3338
let SetupArgs {
3439
owner,
@@ -73,7 +78,7 @@ fn setup<'a>(app: &'a App, args: SetupArgs<'a>) -> SetupResponse<'a> {
7378

7479
#[test]
7580
fn instantiation() {
76-
let app = App::default();
81+
let app = new_app();
7782

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

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

121127
let owner = "sunny"; // Owner of the staking contract (i. e. the vault contract)
122128
let admin = "theman";
@@ -154,8 +160,8 @@ fn valset_update_sudo() {
154160
];
155161
let rems = vec!["cosmosval2".to_string()];
156162
let tombs = vec!["cosmosval3".to_string()];
157-
// See this as an example how we can make working directly with these genertaed enums nicer
158-
let inner = mesh_apis::virtual_staking_api::sv::VirtualStakingApiSudoMsg::handle_valset_update(
163+
164+
let res = virtual_staking.handle_valset_update(
159165
Some(adds),
160166
Some(rems),
161167
None,
@@ -164,12 +170,6 @@ fn valset_update_sudo() {
164170
Some(tombs),
165171
None,
166172
);
167-
let msg = ContractSudoMsg::VirtualStakingApi(inner);
168-
169-
let res = app
170-
.app_mut()
171-
.wasm_sudo(virtual_staking.contract_addr, &msg)
172-
.unwrap();
173-
174173
println!("res: {:?}", res);
174+
res.unwrap();
175175
}

0 commit comments

Comments
 (0)