Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- parity-test.sh.orig 2019-04-02 12:20:52.084782728 +0200
- +++ parity-test.sh 2019-04-02 12:20:25.500673565 +0200
- @@ -1,26 +1,27 @@
- #!/bin/bash
- #
- # Test Parity RPC - Brad Dameron (serpent6877@hotmail.com)
- +# Modified by https://github.com/c0deright
- #
- -# parity-test.sh <RPC PORT> <# requests before delay> <Delay time between tests>
- +# parity-test.sh <HOST>:<RPC PORT> <# requests before delay> <Delay time between tests>
- # Use CTRL+C to exit program
- #
- -# Example ./parity-test.sh 8545 1000 15 5
- -# Test port 8545 with 1000 requests of each type 15 times with a 5 second delay between tests
- +# Example ./parity-test.sh localhost:8545 1000 15 5
- +# Test localhost on port 8545 with 1000 requests of each type 15 times with a 5 second delay between tests
- #
- # Requires parallel installed.
- -PORT=$1
- +HOST_N_PORT=$1
- REQUESTS=$2
- TESTS=$3
- DELAY=$4
- LOGFILE=parity-test.log
- # Set some defaults if no command line option
- -if [ -z $PORT ]
- +if [ -z $HOST_N_PORT ]
- then
- - PORT=8545
- + HOST_N_PORT="localhost:8545"
- fi
- if [ -z $DELAY ]
- then
- @@ -36,30 +37,31 @@
- fi
- getBalance() {
- - PORT=$1
- - LOGFILE=$2
- + HOST_N_PORT=$1
- # Test getBalance
- - curl -s -X POST --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0xc94770007dda54cF92009BFF0dE90c06F603a09f", "latest"],"id":1}' -H "Content-Type: application/json" -X POST localhost:$PORT >> $LOGFILE
- + curl -s -X POST --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0xc94770007dda54cF92009BFF0dE90c06F603a09f", "latest"],"id":1}' -H "Content-Type: application/json" -X POST $HOST_N_PORT
- # Test getWork
- - curl -s -X POST --data '{"jsonrpc":"2.0","method":"eth_getWork","params":[],"id":73}' -H "Content-Type: application/json" -X POST localhost:$PORT >> $LOGFILE
- +# curl -s -X POST --data '{"jsonrpc":"2.0","method":"eth_getWork","params":[],"id":73}' -H "Content-Type: application/json" -X POST $HOST_N_PORT
- # Test current blockNumber
- - curl -s -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' -H "Content-Type: application/json" -X POST localhost:$PORT >> $LOGFILE
- + curl -s -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' -H "Content-Type: application/json" -X POST $HOST_N_PORT
- # Test peerCount
- - curl -s -X POST --data '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":74}' -H "Content-Type: application/json" -X POST localhost:$PORT >> $LOGFILE
- + curl -s -X POST --data '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":74}' -H "Content-Type: application/json" -X POST $HOST_N_PORT
- # Test accounts
- - curl -s -X POST --data '{"jsonrpc":"2.0","method":"eth_accounts","params":[],"id":1}' -H "Content-Type: application/json" -X POST localhost:$PORT >> $LOGFILE
- + curl -s -X POST --data '{"jsonrpc":"2.0","method":"eth_accounts","params":[],"id":1}' -H "Content-Type: application/json" -X POST $HOST_N_PORT
- }
- export -f getBalance
- -for run in $(eval echo "{1..$TESTS}")
- +exec > >(tee -a $LOGFILE) 2>&1
- +
- +for run in $(seq $TESTS)
- do
- START=$(date +%s)
- - echo "$START - Starting testing ---------" >> $LOGFILE
- - seq $REQUESTS | parallel -j0 -N0 getBalance $PORT $LOGFILE > /dev/null
- + echo "$START - Starting testing ---------"
- + seq $REQUESTS | parallel -j0 -N0 getBalance $HOST_N_PORT >/dev/null
- END=$(date +%s)
- DIFF=$(( $END - $START ))
- - echo "$END - Stopping testing ---------" >> $LOGFILE
- + echo "$END - Stopping testing ---------"
- echo "It took $DIFF seconds for $REQUESTS requests"
- echo "Delaying for $DELAY seconds."
- sleep $DELAY
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement