Skip to content
This repository was archived by the owner on Jan 9, 2024. It is now read-only.

Commit e5a6193

Browse files
authored
Add pylint Python linter (#38)
* Add PyLint to run_linter.sh and CI Fix linter errors in integration script Remove output for passed integration tests * Fix linter errors
1 parent 5f30264 commit e5a6193

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

.circleci/config.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,17 @@ commands:
2727
lint:
2828
steps:
2929
- run:
30-
name: "Install CppLint"
30+
name: "Install Linters"
3131
command: |
3232
sudo apt-get install -y python3-pip
3333
sudo pip3 install cpplint
34+
sudo pip3 install pylint
3435
- run:
35-
name: "Lint"
36+
name: "Run CppLint"
3637
command: cpplint silkrpc/**/*.hpp silkrpc/**/*.cpp
38+
- run:
39+
name: "Run PyLint"
40+
command: pylint tests/
3741

3842
build:
3943
steps:

run_linter.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
#!/bin/bash
22

33
cpplint silkrpc/**/*.hpp silkrpc/**/*.cpp
4+
5+
pylint tests

tests/integration/run_jsonrpc_commands.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
#!/usr/bin/python3
2+
""" Run the JSON RPC API curl commands as integration tests """
3+
4+
# pylint: disable=line-too-long
25

36
import json
47
import shlex
58
import subprocess
69
import sys
710

811
def 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

2122
run_shell_command('''curl --silent -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"web3_clientVersion","params":[],"id":1}' localhost:51515''')
2223
run_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:
3334
run_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''')
3435
run_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''')
3536
run_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''')

tests/perf/run_perf_tests.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/usr/bin/env python3
2-
3-
""" This script is responsible using vegeta to make a list of performance tests (configured via command line) and saves its result on csv file
2+
""" This script uses Vegeta to execute a list of performance tests (configured via command line) and saves its result in CSV file
43
"""
54

5+
# pylint: disable=consider-using-with
6+
67
import os
78
import csv
89
import sys

0 commit comments

Comments
 (0)