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

Updated Kaia changes #1

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
The MIT License (MIT)

Copyright (c) 2024 Kaia DLT Foundation
Copyright (c) 2022-2024 Klaytn Foundation
Copyright (c) 2022 RPC Tester Authors

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
53 changes: 23 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,31 @@
[![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/)
# Kaia RPC-tester

# NO LONGER MAINTAINED

Since the launch of Kaia Blockchain this repository has been parked in favour of the new open-source projects in [Kaia's Github](https://github.com/kaiachain). Contributors have now moved there continuing with massive open-source contributions to our blockchain ecosystem. A big thank you to everyone who has contributed to this repository. For more information about Klaytn's chain merge with Finschia blockchain please refer to the launching of Kaia blockchain - [kaia.io](http://kaia.io/).


# RPC-tester

The tester checks basic operations of Klaytn RPC/WebSocket APIs.
The tester checks basic operations of Kaia RPC/WebSocket APIs.

# How to run
## Python Virtualenv
> You can setup the project Environment as separate env from your globally installed python dev environemnt by using virtualenv.

Please check below instructions after installing virtualenv :)
- Create virtualenv for this project by using `$ virtualenv -p python3.6 venv`
- Create virtualenv for this project by using `$ virtualenv -p python3.6 venv` or `$ python3 -m venv ./venv`
- Activate virtualenv by using `source ./venv/bin/activate`
- Install project dependency by using `$ pip install -r requirements.txt`
- Install this repository as module to use relative path `$pip install -e .`

All done :)

## Required
- [1] Faucet Account: An account which has enough amount KLAY for the test.
- [1] Faucet Account: An account which has enough amount KAIA for the test.
### For EN (to be tested)
- Options
1. --rpc --rpcapi admin,debug,klay,eth,miner,net,personal,rpc,txpool,web3 --rpcport 8551 --rpcaddr 0.0.0.0
2. --ws --wsapi admin,debug,klay,eth,miner,net,personal,rpc,txpool,web3 --wsport 8552 --wsaddr 0.0.0.0
1. --rpc --rpcapi admin,debug,kaia,eth,miner,net,personal,rpc,txpool,web3 --rpcport 8551 --rpcaddr 0.0.0.0
2. --ws --wsapi admin,debug,kaia,eth,miner,net,personal,rpc,txpool,web3 --wsport 8552 --wsaddr 0.0.0.0
3. --sendertxhashindexing
4. --vmdebug
5. --txpool.allow-local-anchortx

```shell
--rpc --rpcapi admin,debug,klay,eth,miner,net,personal,rpc,txpool,web3 --rpcport 8551 --rpcaddr 0.0.0.0 --ws --wsapi admin,debug,klay,miner,net,personal,rpc,txpool,web3 --wsport 8552 --wsaddr 0.0.0.0 --sendertxhashindexing --vmdebug
--rpc --rpcapi admin,debug,kaia,eth,miner,net,personal,rpc,txpool,web3 --rpcport 8551 --rpcaddr 0.0.0.0 --ws --wsapi admin,debug,kaia,miner,net,personal,rpc,txpool,web3 --wsport 8552 --wsaddr 0.0.0.0 --sendertxhashindexing --vmdebug
```

- File
Expand All @@ -42,7 +35,7 @@ All done :)

## Usage
### 0. Set config.json and run generate_ws_from_rpc.sh
`config.json` - The information of EN and the faucet account and fee payer account (both account should have enough KLAY).
`config.json` - The information of EN and the faucet account and fee payer account (both account should have enough KAIA).
```json
{
"endpoint": "localhost",
Expand All @@ -55,7 +48,7 @@ All done :)
"feePayerPrivateKey": "752a08fd165dcc7f37f3e444cf485c5b2020e4096a2cfd02f823a8b8280baaab",
"feePayerAddress": "0xf77e71cf745e14129a344bcfb7e28240a5351beb",
"feePayerPassword": "2524",
"namespaces": "admin,debug,personal,txpool,eth,klay"
"namespaces": "admin,debug,personal,txpool,eth,kaia"
}
```

Expand Down Expand Up @@ -92,7 +85,7 @@ If you want to run tests for specific protocol, you can do like below.
│   └── admin_ws.py
├── block.rlp
├── common # This contains common functions which will be used by many test scripts commonly.
│   ├── klay.py # functions can be used by multiple tests cases with klay namespace
│   ├── kaia.py # functions can be used by multiple tests cases with kaia namespace
│   ├── net.py # functions can be used by multiple tests cases with net namespace
│   └── personal.py # functions can be used by multiple tests cases with personal namespace
├── config.json # config file used during tests.
Expand Down Expand Up @@ -124,25 +117,25 @@ If you want to run tests for specific protocol, you can do like below.
│   │   ├── eth_transaction_rpc.py
│   │   └── eth_transaction_ws.py
├── generate_ws_from_rpc.sh
├── klay # This contains test scripts about `klay` namespace.
├── kaia # This contains test scripts about `kaia` namespace.
│   ├── account
│   │   ├── klay_account_rpc.py
│   │   └── klay_account_ws.py
│   │   ├── kaia_account_rpc.py
│   │   └── kaia_account_ws.py
│   ├── block
│   │   ├── klay_block_rpc.py
│   │   └── klay_block_ws.py
│   │   ├── kaia_block_rpc.py
│   │   └── kaia_block_ws.py
│   ├── configuration
│   │   ├── klay_configuration_rpc.py
│   │   └── klay_configuration_ws.py
│   │   ├── kaia_configuration_rpc.py
│   │   └── kaia_configuration_ws.py
│   ├── filter
│   │   ├── klay_filter_rpc.py
│   │   └── klay_filter_ws.py
│   │   ├── kaia_filter_rpc.py
│   │   └── kaia_filter_ws.py
│   ├── miscellaneous
│   │   ├── klay_miscellaneous_rpc.py
│   │   └── klay_miscellaneous_ws.py
│   │   ├── kaia_miscellaneous_rpc.py
│   │   └── kaia_miscellaneous_ws.py
│   └── transaction
│   │   ├── klay_transaction_rpc.py
│   │   └── klay_transaction_ws.py
│   │   ├── kaia_transaction_rpc.py
│   │   └── kaia_transaction_ws.py
├── main.py # Run tests by executing main.py
├── net # This contains test scripts about `net` namespace.
│   ├── net_rpc.py
Expand Down
22 changes: 11 additions & 11 deletions admin/admin_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ def test_admin_stopRPC_success_using_ws(self):
self.assertTrue(ws_result)
self.assertIsNone(error)

Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some klay logs.")
Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some kaia logs.")

def test_admin_stopRPC_error_http_rpc_not_running_using_ws(self):
method = f"{self.ns}_stopRPC"
_, error = Utils.call_ws(self.endpoint, method, None, self.log_path) # Using WebSocket is intended.
Utils.check_error(self, "HTTPRPCNotRunning", error)

Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some klay logs.")
Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some kaia logs.")

def test_admin_startRPC_success_using_ws(self):
# During running above tests, http endpoint is closed so we must request using WebSocket.
Expand All @@ -167,7 +167,7 @@ def test_admin_stopRPC_success_wrong_value_param_using_ws(self):
self.assertTrue(ws_result)
self.assertIsNone(error)

Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some klay logs.")
Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some kaia logs.")

def test_admin_startRPC_success_no_param_using_ws(self):
method = f"{self.ns}_startRPC"
Expand All @@ -179,14 +179,14 @@ def create_params_for_starting_rpc(self):
host = "0.0.0.0"
port = int(self.rpc_port)
cors = "*"
apis = "admin,eth,klay,net,personal,debug,web3,txpool"
apis = "admin,eth,kaia,net,personal,debug,web3,txpool"
return [host, port, cors, apis]

def create_params_for_starting_ws(self):
host = "0.0.0.0"
port = int(self.ws_port)
cors = "*"
apis = "admin,eth,klay,net,personal,debug,web3,txpool"
apis = "admin,eth,kaia,net,personal,debug,web3,txpool"
return [host, port, cors, apis]

def test_admin_startRPC_error_wrong_type_param1_using_ws(self):
Expand Down Expand Up @@ -245,7 +245,7 @@ def test_admin_stopWS_success_using_rpc(self):
self.assertTrue(result_from_rpc)
self.assertIsNone(error)

Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some klay logs.")
Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some kaia logs.")

def test_admin_startWS_success_using_rpc(self):
method = f"{self.ns}_startWS"
Expand All @@ -261,7 +261,7 @@ def test_admin_stopWS_success_wrong_value_param_using_rpc(self):
self.assertTrue(result_from_rpc)
self.assertIsNone(error)

Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some klay logs.")
Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some kaia logs.")

def test_admin_stopWS_error_ws_not_running_using_rpc(self):
method = f"{self.ns}_stopWS"
Expand Down Expand Up @@ -330,7 +330,7 @@ def test_admin_exportChain_success(self):
_, error = Utils.call_rpc(self.endpoint, method, [file_path], self.log_path)
self.assertIsNone(error)

Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some klay logs.")
Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some kaia logs.")

self.assertTrue(pathlib.Path.exists(pathlib.Path(file_path)))

Expand All @@ -340,7 +340,7 @@ def test_admin_exportChain_error_already_exist(self):
_, error = Utils.call_rpc(self.endpoint, method, [file_path], self.log_path)
Utils.check_error(self, "ExistingFile", error)

Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some klay logs.")
Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some kaia logs.")

def test_admin_exportChain_error_no_param(self):
method = f"{self.ns}_exportChain"
Expand All @@ -353,7 +353,7 @@ def test_admin_importChain_success(self):
_, error = Utils.call_rpc(self.endpoint, method, [file_path], self.log_path)
self.assertIsNone(error)

Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some klay logs.")
Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some kaia logs.")

def test_admin_importChain_error_no_param(self):
method = f"{self.ns}_importChain"
Expand All @@ -375,7 +375,7 @@ def test_admin_nodeConfig_success(self):
_, error = Utils.call_rpc(self.endpoint, method, [], self.log_path)
self.assertIsNone(error)

Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some klay logs.")
Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some kaia logs.")

@staticmethod
def suite():
Expand Down
22 changes: 11 additions & 11 deletions admin/admin_ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,14 @@ def test_admin_stopRPC_success_using_ws(self):
self.assertTrue(ws_result)
self.assertIsNone(error)

Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some klay logs.")
Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some kaia logs.")

def test_admin_stopRPC_error_http_rpc_not_running_using_ws(self):
method = f"{self.ns}_stopRPC"
_, error = Utils.call_ws(self.endpoint, method, None, self.log_path) # Using RPC is intended.
Utils.check_error(self, "HTTPRPCNotRunning", error)

Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some klay logs.")
Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some kaia logs.")

def test_admin_startRPC_success_using_ws(self):
# During running above tests, http endpoint is closed so we must request using RPC.
Expand All @@ -167,7 +167,7 @@ def test_admin_stopRPC_success_wrong_value_param_using_ws(self):
self.assertTrue(ws_result)
self.assertIsNone(error)

Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some klay logs.")
Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some kaia logs.")

def test_admin_startRPC_success_no_param_using_ws(self):
method = f"{self.ns}_startRPC"
Expand All @@ -179,14 +179,14 @@ def create_params_for_starting_rpc(self):
host = "0.0.0.0"
port = int(self.rpc_port)
cors = "*"
apis = "admin,eth,klay,net,personal,debug,web3,txpool"
apis = "admin,eth,kaia,net,personal,debug,web3,txpool"
return [host, port, cors, apis]

def create_params_for_starting_ws(self):
host = "0.0.0.0"
port = int(self.ws_port)
cors = "*"
apis = "admin,eth,klay,net,personal,debug,web3,txpool"
apis = "admin,eth,kaia,net,personal,debug,web3,txpool"
return [host, port, cors, apis]

def test_admin_startRPC_error_wrong_type_param1_using_ws(self):
Expand Down Expand Up @@ -245,7 +245,7 @@ def test_admin_stopWS_success_using_rpc(self):
self.assertTrue(result_from_rpc)
self.assertIsNone(error)

Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some klay logs.")
Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some kaia logs.")

def test_admin_startWS_success_using_rpc(self):
method = f"{self.ns}_startWS"
Expand All @@ -261,7 +261,7 @@ def test_admin_stopWS_success_wrong_value_param_using_rpc(self):
self.assertTrue(result_from_rpc)
self.assertIsNone(error)

Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some klay logs.")
Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some kaia logs.")

def test_admin_stopWS_error_ws_not_running_using_rpc(self):
method = f"{self.ns}_stopWS"
Expand Down Expand Up @@ -330,7 +330,7 @@ def test_admin_exportChain_success(self):
_, error = Utils.call_ws(self.endpoint, method, [file_path], self.log_path)
self.assertIsNone(error)

Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some klay logs.")
Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some kaia logs.")

self.assertTrue(pathlib.Path.exists(pathlib.Path(file_path)))

Expand All @@ -340,7 +340,7 @@ def test_admin_exportChain_error_already_exist(self):
_, error = Utils.call_ws(self.endpoint, method, [file_path], self.log_path)
Utils.check_error(self, "ExistingFile", error)

Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some klay logs.")
Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some kaia logs.")

def test_admin_exportChain_error_no_param(self):
method = f"{self.ns}_exportChain"
Expand All @@ -353,7 +353,7 @@ def test_admin_importChain_success(self):
_, error = Utils.call_ws(self.endpoint, method, [file_path], self.log_path)
self.assertIsNone(error)

Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some klay logs.")
Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some kaia logs.")

def test_admin_importChain_error_no_param(self):
method = f"{self.ns}_importChain"
Expand All @@ -375,7 +375,7 @@ def test_admin_nodeConfig_success(self):
_, error = Utils.call_ws(self.endpoint, method, [], self.log_path)
self.assertIsNone(error)

Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some klay logs.")
Utils.waiting_count("Waiting for", self.waiting_count, "seconds until stacking some kaia logs.")

@staticmethod
def suite():
Expand Down
2 changes: 1 addition & 1 deletion common/eth.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def checkEthereumBlockOrHeaderFormat(self, actualReturn):
self.assertEqual(immutable_fields.get(field), actualValue)
elif field == "uncles":
if actualValue is not None:
# Uncles must not be existed in actualReturn from Klaytn node.
# Uncles must not be existed in actualReturn from Kaia node.
self.assertTrue(len(actualValue) == 0)
elif field == "transactions":
if actualValue is not None:
Expand Down
12 changes: 6 additions & 6 deletions common/klay.py → common/kaia.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,33 @@


def send_transaction(endpoint, params):
transaction_hash, error = Utils.call_rpc(endpoint, "klay_sendTransaction", params, log_path)
transaction_hash, error = Utils.call_rpc(endpoint, "kaia_sendTransaction", params, log_path)
return transaction_hash, error


def get_transaction(endpoint, params):
transaction, error = Utils.call_rpc(endpoint, "klay_getTransactionByHash", params, log_path)
transaction, error = Utils.call_rpc(endpoint, "kaia_getTransactionByHash", params, log_path)
return transaction, error


def get_transaction_receipt(endpoint, params):
receipt, error = Utils.call_rpc(endpoint, "klay_getTransactionReceipt", params, log_path)
receipt, error = Utils.call_rpc(endpoint, "kaia_getTransactionReceipt", params, log_path)
return receipt, error


def get_latest_block_by_number(endpoint):
method = "klay_getBlockByNumber"
method = "kaia_getBlockByNumber"
latest_block, _ = Utils.call_rpc(endpoint, method, ["latest", True], log_path)
return latest_block


def get_block_number(endpoint):
method = "klay_blockNumber"
method = "kaia_blockNumber"
block_number, _ = Utils.call_rpc(endpoint, method, ["latest", True], log_path)
return block_number

def get_chain_config(endpoint):
method = "klay_getChainConfig"
method = "kaia_getChainConfig"
chain_config, _ = Utils.call_rpc(endpoint, method, [], log_path)
return chain_config

Expand Down
2 changes: 1 addition & 1 deletion config_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"feePayerPrivateKey": "752a08fd165dcc7f37f3e444cf485c5b2020e4096a2cfd02f823a8b8280baaab",
"feePayerAddress": "0xf77e71cf745e14129a344bcfb7e28240a5351beb",
"feePayerPassword": "2523",
"namespaces": "admin,debug,eth,governance,klay,net,personal,txpool"
"namespaces": "admin,debug,eth,governance,kaia,net,personal,txpool"
}
Loading