From 6b44708865a1426f4f096585a9018a0b529909a3 Mon Sep 17 00:00:00 2001 From: Christian Koopmann Date: Sat, 30 Jul 2022 17:41:45 +0800 Subject: [PATCH] Rustfmt --- cli/src/cmd/forge/script/broadcast.rs | 18 ++++++---- cli/src/cmd/forge/script/sequence.rs | 4 +-- cli/tests/it/script.rs | 47 +++++++++++++-------------- 3 files changed, 36 insertions(+), 33 deletions(-) diff --git a/cli/src/cmd/forge/script/broadcast.rs b/cli/src/cmd/forge/script/broadcast.rs index 5f942ab08a902..ccab6e44e66c2 100644 --- a/cli/src/cmd/forge/script/broadcast.rs +++ b/cli/src/cmd/forge/script/broadcast.rs @@ -208,16 +208,22 @@ impl ScriptArgs { if let Some(txs) = result.transactions { if script_config.evm_opts.fork_url.is_some() { let mut gas_filled_txs; - if self.skip_simulation { + if self.skip_simulation { println!("\nSKIPPING ON CHAIN SIMULATION."); gas_filled_txs = VecDeque::new(); for tx in txs { - gas_filled_txs.push_back(TransactionWithMetadata::from_typed_transaction(tx.clone())?); + gas_filled_txs.push_back(TransactionWithMetadata::from_typed_transaction( + tx.clone(), + )?); } - } - else { - gas_filled_txs = self - .execute_transactions(txs, &mut script_config, decoder, &verify.known_contracts) + } else { + gas_filled_txs = self + .execute_transactions( + txs, + &mut script_config, + decoder, + &verify.known_contracts, + ) .await .map_err(|_| { eyre::eyre!( diff --git a/cli/src/cmd/forge/script/sequence.rs b/cli/src/cmd/forge/script/sequence.rs index f80fc1943d7d9..0873598325a82 100644 --- a/cli/src/cmd/forge/script/sequence.rs +++ b/cli/src/cmd/forge/script/sequence.rs @@ -265,9 +265,7 @@ fn default_vec_of_strings() -> Option> { } impl TransactionWithMetadata { - pub fn from_typed_transaction( - transaction: TypedTransaction, - ) -> eyre::Result { + pub fn from_typed_transaction(transaction: TypedTransaction) -> eyre::Result { let metadata = Self { transaction, ..Default::default() }; Ok(metadata) } diff --git a/cli/tests/it/script.rs b/cli/tests/it/script.rs index 1de253333cedc..a096028595391 100644 --- a/cli/tests/it/script.rs +++ b/cli/tests/it/script.rs @@ -211,14 +211,15 @@ result: uint256 255 )); }); - -forgetest_async!(can_broadcast_script_skipping_simulation, |prj: TestProject, mut cmd: TestCommand| async move { - foundry_cli_test_utils::util::initialize(prj.root()); - let script = prj - .inner() - .add_source( - "Foo", - r#" +forgetest_async!( + can_broadcast_script_skipping_simulation, + |prj: TestProject, mut cmd: TestCommand| async move { + foundry_cli_test_utils::util::initialize(prj.root()); + let script = prj + .inner() + .add_source( + "Foo", + r#" // SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.10; import "forge-std/Script.sol"; @@ -232,13 +233,14 @@ contract Demo is Script { vm.stopBroadcast(); } }"#, - ) - .unwrap(); + ) + .unwrap(); - let (_api, handle) = spawn(NodeConfig::test()).await; - let target_contract = script.display().to_string() + ":Demo"; - let private_key = "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80".to_string(); - cmd.set_current_dir(prj.root()); + let (_api, handle) = spawn(NodeConfig::test()).await; + let target_contract = script.display().to_string() + ":Demo"; + let private_key = + "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80".to_string(); + cmd.set_current_dir(prj.root()); cmd.args([ "script", @@ -251,20 +253,17 @@ contract Demo is Script { "--broadcast", "--skip-simulation", "--private-key", - &private_key + &private_key, ]); - let output = cmd.stdout_lossy(); + let output = cmd.stdout_lossy(); - println!("{}", output.to_string()); + println!("{}", output.to_string()); - assert!(output.contains( - "Waiting for receipts" - )); - assert!(output.contains( - "SKIPPING ON CHAIN SIMULATION" - )); -}); + assert!(output.contains("Waiting for receipts")); + assert!(output.contains("SKIPPING ON CHAIN SIMULATION")); + } +); forgetest_async!(can_deploy_script_without_lib, |prj: TestProject, cmd: TestCommand| async move { let (_api, handle) = spawn(NodeConfig::test()).await;