Skip to content

Commit

Permalink
nits
Browse files Browse the repository at this point in the history
  • Loading branch information
klkvr committed Apr 28, 2024
1 parent 099fd5a commit 3a0ce36
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
7 changes: 2 additions & 5 deletions crates/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use foundry_compilers::{
};
use inflector::Inflector;
use regex::Regex;
use revm_primitives::{fixed_bytes, FixedBytes, SpecId};
use revm_primitives::{FixedBytes, SpecId};
use semver::Version;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::{
Expand Down Expand Up @@ -451,10 +451,7 @@ impl Config {
pub const DEFAULT_SENDER: Address = address!("1804c8AB1F12E6bbf3894d4083f33e07309d1f38");

/// Default salt for create2 library deployments
///
/// cast keccak 'foundry create2'
pub const DEFAULT_CREATE2_LIBRARY_SALT: FixedBytes<32> =
fixed_bytes!("19bf59b7b67ae8edcbc6e53616080f61fa99285c061450ad601b0bc40c9adfc9");
pub const DEFAULT_CREATE2_LIBRARY_SALT: FixedBytes<32> = FixedBytes::<32>::ZERO;

/// Returns the current `Config`
///
Expand Down
29 changes: 29 additions & 0 deletions crates/forge/tests/cli/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1348,3 +1348,32 @@ forgetest_async!(can_deploy_library_create2, |prj, cmd| {
.assert_nonce_increment(&[(0, 1), (1, 1)])
.await;
});

// Asserts that running the same script twice only deploys library once when using different
// senders.
forgetest_async!(can_deploy_library_create2_different_sender, |prj, cmd| {
let (_api, handle) = spawn(NodeConfig::test()).await;

let mut tester = ScriptTester::new_broadcast(cmd, &handle.http_endpoint(), prj.root());

tester
.load_private_keys(&[0, 1])
.await
.add_sig("BroadcastTest", "deploy()")
.simulate(ScriptOutcome::OkSimulation)
.broadcast(ScriptOutcome::OkBroadcast)
.assert_nonce_increment(&[(0, 2), (1, 1)])
.await;

tester.clear();

// Run different script from the same contract (which requires the same library).
tester
.load_private_keys(&[2])
.await
.add_sig("BroadcastTest", "deployNoArgs()")
.simulate(ScriptOutcome::OkSimulation)
.broadcast(ScriptOutcome::OkBroadcast)
.assert_nonce_increment(&[(2, 2)])
.await;
});
4 changes: 2 additions & 2 deletions crates/script/src/runner.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::ScriptResult;
use crate::build::ScriptPredeployLibraries;
use alloy_primitives::{Address, Bytes, U256};
use alloy_primitives::{Address, Bytes, TxKind, U256};
use alloy_rpc_types::TransactionRequest;
use eyre::Result;
use foundry_cheatcodes::BroadcastableTransaction;
Expand Down Expand Up @@ -110,7 +110,7 @@ impl ScriptRunner {
from: Some(self.evm_opts.sender),
input: Some(calldata.into()).into(),
nonce: Some(sender_nonce + library_transactions.len() as u64),
to: Some(DEFAULT_CREATE2_DEPLOYER),
to: Some(TxKind::Call(DEFAULT_CREATE2_DEPLOYER)),
..Default::default()
},
});
Expand Down
2 changes: 1 addition & 1 deletion crates/test-utils/src/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use alloy_primitives::Address;
use alloy_provider::Provider;
use alloy_rpc_types::BlockId;
use eyre::Result;
use foundry_common::provider::alloy::{get_http_provider, RetryProvider};
use foundry_common::provider::{get_http_provider, RetryProvider};
use std::{
collections::BTreeMap,
fs,
Expand Down

0 comments on commit 3a0ce36

Please sign in to comment.