Skip to content

Commit

Permalink
add rpc-url and rpc-block flags (#557)
Browse files Browse the repository at this point in the history
  • Loading branch information
anishnaik authored Feb 3, 2025
1 parent 305afb8 commit 2d1caa5
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions cmd/fuzz_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ func addFuzzFlags() error {

// Run slither and overwrite the cache
fuzzCmd.Flags().Bool("use-slither-force", false, "runs slither and overwrite the cached results")

// RPC url
fuzzCmd.Flags().String("rpc-url", "", "RPC URL to fetch contracts over")

// RPC block
fuzzCmd.Flags().Uint64("rpc-block", 0, "block number to use when fetching contracts over RPC")
return nil
}

Expand Down Expand Up @@ -177,11 +183,10 @@ func updateProjectConfigWithFuzzFlags(cmd *cobra.Command, projectConfig *config.

// Update stop on failed test feature
if cmd.Flags().Changed("fail-fast") {
failFast, err := cmd.Flags().GetBool("fail-fast")
projectConfig.Fuzzing.Testing.StopOnFailedTest, err = cmd.Flags().GetBool("fail-fast")
if err != nil {
return err
}
projectConfig.Fuzzing.Testing.StopOnFailedTest = failFast
}

// Update configuration to exploration mode
Expand All @@ -201,13 +206,10 @@ func updateProjectConfigWithFuzzFlags(cmd *cobra.Command, projectConfig *config.

// Update configuration to run slither while using current cache
if cmd.Flags().Changed("use-slither") {
useSlither, err := cmd.Flags().GetBool("use-slither")
projectConfig.Slither.UseSlither, err = cmd.Flags().GetBool("use-slither")
if err != nil {
return err
}
if useSlither {
projectConfig.Slither.UseSlither = true
}
}

// Update configuration to run slither and overwrite the current cache
Expand All @@ -222,5 +224,21 @@ func updateProjectConfigWithFuzzFlags(cmd *cobra.Command, projectConfig *config.
}
}

// Update RPC url
if cmd.Flags().Changed("rpc-url") {
projectConfig.Fuzzing.TestChainConfig.ForkConfig.RpcUrl, err = cmd.Flags().GetString("rpc-url")
if err != nil {
return err
}
}

// Update RPC block
if cmd.Flags().Changed("rpc-block") {
projectConfig.Fuzzing.TestChainConfig.ForkConfig.RpcBlock, err = cmd.Flags().GetUint64("rpc-block")
if err != nil {
return err
}
}

return nil
}

0 comments on commit 2d1caa5

Please sign in to comment.