Skip to content

Latest commit

 

History

History
138 lines (111 loc) · 4.62 KB

polycli_rpcfuzz.md

File metadata and controls

138 lines (111 loc) · 4.62 KB

polycli rpcfuzz

Auto-generated documentation.

Table of Contents

Description

Continually run a variety of RPC calls and fuzzers.

polycli rpcfuzz [flags]

Usage

This command will run a series of RPC calls against a given JSON RPC endpoint. The idea is to be able to check for various features and function to see if the RPC generally conforms to typical geth standards for the RPC.

Some setup might be needed depending on how you're testing. We'll demonstrate with geth.

In order to quickly test this, you can run geth in dev mode.

$ geth \
    --dev \
    --dev.period 5 \
    --http \
    --http.addr localhost \
    --http.port 8545 \
    --http.api 'admin,debug,web3,eth,txpool,personal,miner,net' \
    --verbosity 5 \
    --rpc.gascap 50000000 \
    --rpc.txfeecap 0 \
    --miner.gaslimit 10 \
    --miner.gasprice 1 \
    --gpo.blocks 1 \
    --gpo.percentile 1 \
    --gpo.maxprice 10 \
    --gpo.ignoreprice 2 \
    --dev.gaslimit 50000000

If we wanted to use erigon for testing, we could do something like this as well.

$ erigon \
    --chain dev \
    --dev.period 5 \
    --http \
    --http.addr localhost \
    --http.port 8545 \
    --http.api 'admin,debug,web3,eth,txpool,clique,net' \
    --verbosity 5 \
    --rpc.gascap 50000000 \
    --miner.gaslimit 10 \
    --gpo.blocks 1 \
    --gpo.percentile 1 \
    --mine

Once your Eth client is running and the RPC is functional, you'll need to transfer some amount of ether to a known account that ca be used for testing.

$ cast send \
    --from "$(cast rpc --rpc-url localhost:8545 eth_coinbase | jq -r '.')" \
    --rpc-url localhost:8545 \
    --unlocked \
    --value 100ether \
    --json \
    0x85dA99c8a7C2C95964c8EfD687E95E632Fc533D6 | jq

Then we might want to deploy some test smart contracts. For the purposes of testing we'll our ERC20 contract.

$ cast send \
    --from 0x85dA99c8a7C2C95964c8EfD687E95E632Fc533D6 \
    --private-key 0x42b6e34dc21598a807dc19d7784c71b2a7a01f6480dc6f58258f78e539f1a1fa \
    --rpc-url localhost:8545 \
    --json \
    --create \
    "$(cat ./contracts/tokens/ERC20/ERC20.bin)" | jq

Once this has been completed this will be the address of the contract: 0x6fda56c57b0acadb96ed5624ac500c0429d59429.

$  docker run -v $PWD/contracts:/contracts ethereum/solc:stable --storage-layout /contracts/tokens/ERC20/ERC20.sol

Links

Flags

      --contract-address string   The address of a contract that can be used for testing. If not specified, a contract will be deployed automatically.
      --csv                       Flag to indicate that output will be exported as a CSV.
      --export-path string        The directory export path of the output of the tests. Must pair this with either --json, --csv, --md, or --html
      --fuzz                      Flag to indicate whether to fuzz input or not.
      --fuzzn int                 Number of times to run the fuzzer per test. (default 100)
  -h, --help                      help for rpcfuzz
      --html                      Flag to indicate that output will be exported as a HTML.
      --json                      Flag to indicate that output will be exported as a JSON.
      --md                        Flag to indicate that output will be exported as a Markdown.
      --namespaces string         Comma separated list of rpc namespaces to test (default "eth,web3,net,debug,raw")
      --private-key string        The hex encoded private key that we'll use to sending transactions (default "42b6e34dc21598a807dc19d7784c71b2a7a01f6480dc6f58258f78e539f1a1fa")
  -r, --rpc-url string            The RPC endpoint url (default "http://localhost:8545")
      --seed int                  A seed for generating random values within the fuzzer (default 123456)

The command also inherits flags from parent commands.

      --config string   config file (default is $HOME/.polygon-cli.yaml)
      --pretty-logs     Should logs be in pretty format or JSON (default true)
  -v, --verbosity int   0 - Silent
                        100 Panic
                        200 Fatal
                        300 Error
                        400 Warning
                        500 Info
                        600 Debug
                        700 Trace (default 500)

See also

  • polycli - A Swiss Army knife of blockchain tools.