From ccadbdc7538d5787c5c3cf04da29f40f49020c31 Mon Sep 17 00:00:00 2001 From: Dmitry Novikov Date: Wed, 16 Oct 2024 20:03:41 +0400 Subject: [PATCH] uncomment test; it works --- ethexe/cli/src/tests.rs | 63 +++++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 27 deletions(-) diff --git a/ethexe/cli/src/tests.rs b/ethexe/cli/src/tests.rs index 6d3bdba192d..a15a9f1fda9 100644 --- a/ethexe/cli/src/tests.rs +++ b/ethexe/cli/src/tests.rs @@ -378,7 +378,12 @@ async fn incoming_transfers() { env.transfer_wvara(ping_id, VALUE_SENT).await; - listener.apply_until_block_event(|e| Ok(matches!(e, BlockEvent::Router(RouterEvent::BlockCommitted { .. })).then_some(()))).await.unwrap(); + listener + .apply_until_block_event(|e| { + Ok(matches!(e, BlockEvent::Router(RouterEvent::BlockCommitted { .. })).then_some(())) + }) + .await + .unwrap(); let on_eth_balance = wvara .query() @@ -391,31 +396,32 @@ async fn incoming_transfers() { let local_balance = node.db.read_state(state_hash).unwrap().balance; assert_eq!(local_balance, VALUE_SENT); - // TODO (breathx): `value_to_receive` param of transition. - // let res = env - // .send_message(ping_id, b"PING", VALUE_SENT) - // .await - // .unwrap() - // .wait_for() - // .await - // .unwrap(); - - // assert_eq!( - // res.reply_code, - // ReplyCode::Success(SuccessReplyReason::Manual) - // ); - // assert_eq!(res.reply_value, 0); - - // let on_eth_balance = wvara - // .query() - // .balance_of(ping.address().0.into()) - // .await - // .unwrap(); - // assert_eq!(on_eth_balance, 2 * VALUE_SENT); - - // let state_hash = ping.query().state_hash().await.unwrap(); - // let local_balance = node.db.read_state(state_hash).unwrap().balance; - // assert_eq!(local_balance, 2 * VALUE_SENT); + env.approve_wvara(ping_id).await; + + let res = env + .send_message(ping_id, b"PING", VALUE_SENT) + .await + .unwrap() + .wait_for() + .await + .unwrap(); + + assert_eq!( + res.reply_code, + ReplyCode::Success(SuccessReplyReason::Manual) + ); + assert_eq!(res.reply_value, 0); + + let on_eth_balance = wvara + .query() + .balance_of(ping.address().0.into()) + .await + .unwrap(); + assert_eq!(on_eth_balance, 2 * VALUE_SENT); + + let state_hash = ping.query().state_hash().await.unwrap(); + let local_balance = node.db.read_state(state_hash).unwrap().balance; + assert_eq!(local_balance, 2 * VALUE_SENT); } #[tokio::test(flavor = "multi_thread")] @@ -1035,7 +1041,10 @@ mod utils { let program_address = ethexe_signer::Address::try_from(program_id).unwrap(); let wvara = self.ethereum.router().wvara(); - wvara.transfer(program_address.0.into(), value).await.unwrap(); + wvara + .transfer(program_address.0.into(), value) + .await + .unwrap(); } pub fn events_publisher(&self) -> EventsPublisher {