Skip to content

Commit

Permalink
Rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ckoopmann committed Jul 30, 2022
1 parent ced6762 commit 6b44708
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 33 deletions.
18 changes: 12 additions & 6 deletions cli/src/cmd/forge/script/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
4 changes: 1 addition & 3 deletions cli/src/cmd/forge/script/sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,7 @@ fn default_vec_of_strings() -> Option<Vec<String>> {
}

impl TransactionWithMetadata {
pub fn from_typed_transaction(
transaction: TypedTransaction,
) -> eyre::Result<Self> {
pub fn from_typed_transaction(transaction: TypedTransaction) -> eyre::Result<Self> {
let metadata = Self { transaction, ..Default::default() };
Ok(metadata)
}
Expand Down
47 changes: 23 additions & 24 deletions cli/tests/it/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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",
Expand All @@ -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;
Expand Down

0 comments on commit 6b44708

Please sign in to comment.