From 4bab45711425db25b217347c0b522f03798280b5 Mon Sep 17 00:00:00 2001 From: Omar Abdulla Date: Fri, 11 Jul 2025 17:18:42 +0300 Subject: [PATCH 1/2] Added `--dev` to `substrate-node` arguments. This commit adds the `--dev` argument to the `substrate-node` to allow the chain to keep advancing as time goes own. We have found that if this option is not added then the chain won't advance forward. --- Cargo.lock | 1 + crates/node/Cargo.toml | 1 + crates/node/src/kitchensink.rs | 35 +++++++++++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 0cff4c8..c125fee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4003,6 +4003,7 @@ dependencies = [ "sp-core", "sp-runtime", "temp-dir", + "tokio", "tracing", ] diff --git a/crates/node/Cargo.toml b/crates/node/Cargo.toml index 1b54fc9..8fd6150 100644 --- a/crates/node/Cargo.toml +++ b/crates/node/Cargo.toml @@ -24,3 +24,4 @@ sp-runtime = { workspace = true } [dev-dependencies] temp-dir = { workspace = true } +tokio = { workspace = true } diff --git a/crates/node/src/kitchensink.rs b/crates/node/src/kitchensink.rs index a36a6d6..f93d539 100644 --- a/crates/node/src/kitchensink.rs +++ b/crates/node/src/kitchensink.rs @@ -128,6 +128,7 @@ impl KitchensinkNode { // Start Substrate node let mut substrate_process = Command::new(&self.substrate_binary) + .arg("--dev") .arg("--chain") .arg(chainspec_path) .arg("--base-path") @@ -808,13 +809,14 @@ impl BlockHeader for KitchenSinkHeader { #[cfg(test)] mod tests { + use alloy::rpc::types::TransactionRequest; use revive_dt_config::Arguments; use std::path::PathBuf; use temp_dir::TempDir; use std::fs; - use super::KitchensinkNode; + use super::*; use crate::{GENESIS_JSON, Node}; fn test_config() -> (Arguments, TempDir) { @@ -829,6 +831,37 @@ mod tests { (config, temp_dir) } + #[tokio::test] + async fn node_mines_simple_transfer_transaction_and_returns_receipt() { + // Arrange + let (args, _temp_dir) = test_config(); + let mut node = KitchensinkNode::new(&args); + node.spawn(GENESIS_JSON.to_owned()) + .expect("Failed to spawn the node"); + + let provider = ProviderBuilder::new() + .network::() + .wallet(args.wallet()) + .connect(&node.rpc_url) + .await + .expect("Failed to create provider"); + + let account_address = args.wallet().default_signer().address(); + let transaction = TransactionRequest::default() + .to(account_address) + .value(U256::from(100_000_000_000_000u128)); + + // Act + let receipt = provider.send_transaction(transaction).await; + + // Assert + let _ = receipt + .expect("Failed to send the transfer transaction") + .get_receipt() + .await + .expect("Failed to get the receipt for the transfer"); + } + #[test] fn test_init_generates_chainspec_with_balances() { let genesis_content = r#" From 7664e9735e44809eb8d604acc01c89db480647fd Mon Sep 17 00:00:00 2001 From: Omar Abdulla Date: Fri, 11 Jul 2025 17:20:36 +0300 Subject: [PATCH 2/2] fix clippy warning --- crates/node/src/kitchensink.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/node/src/kitchensink.rs b/crates/node/src/kitchensink.rs index f93d539..e621164 100644 --- a/crates/node/src/kitchensink.rs +++ b/crates/node/src/kitchensink.rs @@ -583,7 +583,7 @@ impl TransactionBuilder for ::Transacti Ok(unsigned_tx) => Ok(unsigned_tx), Err(UnbuiltTransactionError { request, error }) => { Err(UnbuiltTransactionError:: { - request: request, + request, error: match error { TransactionBuilderError::InvalidTransactionRequest(tx_type, items) => { TransactionBuilderError::InvalidTransactionRequest(tx_type, items)