-
Notifications
You must be signed in to change notification settings - Fork 33
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
chore: transform url
arg into a flag
#138
Conversation
If we end up merging this PR, we should make sure we update the |
url
arg into a flag
Implemented in the PR ✅ |
func validateUrl(input string) (*url.URL, error) { | ||
url, err := url.Parse(input) | ||
if err != nil { | ||
log.Error().Err(err).Msg("Unable to parse url input error") | ||
return nil, err | ||
} | ||
|
||
if url.Scheme == "" { | ||
return nil, errors.New("the scheme has not been specified") | ||
} | ||
switch url.Scheme { | ||
case "http", "https", "ws", "wss": | ||
return url, nil | ||
default: | ||
return nil, fmt.Errorf("the scheme %s is not supported", url.Scheme) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice simplification here
@@ -14,7 +14,7 @@ | |||
Run a generic load test against an Eth/EVM style JSON-RPC endpoint. | |||
|
|||
```bash | |||
polycli loadtest url [flags] | |||
polycli loadtest [flags] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: potentially add comment here that rpc-url default is localhost
@@ -98,6 +98,7 @@ The command also inherits flags from parent commands. | |||
--private-key string The hex encoded private key that we'll use to send transactions (default "42b6e34dc21598a807dc19d7784c71b2a7a01f6480dc6f58258f78e539f1a1fa") | |||
--rate-limit float An overall limit to the number of requests per second. Give a number less than zero to remove this limit all together (default 4) | |||
-n, --requests int Number of requests to perform for the benchmarking session. The default is to just perform a single request which usually leads to non-representative benchmarking results. (default 1) | |||
-r, --rpc-url string The RPC endpoint url (default "http://localhost:8545") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm, this is perfect
@@ -37,10 +37,10 @@ geth-loadtest: build fund ## Run loadtest against an EVM/Geth chain. | |||
sleep 5 | |||
$(BUILD_DIR)/$(BIN_NAME) loadtest \ | |||
--verbosity 700 \ | |||
--rpc-url http://127.0.0.1:$(PORT) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: potentially make host configurable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah we could, this is just a handy command to trigger load test in ci :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great, couple nits but not a blocker
Description
🚨 Breaking change 🚨
It's just a suggestion, no problem if we don't merge it :)
This pull request enhances the
loadtest
,loadtest uniswapv3
,monitor
andrpcfuzz
commands by transforming theurl
argument into a more flexible and user-friendly flag calledrpc-url
. With this update, users can now set the URL as a flag, offering greater control and simplicity in command usage, following the standards employed by other tools such as cast.By default, the
rpc-url
flag is set tohttp://localhost:8545
.It's now possible to run
polycli loadtest
. If you were specifying the url as an argument previously, you can switch frompolycli loadtest <url>
topolycli loadtest --rpc-url <url>
orpolycli loadtest -r <url>
.Other
cobra.Command
to a separate filecmd.go
orapp.go
for each cmd.checkFlags
and logic responsible for running the cmd in a specific func.util
, to be reused in other commands also.For example, here's how the
monitor
cmd looks now.Jira / Linear Tickets
Testing
x