File tree Expand file tree Collapse file tree 2 files changed +38
-5
lines changed
Expand file tree Collapse file tree 2 files changed +38
-5
lines changed Original file line number Diff line number Diff line change @@ -3170,6 +3170,40 @@ Error: script failed: call to non-contract address [..]
31703170"# ] ] ) ;
31713171} ) ;
31723172
3173+ // Test that --verify without --broadcast fails with a clear error message
3174+ forgetest ! ( verify_without_broadcast_fails, |prj, cmd| {
3175+ let script = prj. add_source(
3176+ "Counter" ,
3177+ r#"
3178+ import "forge-std/Script.sol";
3179+
3180+ contract CounterScript is Script {
3181+ function run() external {
3182+ // Simple script that does nothing
3183+ }
3184+ }
3185+ "# ,
3186+ ) ;
3187+
3188+ cmd. args( [
3189+ "script" ,
3190+ script. to_str( ) . unwrap( ) ,
3191+ "--verify" ,
3192+ "--rpc-url" ,
3193+ "https://sepolia.infura.io/v3/test" ,
3194+ ] )
3195+ . assert_failure( )
3196+ . stderr_eq( str ![ [ r#"
3197+ error: the following required arguments were not provided:
3198+ --broadcast
3199+
3200+ Usage: [..] script --broadcast --verify --fork-url <URL> <PATH> [ARGS]...
3201+
3202+ For more information, try '--help'.
3203+
3204+ "# ] ] ) ;
3205+ } ) ;
3206+
31733207// <https://github.com/foundry-rs/foundry/issues/11855>
31743208forgetest_async ! ( can_broadcast_from_deploy_code_cheatcode, |prj, cmd| {
31753209 foundry_test_utils:: util:: initialize( prj. root( ) ) ;
Original file line number Diff line number Diff line change @@ -190,7 +190,7 @@ pub struct ScriptArgs {
190190 pub etherscan_api_key : Option < String > ,
191191
192192 /// Verifies all the contracts found in the receipts of a script, if any.
193- #[ arg( long) ]
193+ #[ arg( long, requires = "broadcast" ) ]
194194 pub verify : bool ,
195195
196196 /// Gas price for legacy transactions, or max fee per gas for EIP1559 transactions, either
@@ -250,8 +250,7 @@ impl ScriptArgs {
250250
251251 // Move from `CompiledState` to `BundledState` either by resuming or executing and
252252 // simulating script.
253- let bundled = if compiled. args . resume || ( compiled. args . verify && !compiled. args . broadcast )
254- {
253+ let bundled = if compiled. args . resume {
255254 compiled. resume ( ) . await ?
256255 } else {
257256 // Drive state machine to point at which we have everything needed for simulation.
@@ -489,9 +488,9 @@ impl ScriptArgs {
489488 Ok ( ( ) )
490489 }
491490
492- /// We only broadcast transactions if --broadcast or --resume was passed.
491+ /// We only broadcast transactions if --broadcast, --resume, or --verify was passed.
493492 fn should_broadcast ( & self ) -> bool {
494- self . broadcast || self . resume
493+ self . broadcast || self . resume || self . verify
495494 }
496495}
497496
You can’t perform that action at this time.
0 commit comments