Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add CLI commands for RPC URL and block number #1194

Merged
merged 5 commits into from
Feb 29, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Data.Set qualified as Set
import Data.Text (Text)
import Data.Time.Clock.System (getSystemTime, systemSeconds)
import Data.Version (showVersion)
import Data.Word (Word8, Word16)
import Data.Word (Word8, Word16, Word64)
import Main.Utf8 (withUtf8)
import Options.Applicative
import Paths_echidna (version)
Expand Down Expand Up @@ -127,6 +127,8 @@ data Options = Options
, cliAllContracts :: Bool
, cliTimeout :: Maybe Int
, cliTestLimit :: Maybe Int
, cliRpcBlock :: Maybe Word64
, cliRpcUrl :: Maybe Text
, cliShrinkLimit :: Maybe Int
, cliSeqLen :: Maybe Int
, cliContractAddr :: Maybe Addr
Expand Down Expand Up @@ -174,6 +176,12 @@ options = Options
<*> optional (option auto $ long "test-limit"
<> metavar "INTEGER"
<> help ("Number of sequences of transactions to generate during testing. Default is " ++ show defaultTestLimit))
<*> optional (option auto $ long "rpc-block"
<> metavar "BLOCK"
<> help "Block number to use when fetching over RPC.")
<*> optional (option str $ long "rpc-url"
<> metavar "URL"
<> help "RPC URL to fetch contracts over.")
<*> optional (option auto $ long "shrink-limit"
<> metavar "INTEGER"
<> help ("Number of tries to attempt to shrink a failing sequence of transactions. Default is " ++ show defaultShrinkLimit))
Expand Down Expand Up @@ -206,8 +214,8 @@ versionOption = infoOption

overrideConfig :: EConfig -> Options -> IO EConfig
overrideConfig config Options{..} = do
rpcUrl <- Onchain.rpcUrlEnv
rpcBlock <- Onchain.rpcBlockEnv
rpcUrl <- pure cliRpcUrl <|> Onchain.rpcUrlEnv
rpcBlock <- pure cliRpcBlock <|> Onchain.rpcBlockEnv
pure $
config { solConf = overrideSolConf config.solConf
, campaignConf = overrideCampaignConf config.campaignConf
Expand Down
Loading