diff --git a/crates/telos/node/tests/live_test_runner.rs b/crates/telos/node/tests/live_test_runner.rs index 132429c46ec81..39fd3e776ac6c 100644 --- a/crates/telos/node/tests/live_test_runner.rs +++ b/crates/telos/node/tests/live_test_runner.rs @@ -4,7 +4,7 @@ use alloy_provider::network::EthereumWallet; use alloy_provider::{Provider, ProviderBuilder, ReqwestProvider}; use alloy_provider::fillers::{FillProvider, JoinFill, WalletFiller}; use alloy_rpc_client::ClientBuilder; -use alloy_rpc_types::TransactionRequest; +use alloy_rpc_types::{BlockNumberOrTag, TransactionRequest}; use alloy_signer_local::PrivateKeySigner; use alloy_sol_types::private::primitives::TxKind::{Call, Create}; use alloy_sol_types::{sol, SolEvent, SolValue}; @@ -70,12 +70,11 @@ pub async fn test_blocknum_onchain(url: &str, private_key: &str) { let provider = ProviderBuilder::new().wallet(wallet.clone()).on_http(Url::from_str(url).unwrap()); - info!("Deploying contract using address {address}"); let nonce = provider.get_transaction_count(address).await.unwrap(); let chain_id = provider.get_chain_id().await.unwrap(); - let gas_price: u128 = 600 * (GWEI_TO_WEI as u128); + let gas_price = provider.get_gas_price().await.unwrap(); let legacy_tx = TxLegacy { chain_id: Some(chain_id), @@ -108,27 +107,6 @@ pub async fn test_blocknum_onchain(url: &str, private_key: &str) { let contract_address = receipt.contract_address().unwrap(); let block_num_checker = BlockNumChecker::new(contract_address, provider.clone()); - // let legacy_tx = TxLegacy { - // chain_id: Some(chain_id), - // nonce: provider.get_transaction_count(address).await.unwrap(), - // gas_price: gas_price.into(), - // gas_limit: 20_000_000, - // to: Call(contract_address), - // value: U256::ZERO, - // input: block_num_checker.logBlockNum().calldata().clone(), - // }; - // - // let legacy_tx_request = TransactionRequest { - // from: Some(address), - // to: Some(legacy_tx.to), - // gas: Some(legacy_tx.gas_limit as u128), - // gas_price: Some(legacy_tx.gas_price), - // value: Some(legacy_tx.value), - // input: TransactionInput::from(legacy_tx.input), - // nonce: Some(legacy_tx.nonce), - // chain_id: legacy_tx.chain_id, - // ..Default::default() - // }; let legacy_tx_request = TransactionRequest::default() .with_from(address) @@ -151,4 +129,12 @@ pub async fn test_blocknum_onchain(url: &str, private_key: &str) { let first_log = logs[0].clone().inner; let block_num_event = BlockNumChecker::BlockNumber::decode_log(&first_log, true).unwrap(); assert_eq!(U256::from(rpc_block_num), block_num_event.number); + info!("Block numbers match inside transaction event"); + + let block_num_latest = block_num_checker.getBlockNum().call().await.unwrap(); + assert!(block_num_latest._0 > U256::from(rpc_block_num), "Latest block number via call to getBlockNum is not greater than the block number in the previous log event"); + + let block_num_five_back = block_num_checker.getBlockNum().call().block(BlockId::number(rpc_block_num - 5)).await.unwrap(); + assert!(block_num_five_back._0 == U256::from(rpc_block_num - 5), "Block number 5 blocks back via historical eth_call is not correct"); + } \ No newline at end of file