Skip to content

Commit

Permalink
happier
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitry-lahoda committed Apr 11, 2024
1 parent de1bde9 commit 57cb25a
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 7 deletions.
4 changes: 2 additions & 2 deletions mantis/node/src/mantis/blackbox/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub async fn solve<Decider: Get<bool>>(
signing_key: &cosmrs::crypto::secp256k1::SigningKey,
tip: &Tip,
cvm_glt: Option<cw_cvm_outpost::msg::CvmGlt>,
router: &String,
router: &str,
) -> Vec<cw_mantis_order::ExecMsg> {
let cows_per_pair = find_cows(&active_orders);
let mut msgs = vec![];
Expand Down Expand Up @@ -196,7 +196,7 @@ async fn intent_banks_to_cvm_program(
pair_solution: PairSolution,
all_orders: &Vec<OrderItem>,
cvm_glt: &cw_cvm_outpost::msg::GetConfigResponse,
router_api: &String,
router_api: &str,
salt: &Vec<u8>,
) -> CvmProgram {
let (a, b) = IntentBankInput::find_intent_amount(
Expand Down
83 changes: 78 additions & 5 deletions mantis/node/tests/cvms.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
use cosmwasm_std::{Addr, Empty};
use cw_cvm_outpost::msg::HereItem;
use bounded_collections::Get;
use cosmrs::tendermint::block::Height;
use cosmwasm_std::{Addr, Coin, Coins, Empty};
use cw_cvm_outpost::msg::{CvmGlt, HereItem};
use cw_mantis_order::{OrderItem, OrderSubMsg};
use cw_multi_test::{App, Contract, ContractWrapper, Executor};
use mantis_node::mantis::cosmos::{client::Tip, signer::from_mnemonic};
use serde::de;
// use cw_orch::prelude::*;
// use cw_orch::interface;

#[test]
fn cvm_devnet_case() {
#[tokio::test]
async fn cvm_devnet_case() {
let mut centauri = App::default();
let mut _osmosis = App::default();
let cw_mantis_order_wasm = (ContractWrapper::new(
Expand Down Expand Up @@ -65,5 +70,73 @@ fn cvm_devnet_case() {

let sender = Addr::unchecked("juno16g2rahf5846rxzp3fwlswy08fz8ccuwk03k57y");

let solution = mantis_node::mantis::blackbox::solve(active_orders, signing_key, tip, cvm_glt, router);
let ACoin = |x: u128| Coin {
denom: "a".to_string(),
amount: x.into(),
};

let BCoin = |x : u128| Coin {
denom: "b".to_string(),
amount: x.into(),
};

let a_to_b = OrderItem {
owner: sender.clone(),
msg: OrderSubMsg {
wants: ACoin(100),
timeout: centauri.block_info().height+100,
convert: None,
min_fill: None,
virtual_given: None,

},
given: BCoin(100),
order_id: 1u128.into(),
};

let b_to_a = OrderItem {
owner: sender.clone(),
msg: OrderSubMsg {
wants: BCoin(1000),
timeout: centauri.block_info().height+100,
convert: None,
min_fill: None,
virtual_given: None,

},
given: ACoin(1000),
order_id: 2u128.into(),
};
let active_orders = vec![a_to_b, b_to_a];
let alice = from_mnemonic(
"document prefer nurse marriage flavor cheese west when knee drink sorry minimum thunder tilt cherry behave cute stove elder couch badge gown coral expire"
,
"m/44'/118'/0'/0/0",).unwrap();
let tip = Tip {
block: Height::default(),
account: cosmos_sdk_proto::cosmos::auth::v1beta1::BaseAccount{
address: alice.public_key().to_string(),
pub_key: Some(alice.public_key().to_any().unwrap()),
account_number: 1,
sequence: 1,
},
};
let router = "shortest_path";
let cvm_glt = Some(CvmGlt {
network_to_networks: todo!(),
assets: todo!(),
exchanges: todo!(),
networks: todo!(),
network_assets: todo!(),
asset_venue_items: todo!(),
});
let solution = mantis_node::mantis::blackbox::solve::<True>(active_orders, &alice, &tip, cvm_glt, router);
}

enum True{}

impl Get<bool> for True {
fn get() -> bool {
true
}
}

0 comments on commit 57cb25a

Please sign in to comment.