Skip to content
Open

V203 #107

Show file tree
Hide file tree
Changes from all commits
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
59 changes: 59 additions & 0 deletions .github/workflows/ci_integration_tests_docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: ci_integration_tests_docker

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]

# os: [ubuntu-22.04, macos-latest]


steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

- name: Install dependencies
run: make prepare

- name: Run tests
run: make test
env:
DOCKER: true
DOCKER_CKB_VERSION: "nervos/ckb:v0.202.0-rc1"

#
#DOCKER = os.getenv('DOCKER',False)
#DOCKER_CKB_VERSION = os.getenv('DOCKER_CKB_VERSION',"nervos/ckb:v0.202.0-rc1")
# - name: Setup upterm session
# if: always()
# uses: lhotari/action-upterm@v1

- name: Publish reports
if: failure()
uses: actions/upload-artifact@v4
with:
name: jfoa-build-reports-${{ runner.os }}
path: ./report
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ develop_prepare:
python3 -m download_ckb_light_client
echo "install ckb cli"
bash develop_prepare.sh
# test_cases/ckb2023 \

test_cases := \
test_cases/ckb_cli \
test_cases/ckb2023 \
test_cases/contracts \
test_cases/example \
test_cases/framework \
Expand Down
6 changes: 6 additions & 0 deletions framework/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import framework.test_cluster
import framework.config
import shutil

from framework.test_node import DOCKER
from framework.util import get_project_root


Expand Down Expand Up @@ -56,3 +58,7 @@ def teardown_method(self, method):
f"{get_project_root()}/tmp",
f"{get_project_root()}/report/{method.__name__}",
)

@staticmethod
def skip_docker():
return DOCKER
9 changes: 7 additions & 2 deletions framework/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
import os


DOCKER = os.getenv("DOCKER", False)
DOCKER_CKB_VERSION = os.getenv("DOCKER_CKB_VERSION", "nervos/ckb:v0.202.0-rc1")



DOCKER = os.getenv("DOCKER", False)
DOCKER_CKB_VERSION = os.getenv("DOCKER_CKB_VERSION", "nervos/ckb:v0.203.0-rc1")

Expand Down Expand Up @@ -206,13 +211,13 @@ def start(self):
ws_port = self.ckb_config["ckb_ws_listen_address"].split(":")[-1]
tcp_port = self.ckb_config["ckb_tcp_listen_address"].split(":")[-1]
self.ckb_pid = run_command(
f"docker run --name {self.ckb_dir.split('/')[-1]} -p {p2p_port}:{p2p_port} -p {rpc_port}:{rpc_port} -p {ws_port}:{ws_port} -p {tcp_port}:{tcp_port} -v {self.ckb_dir}:/var/lib/ckb {DOCKER_CKB_VERSION} run -C /var/lib/ckb "
f"docker run --name {self.ckb_dir.split('/')[-1]} -p {p2p_port}:{p2p_port} -p {rpc_port}:{rpc_port} -p {ws_port}:{ws_port} -p {tcp_port}:{tcp_port} --network my-network -v {self.ckb_dir}:/var/lib/ckb {DOCKER_CKB_VERSION} run -C /var/lib/ckb "
f"--indexer --skip-spec-check > {self.ckb_dir}/node.log 2>&1 &"
)
time.sleep(3)
return
self.ckb_pid = run_command(
f"docker run --name {self.ckb_dir.split('/')[-1]} -p {p2p_port}:{p2p_port} -p {rpc_port}:{rpc_port} -v {self.ckb_dir}:/var/lib/ckb {DOCKER_CKB_VERSION} run -C /var/lib/ckb "
f"docker run --name {self.ckb_dir.split('/')[-1]} -p {p2p_port}:{p2p_port} -p {rpc_port}:{rpc_port} --network my-network -v {self.ckb_dir}:/var/lib/ckb {DOCKER_CKB_VERSION} run -C /var/lib/ckb "
f"--indexer --skip-spec-check > {self.ckb_dir}/node.log 2>&1 &"
)
time.sleep(3)
Expand Down
2 changes: 1 addition & 1 deletion framework/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get_ckb_configs(p2p_port, rpc_port, spec='{ file = "dev.toml" }'):
"ckb_network_listen_addresses": [
"/ip4/0.0.0.0/tcp/{p2p_port}".format(p2p_port=p2p_port)
],
"ckb_rpc_listen_address": "127.0.0.1:{rpc_port}".format(rpc_port=rpc_port),
"ckb_rpc_listen_address": "0.0.0.0:{rpc_port}".format(rpc_port=rpc_port),
"ckb_rpc_modules": [
"Net",
"Pool",
Expand Down
5 changes: 3 additions & 2 deletions test_cases/replace_rpc/test_sub_telnet_with_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import time

from framework.basic import CkbTest
from framework.test_node import DOCKER


class TestTelnetAndWebsocket(CkbTest):
Expand All @@ -21,8 +22,8 @@ def setup_class(cls):
cls.node113.prepare(
other_ckb_config={
"ckb_logger_filter": "debug",
"ckb_tcp_listen_address": "127.0.0.1:18116",
"ckb_ws_listen_address": "127.0.0.1:18124",
"ckb_tcp_listen_address": "0.0.0.0:18116",
"ckb_ws_listen_address": "0.0.0.0:18124",
}
)

Expand Down
17 changes: 10 additions & 7 deletions test_cases/replace_rpc/test_telnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def setup_class(cls):
cls.node113.prepare(
other_ckb_config={
"ckb_logger_filter": "debug",
"ckb_tcp_listen_address": "127.0.0.1:18115",
"ckb_ws_listen_address": "127.0.0.1:18124",
"ckb_tcp_listen_address": "0.0.0.0:18115",
"ckb_ws_listen_address": "0.0.0.0:18124",
}
)

Expand Down Expand Up @@ -53,7 +53,7 @@ def test_link_count_max(self):
"""
# 1.test 113 max link count
telnets = []
for i in range(10000):
for i in range(100):
print(i)
telnet = self.node113.subscribe_telnet("new_tip_header")
telnets.append(telnet)
Expand All @@ -74,7 +74,7 @@ def test_link_time_max(self):
"""
telnet113 = self.node113.subscribe_telnet("new_tip_header")

for i in range(300):
for i in range(30):
self.Miner.miner_with_version(self.node113, "0x0")
print("current idx:", i)
ret113 = telnet113.read_very_eager()
Expand All @@ -91,7 +91,10 @@ def test_link_websocket(self):
"""
with pytest.raises(Exception) as exc_info:
socket = self.node113.subscribe_websocket(
"new_tip_header", self.node113.ckb_config["ckb_tcp_listen_address"]
"new_tip_header",
self.node113.ckb_config["ckb_tcp_listen_address"].replace(
"0.0.0.0", "127.0.0.1"
),
)
expected_error_message = "invalid literal for int() with base 10"
assert (
Expand All @@ -106,7 +109,7 @@ def test_rpc(self):
"""

client = self.node113.getClient()
client.url = f"http://{self.node113.ckb_config['ckb_tcp_listen_address']}"
client.url = f"http://{self.node113.ckb_config['ckb_tcp_listen_address'].replace('0.0.0.0','127.0.0.1')}"

with pytest.raises(Exception) as exc_info:
response = client.call("get_tip_block_number", [], 1)
Expand Down Expand Up @@ -142,7 +145,7 @@ def test_unsubscribe(self):
"""

client = self.node113.getClient()
client.url = f"http://{self.node113.ckb_config['ckb_rpc_listen_address']}"
client.url = f"http://{self.node113.ckb_config['ckb_rpc_listen_address'].replace('0.0.0.0','127.0.0.1')}"
socket = self.node113.subscribe_telnet("new_tip_header")
self.Miner.miner_with_version(self.node113, "0x0")
ret = socket.read_very_eager()
Expand Down
9 changes: 4 additions & 5 deletions test_cases/replace_rpc/test_websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,15 @@ def setup_class(cls):

"""
cls.node113 = cls.CkbNode.init_dev_by_port(
cls.CkbNodeConfigPath.CURRENT_TEST, "telnet/node", 8114, 8115
cls.CkbNodeConfigPath.CURRENT_TEST, "telnet2/node", 8114, 8115
)
cls.node113.prepare(
other_ckb_config={
"ckb_logger_filter": "debug",
"ckb_tcp_listen_address": "127.0.0.1:18114",
"ckb_ws_listen_address": "127.0.0.1:18124",
"ckb_tcp_listen_address": "0.0.0.0:18114",
"ckb_ws_listen_address": "0.0.0.0:18124",
}
)

cls.node113.start()
cls.Miner.make_tip_height_number(cls.node113, 100)

Expand Down Expand Up @@ -89,7 +88,7 @@ def test_rpc(self):
3. 113: support
"""
client = self.node113.getClient()
client.url = f"http://{self.node113.ckb_config['ckb_ws_listen_address']}"
client.url = f"http://{self.node113.ckb_config['ckb_ws_listen_address'].replace('0.0.0.0','127.0.0.1')}"

response = client.call("get_tip_block_number", [], 1)

Expand Down
Loading