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

Adding support for authorization header #187

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

praetoriansentry
Copy link
Contributor

@praetoriansentry praetoriansentry commented Jan 9, 2024

Description

Adding a flag to add an authorization bearer to http requests.

Tests

Ensure polycli monitor is working:

./out/polycli monitor -H "X-goog-api-key: $apikey" --rpc-url https://json-rpc.do9ic5iuox53t826lv7lqek2p.blockchainnodeengine.com

Ensure loadtest command works with the custom header as well:

./out/polycli loadtest --mode rpc -H "X-goog-api-key: $apikey" --rpc-url https://json-rpc.do9ic5iuox53t826lv7lqek2p.blockchainnodeengine.com --verbosity 700 --requests 100 --concurrency 10 --rate-limit 50

@@ -260,6 +270,7 @@ inscription - sending inscription transactions`)
ltp.ContractCallFunctionArgs = LoadtestCmd.Flags().StringSlice("function-arg", []string{}, `The arguments that will be passed to a contract function call. This must be paired up with "--mode contract-call" and "--contract-address". Args can be passed multiple times: "--function-arg 'test' --function-arg 999" or comma separated values "--function-arg "test",9". The ordering of the arguments must match the ordering of the function parameters.`)
ltp.ContractCallPayable = LoadtestCmd.Flags().Bool("contract-call-payable", false, "Use this flag if the function is payable, the value amount passed will be from --eth-amount. This must be paired up with --mode contract-call and --contract-address")
ltp.InscriptionContent = LoadtestCmd.Flags().String("inscription-content", `data:,{"p":"erc-20","op":"mint","tick":"TEST","amt":"1"}`, "The inscription content that will be encoded as calldata. This must be paired up with --mode inscription")
ltp.RawHTTPHeaders = LoadtestCmd.Flags().StringSliceP("header", "H", nil, "Header to be added to each HTTP request. E.g. \"X-First-Name: Joe\"")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just for clarity: if user needs to pass multiple headers, what is the recommended / valid format? pass multiple -H flags to polycli cmd, or, single -H with comma separated set of headers?

var rpc *ethrpc.Client
var err error
if inputLoadTestParams.ParsedHTTPHeaders == nil {
log.Trace().Msg("No HeadersAdding custom headers")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, spacing: No Headers. Adding custom headers.

@@ -30,6 +30,7 @@ If you're experiencing missing blocks, try adjusting the `--batch-size` and `--i
```bash
-b, --batch-size string Number of requests per batch (default "auto")
-c, --cache-limit int Number of cached blocks for the LRU block data structure (Min 100) (default 200)
-H, --header strings Header to be added to each HTTP request. E.g. "X-First-Name: Joe"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in same vein, consider adding bit extra clarity for users needing to pass multiple headers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants