From d30a4b02dd6b71cff2150b1f0f00d1da51b1b9d4 Mon Sep 17 00:00:00 2001 From: pgherveou Date: Wed, 13 Nov 2024 22:50:54 +0100 Subject: [PATCH] simplify test --- substrate/frame/revive/rpc/src/example.rs | 2 +- substrate/frame/revive/rpc/src/tests.rs | 19 ++++--------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/substrate/frame/revive/rpc/src/example.rs b/substrate/frame/revive/rpc/src/example.rs index 0be18d7a4af8..20f00465b146 100644 --- a/substrate/frame/revive/rpc/src/example.rs +++ b/substrate/frame/revive/rpc/src/example.rs @@ -125,7 +125,7 @@ impl TransactionBuilder { None, ) .await - .with_context(|| "Failed to fetch gas estimate")?; + .with_context(|| "eth_call failed")?; Ok(result.0) } diff --git a/substrate/frame/revive/rpc/src/tests.rs b/substrate/frame/revive/rpc/src/tests.rs index b9ec7700f520..9797e2652658 100644 --- a/substrate/frame/revive/rpc/src/tests.rs +++ b/substrate/frame/revive/rpc/src/tests.rs @@ -299,14 +299,8 @@ async fn native_evm_ratio_works() -> anyhow::Result<()> { .send_and_wait_for_receipt(&client) .await?; - let get_deposit = contract.function("getDeposit")?; - let output = TransactionBuilder::default() - .to(contract_address) - .input(get_deposit.encode_input(&[])?.to_vec()) - .eth_call(&client) - .await?; - let output = get_deposit.decode_output(&output)?; - assert_eq!(output[0], Token::Uint(value.into())); + let contract_value = client.get_balance(ethan.address(), BlockTag::Latest.into()).await?; + assert_eq!(contract_value, value.into()); let withdraw_value = 1_000_000_000_000_000_000u128; // 1 eth TransactionBuilder::default() @@ -320,13 +314,8 @@ async fn native_evm_ratio_works() -> anyhow::Result<()> { .send_and_wait_for_receipt(&client) .await?; - let output = TransactionBuilder::default() - .to(contract_address) - .input(get_deposit.encode_input(&[])?.to_vec()) - .eth_call(&client) - .await?; - let output = get_deposit.decode_output(&output)?; - assert_eq!(output[0], Token::Uint((value - withdraw_value).into())); + let contract_value = client.get_balance(ethan.address(), BlockTag::Latest.into()).await?; + assert_eq!(contract_value, (value - withdraw_value).into()); Ok(()) }