From adaba4edc76f573c17ab3cf6867929adb7dbdbb6 Mon Sep 17 00:00:00 2001 From: dzmitry-lahoda Date: Sat, 20 Apr 2024 00:36:06 +0100 Subject: [PATCH] fixing random --- mantis/node/src/bin/mantis.rs | 42 +++++++++++++------------ mantis/node/src/mantis/cosmos/client.rs | 4 +-- mantis/node/src/mantis/simulate.rs | 2 +- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/mantis/node/src/bin/mantis.rs b/mantis/node/src/bin/mantis.rs index 69f3b5c..ec36fc1 100644 --- a/mantis/node/src/bin/mantis.rs +++ b/mantis/node/src/bin/mantis.rs @@ -141,26 +141,28 @@ async fn simulate_orders(simulate_args: &SimulateArgs) { let tip = get_latest_block_and_account_by_key(&args.rpc_centauri, &args.grpc_centauri, &signer).await; - let pair = simulate_args - .coins - .choose(&mut rand::thread_rng()) - .expect("some"); - let rpc = CosmosChainInfo { - rpc: args.rpc_centauri.clone(), - chain_id: args.main_chain_id.clone(), - }; - simulate::simulate_order( - &mut write_client, - &mut cosmos_query_client, - args.order_contract.clone(), - pair, - &signer, - &rpc, - &tip, - gas, - simulate_args.random_parts, - ) - .await; + assert!(simulate_args.coins.len() > 0); + let mut coinpairs = simulate_args.coins.clone(); + coinpairs.shuffle(&mut rand::thread_rng()); + + for coin_pair in coinpairs { + let rpc = CosmosChainInfo { + rpc: args.rpc_centauri.clone(), + chain_id: args.main_chain_id.clone(), + }; + simulate::simulate_order( + &mut write_client, + &mut cosmos_query_client, + args.order_contract.clone(), + &coin_pair, + &signer, + &rpc, + &tip, + gas, + simulate_args.random_parts, + ) + .await; + } } enum CoinToss {} diff --git a/mantis/node/src/mantis/cosmos/client.rs b/mantis/node/src/mantis/cosmos/client.rs index 737caeb..04c1acf 100644 --- a/mantis/node/src/mantis/cosmos/client.rs +++ b/mantis/node/src/mantis/cosmos/client.rs @@ -139,7 +139,7 @@ pub async fn sign_and_tx_tendermint( .broadcast_commit(&rpc_client) .await .expect("broadcasted"); - println!("result: {:?}", result); + log::error!("result: {:?}", result); assert!(!result.check_tx.code.is_err(), "err"); assert!(!result.tx_result.code.is_err(), "err"); result @@ -166,7 +166,7 @@ pub async fn tx_broadcast_single_signed_msg( &chain::Id::try_from(rpc.chain_id.as_ref()).expect("chain_id"), tip.account.account_number, ) - .unwrap(); + .expect("sign works"); sign_and_tx_tendermint(&rpc.rpc, sign_doc, signing_key).await } diff --git a/mantis/node/src/mantis/simulate.rs b/mantis/node/src/mantis/simulate.rs index c3fbde2..f3e6ba3 100644 --- a/mantis/node/src/mantis/simulate.rs +++ b/mantis/node/src/mantis/simulate.rs @@ -81,7 +81,7 @@ pub async fn simulate_order( log::info!("========================= simulate_order ========================="); let (msg, fund) = randomize_order(&coins_pair, tip.block, random_parts); - println!("msg: {:?}", msg); + log::info!("msg: {:?}", msg); let auth_info = simulate_and_set_fee(signing_key, &tip.account, gas).await;