diff --git a/Cargo.lock b/Cargo.lock index 59fb7ea9..2bde2511 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2310,9 +2310,9 @@ checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -2930,9 +2930,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -4038,9 +4038,9 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "petgraph" @@ -5013,6 +5013,7 @@ dependencies = [ "sha3", "tokio", "tracing", + "url", ] [[package]] @@ -7392,9 +7393,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", "idna", diff --git a/chains/arbitrum/testing/rosetta-testing-arbitrum/Cargo.toml b/chains/arbitrum/testing/rosetta-testing-arbitrum/Cargo.toml index a1251762..2cf21bab 100644 --- a/chains/arbitrum/testing/rosetta-testing-arbitrum/Cargo.toml +++ b/chains/arbitrum/testing/rosetta-testing-arbitrum/Cargo.toml @@ -20,4 +20,5 @@ rosetta-server-arbitrum.workspace = true [dev-dependencies] ethers-solc = "2.0" -sha3 = "0.10" \ No newline at end of file +sha3 = "0.10" +url = "2.5.0" \ No newline at end of file diff --git a/chains/arbitrum/testing/rosetta-testing-arbitrum/src/lib.rs b/chains/arbitrum/testing/rosetta-testing-arbitrum/src/lib.rs index 4da6a061..7cda8d60 100644 --- a/chains/arbitrum/testing/rosetta-testing-arbitrum/src/lib.rs +++ b/chains/arbitrum/testing/rosetta-testing-arbitrum/src/lib.rs @@ -52,7 +52,7 @@ impl ArbitrumEnv { // You can start your Bash script here //when running the test , get the folder path, recive as perms - let script_path = "/home/daino/nitro-testnode/test-node.bash"; // Replace with the actual path to binary + let script_path = "../nitro-testnode/test-node.bash"; // Replace with the actual path to binary let output = Command::new(script_path) .arg("--detach") .output() @@ -96,16 +96,25 @@ impl ArbitrumEnv { #[cfg(test)] mod tests { - use ethers::utils::hex; + use ethers::{ + providers::{Http, Middleware, Provider}, + signers::{LocalWallet, Signer}, + types::{ + transaction::eip2718::TypedTransaction, Bytes, TransactionRequest, H160, U256, U64, + }, + utils::hex, + }; use ethers_solc::{artifacts::Source, CompilerInput, EvmVersion, Solc}; use rosetta_client::Wallet; use rosetta_core::{types::PartialBlockIdentifier, BlockchainClient}; use rosetta_server_arbitrum::ArbitrumClient; use sha3::Digest; - use std::{collections::BTreeMap, path::Path}; + use std::{collections::BTreeMap, path::Path, str::FromStr, thread, time::Duration}; + use url::Url; use super::*; + //Test for start the arbitrum default node (nitro-testnode) #[tokio::test] async fn start_new() { match ArbitrumEnv::new().await { @@ -132,6 +141,49 @@ mod tests { assert!(result.is_err(), "Cleanup should have failed: {:?}", result); } + //must run this test before running below tests. + #[tokio::test] + pub async fn for_incress_blocknumber() -> Result<()> { + let rpc_url_str = "http://localhost:8547"; + let rpc_url = Url::parse(rpc_url_str).expect("Invalid URL"); + let http = Http::new(rpc_url); + let provider = Provider::::new(http); + let chain_id = provider.get_chainid().await?; + let private_key = "0xb6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659"; + let result = ArbitrumClient::new("dev", "ws://127.0.0.1:8548").await; + assert!(result.is_ok(), "Error creating ArbitrumClient"); + let wallet = private_key.parse::()?.with_chain_id(chain_id.as_u64()); + loop { + let nonce = provider + .get_transaction_count( + ethers::types::NameOrAddress::Address( + H160::from_str("0x3f1eae7d46d88f08fc2f8ed27fcb2ab183eb2d0e").unwrap(), + ), + None, + ) + .await + .unwrap(); //public key of faucet account + // Create a transaction request + let transaction_request = TransactionRequest { + from: None, + to: Some(ethers::types::NameOrAddress::Address( + H160::from_str("0xc109c36fd5d730d7f9a14dB2597B2d9eDd991719").unwrap(), + )), + value: Some(U256::from(1000000000)), // Specify the amount you want to send + gas: Some(U256::from(210000)), // Adjust gas values accordingly + gas_price: Some(U256::from(500000000)), // Adjust gas price accordingly + nonce: Some(U256::from(nonce)), // Nonce will be automatically determined + data: None, + chain_id: Some(U64::from(412346)), // Replace with your desired chain ID + }; + let tx: TypedTransaction = transaction_request.into(); + let signature = wallet.sign_transaction(&tx).await.unwrap(); + let tx: Bytes = tx.rlp_signed(&signature); + let _ = provider.send_raw_transaction(tx).await; + thread::sleep(Duration::from_secs(1)); + } + } + #[tokio::test] async fn network_status() { match ArbitrumClient::new("dev", "ws://127.0.0.1:8548").await { diff --git a/chains/ethereum/server/src/client.rs b/chains/ethereum/server/src/client.rs index d38abd29..79dc15fd 100644 --- a/chains/ethereum/server/src/client.rs +++ b/chains/ethereum/server/src/client.rs @@ -296,16 +296,6 @@ where let block_reward_transaction = crate::utils::block_reward_transaction(&self.client, self.config(), &block).await?; transactions.push(block_reward_transaction); - for transaction in &block.transactions { - let transaction = crate::utils::get_transaction( - &self.client, - self.config(), - block.clone(), - transaction, - ) - .await?; - transactions.push(transaction); - } Ok(Block { block_identifier: BlockIdentifier { index: block_number.as_u64(),