Skip to content

Commit

Permalink
simplify test
Browse files Browse the repository at this point in the history
  • Loading branch information
pgherveou committed Nov 13, 2024
1 parent d4364fd commit d30a4b0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
2 changes: 1 addition & 1 deletion substrate/frame/revive/rpc/src/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl TransactionBuilder {
None,
)
.await
.with_context(|| "Failed to fetch gas estimate")?;
.with_context(|| "eth_call failed")?;
Ok(result.0)
}

Expand Down
19 changes: 4 additions & 15 deletions substrate/frame/revive/rpc/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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(())
}

0 comments on commit d30a4b0

Please sign in to comment.