11#!/usr/bin/python3
2+ """ Run the JSON RPC API curl commands as integration tests """
3+
4+ # pylint: disable=line-too-long
25
36import json
47import shlex
58import subprocess
69import sys
710
811def run_shell_command (command : str ) -> int :
9- """ """
12+ """ Run the specified command as shell. """
1013 command_and_args = shlex .split (command )
11- process = subprocess .run (command_and_args , stdout = subprocess .PIPE , universal_newlines = True )
14+ process = subprocess .run (command_and_args , stdout = subprocess .PIPE , universal_newlines = True , check = True )
1215 if process .returncode != 0 :
1316 sys .exit (process .returncode )
1417 response = json .loads (process .stdout )
1518 if "error" in response :
16- print ( "execute KO:" , command_and_args )
19+ print ( " KO: " , command_and_args , " ERROR: " , response [ "error" ] )
1720 sys .exit (1 )
18- else :
19- print ("execute OK:" , command_and_args )
2021
2122run_shell_command ('''curl --silent -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":1}' localhost:51515''' )
2223run_shell_command ('''curl --silent -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"web3_sha3","params":["0x00"],"id":1}' localhost:51515''' )
@@ -33,7 +34,6 @@ def run_shell_command(command: str) -> int:
3334run_shell_command ('''curl --silent -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlockByHash","params":["0xd268bdabee5eab4914d0de9b0e0071364582cfb3c952b19727f1ab429f4ba2a8", true],"id":25388}' localhost:51515''' )
3435run_shell_command ('''curl --silent -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x41b57c", true],"id":25388}' localhost:51515''' )
3536run_shell_command ('''curl --silent -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlockTransactionCountByNumber","params":["0x41b57c"],"id":1}' localhost:51515''' )
37+ run_shell_command ('''curl --silent -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlockTransactionCountByHash","params":["0x814672e6913a3879217169c6ba461114fa032d9510a56a409d3aab19f668e299"],"id":1}' localhost:51515''' )
3638
37- run_shell_command ('''curl --silent -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"fromBlock": "0x3d0900", "toBlock": "0x3d0964", "address": "0x2a89f54a9f8e727a7be754fd055bb8ea93d0557d"}],"id":3}' http://localhost:51515''' )
38-
39- run_shell_command ('''curl --silent -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getBlockTransactionCountByHash","params":["0x814672e6913a3879217169c6ba461114fa032d9510a56a409d3aab19f668e299"],"id":1}' http://localhost:51515''' )
39+ run_shell_command ('''curl --silent -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"fromBlock": "0x3d0900", "toBlock": "0x3d0964", "address": "0x2a89f54a9f8e727a7be754fd055bb8ea93d0557d"}],"id":3}' localhost:51515''' )
0 commit comments