From 34c0cbebe0e7db90a25ec07be635e672c3a1bdd4 Mon Sep 17 00:00:00 2001 From: gpBlockchain <32102187+gpBlockchain@users.noreply.github.com> Date: Thu, 21 Mar 2024 09:36:16 +0800 Subject: [PATCH 01/33] Update download.py --- download.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/download.py b/download.py index 332c7f6..934296c 100644 --- a/download.py +++ b/download.py @@ -11,7 +11,7 @@ import requests from tqdm import tqdm -versions = ['0.109.0', '0.110.2', '0.111.0', '0.112.1', '0.113.1', "0.114.0", "0.115.0-rc1"] # Replace with your versions +versions = ['0.109.0', '0.110.2', '0.111.0', '0.112.1', '0.113.1', "0.114.0", "0.115.0-rc2"] # Replace with your versions DOWNLOAD_DIR = "download" From 81396632dd3f177d635441b53d2d7c507023bdc2 Mon Sep 17 00:00:00 2001 From: gpBlockchain <32102187+gpBlockchain@users.noreply.github.com> Date: Thu, 21 Mar 2024 09:40:02 +0800 Subject: [PATCH 02/33] issue-4363 add test --- .../tx_pool_refactor/test_11_issue4363.py | 146 ++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 test_cases/tx_pool_refactor/test_11_issue4363.py diff --git a/test_cases/tx_pool_refactor/test_11_issue4363.py b/test_cases/tx_pool_refactor/test_11_issue4363.py new file mode 100644 index 0000000..d546eee --- /dev/null +++ b/test_cases/tx_pool_refactor/test_11_issue4363.py @@ -0,0 +1,146 @@ +import time + +import pytest + +from framework.basic import CkbTest + + +class TestIssue4363(CkbTest): + + @classmethod + def setup_class(cls): + cls.node1 = cls.CkbNode.init_dev_by_port(cls.CkbNodeConfigPath.CURRENT_TEST, "node/node1", 8114, 8115) + cls.node2 = cls.CkbNode.init_dev_by_port(cls.CkbNodeConfigPath.CURRENT_TEST, "node/node2", 8116, 8117) + + cls.node1.prepare() + cls.node1.start() + cls.node2.prepare() + cls.node2.start() + cls.node2.connected(cls.node1) + cls.Miner.make_tip_height_number(cls.node1, 300) + cls.Node.wait_node_height(cls.node2, 300, 300) + + @classmethod + def teardown_class(cls): + cls.node1.stop() + cls.node1.clean() + cls.node2.stop() + cls.node2.clean() + + def test_01_4363(self): + """ + https://github.com/nervosnetwork/ckb/pull/4363/files + 插入消费cellDep时,如果链条太长,就会将多余的链条交易删除 + 0. 生成250个live cell 和 cell=a + 1. 发送200笔 tx1(cellDep=a) + 2. 发送 tx2(input = 低手续费的tx1.putput(1 || 2 || 3 || 4 || 5)) + 3. 发送 tx3(cellDep = 低手续费的tx1.output(1 || 2 || 3 || 4 || 5)) + 4. 发送 tx4(消费 a) + 5. 查询低手续费的tx1 报 PoolRejectedInvalidated + 6. 查询下tx2 报 PoolRejectedInvalidated + 7. 查询 tx3 报 PoolRejectedInvalidated + """ + # 0. 生成250个live cell + account = self.Ckb_cli.util_key_info_by_private_key(self.Config.ACCOUNT_PRIVATE_1) + account_private = self.Config.ACCOUNT_PRIVATE_1 + tx1_hash = self.Ckb_cli.wallet_transfer_by_private_key(account_private, + account["address"]["testnet"], 1000000, + self.node1.getClient().url, "15000000") + tx_live_cell_hash = self.Tx.send_transfer_self_tx_with_input([tx1_hash], ["0x0"], account_private, + output_count=250, + fee=1000090, + api_url=self.node1.getClient().url) + self.Miner.miner_until_tx_committed(self.node1, tx_live_cell_hash) + tx2_hash = self.Ckb_cli.wallet_transfer_by_private_key(self.Config.ACCOUNT_PRIVATE_2, + account["address"]["testnet"], 1000000, + self.node1.getClient().url, "15000000") + tx_3_father_hash = self.Tx.send_transfer_self_tx_with_input([tx2_hash], ["0x0"], account_private, + output_count=5, + fee=1000090, + api_url=self.node1.getClient().url) + self.Miner.miner_until_tx_committed(self.node1, tx_3_father_hash) + + # 0 生成cell a + tx_a_hash = self.Ckb_cli.wallet_transfer_by_private_key(self.Config.ACCOUNT_PRIVATE_2, + account["address"]["testnet"], 1000000, + self.node1.getClient().url, "1500000") + self.Miner.miner_until_tx_committed(self.node1, tx_a_hash) + # 1. 发送200笔 tx1(cellDep=a) + tx1_list = [] + for i in range(200): + print("current i:", i) + tx_hash = self.Tx.send_transfer_self_tx_with_input([tx_live_cell_hash], [hex(i)], account_private, + output_count=3, + fee=100090 + i * 1000, + api_url=self.node1.getClient().url, + dep_cells=[{"tx_hash": tx_a_hash, "index_hex": "0x0"}]) + tx1_list.append(tx_hash) + + # 2. 发送 tx2(input = 低手续费的tx1.putput(1 || 2 || 3 || 4 || 5)) + tx2_list = [] + tx22_list = [] + for i in range(3): + tx_hash = self.Tx.send_transfer_self_tx_with_input([tx1_list[0]], [hex(i)], account_private, + output_count=2, + fee=100090 + i * 1000, + api_url=self.node1.getClient().url) + tx2_list.append(tx_hash) + tx_hash = self.Tx.send_transfer_self_tx_with_input([tx_hash], [hex(1)], account_private, + output_count=1, + fee=100090 + i * 1000, + api_url=self.node1.getClient().url) + tx22_list.append(tx_hash) + + # 3. 发送 tx3(cellDep = 低手续费的tx1.output(1 || 2 || 3 || 4 || 5)) + tx3_list = [] + for i in range(3): + tx_hash = self.Tx.send_transfer_self_tx_with_input([tx_3_father_hash], [hex(i)], account_private, + output_count=2, + fee=100090 + i * 1000, + api_url=self.node1.getClient().url, + dep_cells=[{"tx_hash": tx1_list[1], "index_hex": "0x0"}]) + tx3_list.append(tx_hash) + + # 4. 发送 tx4(消费 a) + tx_a_cost_hash = self.Tx.send_transfer_self_tx_with_input([tx_a_hash], ["0x0"], account_private, + output_count=1, + fee=100090, + api_url=self.node1.getClient().url) + # TODO remove sleep + time.sleep(10) + # 5. 查询低手续费的tx1 报 PoolRejectedInvalidated + print("---- tx1_list------") + pending_status = 0 + rejected_status = 0 + for tx_hash in tx1_list: + response = self.node1.getClient().get_transaction(tx_hash) + response2 = self.node2.getClient().get_transaction(tx_hash) + assert response['tx_status']['status'] == response2['tx_status']['status'] + if response['tx_status']['status'] == 'pending': + pending_status += 1 + if response['tx_status']['status'] == 'rejected': + rejected_status += 1 + assert pending_status == 124 + assert rejected_status == 76 + # 6. 查询下tx2 报 PoolRejectedInvalidated + print("---- tx2_hash------") + for tx_hash in tx2_list: + response = self.node1.getClient().get_transaction(tx_hash) + response2 = self.node2.getClient().get_transaction(tx_hash) + assert response['tx_status']['status'] == response2['tx_status']['status'] + assert response['tx_status']['status'] == 'rejected' + + print("---- tx22_list------") + for tx_hash in tx22_list: + response = self.node1.getClient().get_transaction(tx_hash) + response2 = self.node2.getClient().get_transaction(tx_hash) + assert response['tx_status']['status'] == response2['tx_status']['status'] + assert response['tx_status']['status'] == 'rejected' + + # 7. 查询 tx3 报 PoolRejectedInvalidated + print("---- tx3_list------") + for tx_hash in tx3_list: + response = self.node1.getClient().get_transaction(tx_hash) + response2 = self.node2.getClient().get_transaction(tx_hash) + assert response['tx_status']['status'] == response2['tx_status']['status'] + assert response['tx_status']['status'] == 'rejected' From a97e8af2aad5cd53bdaeae8ed1eb6ee0ee1cdaf0 Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Thu, 21 Mar 2024 14:48:59 +0800 Subject: [PATCH 03/33] rich-indexer support indexer api --- framework/test_node.py | 2 +- test_cases/rpc/node_fixture.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/test_node.py b/framework/test_node.py index 6b53c0d..71cbc4c 100644 --- a/framework/test_node.py +++ b/framework/test_node.py @@ -22,7 +22,7 @@ class CkbNodeConfigPath(Enum): "source/template/specs/mainnet.toml.j2", "download/0.115.0") - v115_rc1 = ( + v115 = ( "source/template/ckb/v115/ckb.toml.j2", "source/template/ckb/v115/ckb-miner.toml.j2", "source/template/ckb/v115/specs/dev.toml", diff --git a/test_cases/rpc/node_fixture.py b/test_cases/rpc/node_fixture.py index ce0cde8..71aed10 100644 --- a/test_cases/rpc/node_fixture.py +++ b/test_cases/rpc/node_fixture.py @@ -34,7 +34,7 @@ def get_cluster(): @pytest.fixture(scope='module') def get_cluster_indexer(): nodes = [ - CkbNode.init_dev_by_port(CkbNodeConfigPath.v115_rc1, "cluster_indexer/node{i}".format(i=i), 8114 + i, + CkbNode.init_dev_by_port(CkbNodeConfigPath.v115, "cluster_indexer/node{i}".format(i=i), 8114 + i, 8225 + i) for i in range(0, 2) From 88d9db8c5bc74908e2d1024161385487c08a1762 Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Thu, 21 Mar 2024 15:29:46 +0800 Subject: [PATCH 04/33] debug workflows run when case run error --- Makefile | 24 ++++++++++++------------ test.sh | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index dec0c35..0108fea 100644 --- a/Makefile +++ b/Makefile @@ -18,18 +18,18 @@ check_failed_html: test: bash test.sh test_cases/replace_rpc bash test.sh test_cases/ckb2023 - bash test.sh test_cases/ckb_cli - bash test.sh test_cases/contracts - bash test.sh test_cases/example - bash test.sh test_cases/framework - bash test.sh test_cases/light_client - bash test.sh test_cases/mocking - bash test.sh test_cases/node_compatible - bash test.sh test_cases/rpc - bash test.sh test_cases/soft_fork - bash test.sh test_cases/issue - bash test.sh test_cases/tx_pool_refactor - bash test.sh test_cases/feature +# bash test.sh test_cases/ckb_cli +# bash test.sh test_cases/contracts +# bash test.sh test_cases/example +# bash test.sh test_cases/framework +# bash test.sh test_cases/light_client +# bash test.sh test_cases/mocking +# bash test.sh test_cases/node_compatible +# bash test.sh test_cases/rpc +# bash test.sh test_cases/soft_fork +# bash test.sh test_cases/issue +# bash test.sh test_cases/tx_pool_refactor +# bash test.sh test_cases/feature @if test -n "$$(ls report/*failed.html 2>/dev/null)"; then \ echo "Error: Failed HTML files found in the 'report' directory"; \ exit 1; \ diff --git a/test.sh b/test.sh index e2abae1..3ca3289 100644 --- a/test.sh +++ b/test.sh @@ -1,4 +1,4 @@ -python -m pytest $1 +python3 -m pytest $1 -x --exitfirst if [ $? == 1 ];then pkill ckb sleep 3 @@ -11,4 +11,4 @@ pkill ckb sleep 3 rm -rf tmp rm -rf report/report.html -echo "run cusscessful" +echo "run successful" From 21b5686d451a4660adf5d48ea1511ce02a931df1 Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Thu, 21 Mar 2024 15:38:07 +0800 Subject: [PATCH 05/33] debug workflows only run fail case when case run error --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0108fea..106e8f5 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ check_failed_html: fi test: bash test.sh test_cases/replace_rpc - bash test.sh test_cases/ckb2023 +# bash test.sh test_cases/ckb2023 # bash test.sh test_cases/ckb_cli # bash test.sh test_cases/contracts # bash test.sh test_cases/example From 025fa4109dc8765d3e817a8b1b2238ba880f62e9 Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Thu, 21 Mar 2024 15:43:47 +0800 Subject: [PATCH 06/33] debug workflows exit signal when case run error --- test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.sh b/test.sh index 3ca3289..a7994f5 100644 --- a/test.sh +++ b/test.sh @@ -5,7 +5,7 @@ if [ $? == 1 ];then rm -rf tmp echo "run failed " mv report/report.html report/${1////_}_failed.html - exit 0 + exit -1 fi pkill ckb sleep 3 From 0464dc9faa90eeee134e2a71d80fe9c3734661c4 Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Thu, 21 Mar 2024 15:44:17 +0800 Subject: [PATCH 07/33] debug workflows exit signal when case run error --- test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.sh b/test.sh index a7994f5..529d061 100644 --- a/test.sh +++ b/test.sh @@ -5,7 +5,7 @@ if [ $? == 1 ];then rm -rf tmp echo "run failed " mv report/report.html report/${1////_}_failed.html - exit -1 + exit 1 fi pkill ckb sleep 3 From 21c63b5208723e8ae9d803acd9cb697b6062fbc0 Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Thu, 21 Mar 2024 15:46:44 +0800 Subject: [PATCH 08/33] recover all cases run --- Makefile | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 106e8f5..dec0c35 100644 --- a/Makefile +++ b/Makefile @@ -17,19 +17,19 @@ check_failed_html: fi test: bash test.sh test_cases/replace_rpc -# bash test.sh test_cases/ckb2023 -# bash test.sh test_cases/ckb_cli -# bash test.sh test_cases/contracts -# bash test.sh test_cases/example -# bash test.sh test_cases/framework -# bash test.sh test_cases/light_client -# bash test.sh test_cases/mocking -# bash test.sh test_cases/node_compatible -# bash test.sh test_cases/rpc -# bash test.sh test_cases/soft_fork -# bash test.sh test_cases/issue -# bash test.sh test_cases/tx_pool_refactor -# bash test.sh test_cases/feature + bash test.sh test_cases/ckb2023 + bash test.sh test_cases/ckb_cli + bash test.sh test_cases/contracts + bash test.sh test_cases/example + bash test.sh test_cases/framework + bash test.sh test_cases/light_client + bash test.sh test_cases/mocking + bash test.sh test_cases/node_compatible + bash test.sh test_cases/rpc + bash test.sh test_cases/soft_fork + bash test.sh test_cases/issue + bash test.sh test_cases/tx_pool_refactor + bash test.sh test_cases/feature @if test -n "$$(ls report/*failed.html 2>/dev/null)"; then \ echo "Error: Failed HTML files found in the 'report' directory"; \ exit 1; \ From a887800b65fdfe273418908ceb226a1a2202c61c Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Thu, 21 Mar 2024 16:17:32 +0800 Subject: [PATCH 09/33] makefile loop testcases --- Makefile | 36 ++++++++++++++++++++++-------------- test.sh | 13 +++++++++---- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index dec0c35..af21c7a 100644 --- a/Makefile +++ b/Makefile @@ -15,21 +15,29 @@ check_failed_html: echo "Error: Failed HTML files found in the 'report' directory"; \ exit 1; \ fi + test: - bash test.sh test_cases/replace_rpc - bash test.sh test_cases/ckb2023 - bash test.sh test_cases/ckb_cli - bash test.sh test_cases/contracts - bash test.sh test_cases/example - bash test.sh test_cases/framework - bash test.sh test_cases/light_client - bash test.sh test_cases/mocking - bash test.sh test_cases/node_compatible - bash test.sh test_cases/rpc - bash test.sh test_cases/soft_fork - bash test.sh test_cases/issue - bash test.sh test_cases/tx_pool_refactor - bash test.sh test_cases/feature + @for test_case in \ + test_cases/replace_rpc \ + test_cases/ckb2023 \ + test_cases/ckb_cli \ + test_cases/contracts \ + test_cases/example \ + test_cases/framework \ + test_cases/light_client \ + test_cases/mocking \ + test_cases/node_compatible \ + test_cases/rpc \ + test_cases/soft_fork \ + test_cases/issue \ + test_cases/tx_pool_refactor \ + test_cases/feature; \ + do \ + echo "Running tests for $$test_case"; \ + if ! bash test.sh "$$test_case"; then \ + exit 1; \ + fi; \ + done @if test -n "$$(ls report/*failed.html 2>/dev/null)"; then \ echo "Error: Failed HTML files found in the 'report' directory"; \ exit 1; \ diff --git a/test.sh b/test.sh index 529d061..a95431b 100644 --- a/test.sh +++ b/test.sh @@ -1,12 +1,17 @@ -python3 -m pytest $1 -x --exitfirst -if [ $? == 1 ];then +#!/bin/bash + +python3 -m pytest "$1" -x --exitfirst +pytest_exit_code=$? + +if [ "$pytest_exit_code" -ne 0 ]; then pkill ckb sleep 3 rm -rf tmp echo "run failed " - mv report/report.html report/${1////_}_failed.html - exit 1 + mv report/report.html "report/${1////_}_failed.html" + exit "$pytest_exit_code" fi + pkill ckb sleep 3 rm -rf tmp From 2ef082f0339ea733e43ca5ade3237d67c23c7227 Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Thu, 21 Mar 2024 17:00:38 +0800 Subject: [PATCH 10/33] makefile loop sats --- Makefile | 39 ++++++++++++++++++++------------------- test.sh | 6 ++++-- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index af21c7a..0ce9ac6 100644 --- a/Makefile +++ b/Makefile @@ -16,28 +16,29 @@ check_failed_html: exit 1; \ fi +test_cases := \ + test_cases/replace_rpc \ + test_cases/ckb2023 \ + test_cases/ckb_cli \ + test_cases/contracts \ + test_cases/example \ + test_cases/framework \ + test_cases/light_client \ + test_cases/mocking \ + test_cases/node_compatible \ + test_cases/rpc \ + test_cases/soft_fork \ + test_cases/issue \ + test_cases/tx_pool_refactor \ + test_cases/feature + +.PHONY: test test: - @for test_case in \ - test_cases/replace_rpc \ - test_cases/ckb2023 \ - test_cases/ckb_cli \ - test_cases/contracts \ - test_cases/example \ - test_cases/framework \ - test_cases/light_client \ - test_cases/mocking \ - test_cases/node_compatible \ - test_cases/rpc \ - test_cases/soft_fork \ - test_cases/issue \ - test_cases/tx_pool_refactor \ - test_cases/feature; \ - do \ + @for test_case in $(test_cases); do \ echo "Running tests for $$test_case"; \ - if ! bash test.sh "$$test_case"; then \ - exit 1; \ - fi; \ + bash test.sh "$$test_case" || true; \ done + @if test -n "$$(ls report/*failed.html 2>/dev/null)"; then \ echo "Error: Failed HTML files found in the 'report' directory"; \ exit 1; \ diff --git a/test.sh b/test.sh index a95431b..57db283 100644 --- a/test.sh +++ b/test.sh @@ -1,6 +1,6 @@ #!/bin/bash -python3 -m pytest "$1" -x --exitfirst +python3 -m pytest "$1" pytest_exit_code=$? if [ "$pytest_exit_code" -ne 0 ]; then @@ -8,7 +8,9 @@ if [ "$pytest_exit_code" -ne 0 ]; then sleep 3 rm -rf tmp echo "run failed " - mv report/report.html "report/${1////_}_failed.html" + if [ -e report/report.html ]; then + mv report/report.html "report/${1////_}_failed.html" + fi exit "$pytest_exit_code" fi From 30c6e34596adae1ad193f89d958a5ea13cd3e169 Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Thu, 21 Mar 2024 19:00:37 +0800 Subject: [PATCH 11/33] makefile loop sats fixed --- Makefile | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 0ce9ac6..bfdee74 100644 --- a/Makefile +++ b/Makefile @@ -18,29 +18,19 @@ check_failed_html: test_cases := \ test_cases/replace_rpc \ - test_cases/ckb2023 \ - test_cases/ckb_cli \ - test_cases/contracts \ - test_cases/example \ - test_cases/framework \ - test_cases/light_client \ - test_cases/mocking \ - test_cases/node_compatible \ - test_cases/rpc \ - test_cases/soft_fork \ - test_cases/issue \ - test_cases/tx_pool_refactor \ - test_cases/feature + test_cases/ckb_cli .PHONY: test test: - @for test_case in $(test_cases); do \ + @failed_cases=; \ + for test_case in $(test_cases); do \ echo "Running tests for $$test_case"; \ - bash test.sh "$$test_case" || true; \ - done - - @if test -n "$$(ls report/*failed.html 2>/dev/null)"; then \ - echo "Error: Failed HTML files found in the 'report' directory"; \ + if ! bash test.sh "$$test_case"; then \ + failed_cases+="$$test_case "; \ + fi; \ + done; \ + if [ -n "$$failed_cases" ]; then \ + echo "Some test cases failed: $$failed_cases"; \ exit 1; \ fi From 725672e71380495db8ee6efeec3e40460ea67cba Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Thu, 21 Mar 2024 19:09:58 +0800 Subject: [PATCH 12/33] makefile loop sats fixed --- Makefile | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index bfdee74..1fbef9f 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,19 @@ check_failed_html: test_cases := \ test_cases/replace_rpc \ - test_cases/ckb_cli + test_cases/ckb2023 \ + test_cases/ckb_cli \ + test_cases/contracts \ + test_cases/example \ + test_cases/framework \ + test_cases/light_client \ + test_cases/mocking \ + test_cases/node_compatible \ + test_cases/rpc \ + test_cases/soft_fork \ + test_cases/issue \ + test_cases/tx_pool_refactor \ + test_cases/feature .PHONY: test test: From 0d019bc2e1206759d4a5214df4f10792df80dad1 Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Fri, 29 Mar 2024 12:23:39 +0800 Subject: [PATCH 13/33] fix v112 node ckb toml and open html report --- pytest.ini | 4 ++-- source/template/ckb/v112/ckb.toml.j2 | 19 ------------------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/pytest.ini b/pytest.ini index 8c13aea..2255416 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,5 +1,5 @@ [pytest] ;ci -;addopts = --html=report/report.html +addopts = --html=report/report.html ;debug -addopts = -s +;addopts = -s diff --git a/source/template/ckb/v112/ckb.toml.j2 b/source/template/ckb/v112/ckb.toml.j2 index 5e00e7a..6aa00b2 100644 --- a/source/template/ckb/v112/ckb.toml.j2 +++ b/source/template/ckb/v112/ckb.toml.j2 @@ -179,25 +179,6 @@ block_uncles_cache_size = {{ ckb_store_block_uncles_cache_size | default(" # [indexer_v2] # # Indexing the pending txs in the ckb tx-pool # index_tx_pool = false - -# # Customize block filtering rules to index only retained blocks -block_filter = "block.header.number.to_uint() >= \"0x0\".to_uint()" -# # Customize cell filtering rules to index only retained cells -cell_filter = "let script = output.type;script!=() && script.code_hash == \"0x00000000000000000000000000000000000000000000000000545950455f4944\"" -# # The initial tip can be set higher than the current indexer tip as the starting height for indexing. -init_tip_hash = "0x8fbd0ec887159d2814cee475911600e3589849670f5ee1ed9798b38fdeef4e44" -# -# # CKB rich-indexer has its unique configuration. -[indexer_v2.rich_indexer] -# # By default, it uses an embedded SQLite database. -# # Alternatively, you can set up a PostgreSQL database service and provide the connection parameters. -# db_type = "postgres" -# db_name = "ckb-rich-indexer" -# db_host = "127.0.0.1" -# db_port = 5432 -# db_user = "postgres" -# db_password = "123456" - [block_assembler] code_hash = "{{ ckb_block_assembler_code_hash }}" args = "{{ ckb_block_assembler_args }}" From 1b1c0f483799f34d945a8c516bb221f29e36ae87 Mon Sep 17 00:00:00 2001 From: gpBlockchain <744158715@qq.com> Date: Fri, 29 Mar 2024 16:18:51 +0800 Subject: [PATCH 14/33] fix ci failed --- test_cases/feature/test_generate_epochs.py | 22 +++---------------- .../tx_pool_refactor/test_11_issue4363.py | 6 +++-- 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/test_cases/feature/test_generate_epochs.py b/test_cases/feature/test_generate_epochs.py index 35f64fd..6b68531 100644 --- a/test_cases/feature/test_generate_epochs.py +++ b/test_cases/feature/test_generate_epochs.py @@ -7,7 +7,7 @@ class TestGenerateEpochs(CkbTest): @classmethod def setup_class(cls): nodes = [ - cls.CkbNode.init_dev_by_port(cls.CkbNodeConfigPath.v114_rc3, + cls.CkbNode.init_dev_by_port(cls.CkbNodeConfigPath.CURRENT_TEST, "feature/gene_rate_epochs/node{i}".format(i=i), 8114 + i, 8225 + i) for @@ -17,9 +17,9 @@ def setup_class(cls): cls.ckb_spec_config_dict = read_toml_file(get_project_root() + "/" + cls.cluster.ckb_nodes[0].ckb_config_path.ckb_spec_path) cls.cluster.ckb_nodes[0].startWithRichIndexer() cls.cluster.ckb_nodes[1].start() - cls.Miner.make_tip_height_number(nodes[0], 1100) + cls.Miner.make_tip_height_number(nodes[0], 100) cls.cluster.connected_all_nodes() - cls.Node.wait_cluster_height(cls.cluster, 1100, 100) + cls.Node.wait_cluster_height(cls.cluster, 100, 1000) @classmethod def teardown_class(cls): @@ -27,20 +27,6 @@ def teardown_class(cls): cls.cluster.stop_all_nodes() cls.cluster.clean_all_nodes() - def test_demo(self): - """ - test - Returns: - - """ - miner_ACCOUNT= self.Ckb_cli.util_key_info_by_private_key(self.Config.MINER_PRIVATE_1) - self.Ckb_cli.wallet_get_capacity(miner_ACCOUNT["address"]["testnet"],self.cluster.ckb_nodes[0].getClient().url) - self.Ckb_cli.wallet_get_live_cells(miner_ACCOUNT["address"]["testnet"],self.cluster.ckb_nodes[0].getClient().url) - self.Ckb_cli.wallet_get_capacity(miner_ACCOUNT["address"]["testnet"], self.cluster.ckb_nodes[1].getClient().url) - self.Ckb_cli.wallet_get_live_cells(miner_ACCOUNT["address"]["testnet"], - self.cluster.ckb_nodes[1].getClient().url) - - def test_01_generate_epochs_0x2(self): """ 调用generate_epochs 生成2个epoch 的number; @@ -94,5 +80,3 @@ def parse_hex_string(hex_string): return None value = int(hex_string, 16) return EpochNumberWithFraction(value) - - diff --git a/test_cases/tx_pool_refactor/test_11_issue4363.py b/test_cases/tx_pool_refactor/test_11_issue4363.py index d546eee..21cbd0e 100644 --- a/test_cases/tx_pool_refactor/test_11_issue4363.py +++ b/test_cases/tx_pool_refactor/test_11_issue4363.py @@ -134,7 +134,8 @@ def test_01_4363(self): for tx_hash in tx22_list: response = self.node1.getClient().get_transaction(tx_hash) response2 = self.node2.getClient().get_transaction(tx_hash) - assert response['tx_status']['status'] == response2['tx_status']['status'] + # unknown: the transaction (tx) did not broadcast to node 2. + assert response2['tx_status']['status'] == 'rejected' or response2['tx_status']['status'] == 'unknown' assert response['tx_status']['status'] == 'rejected' # 7. 查询 tx3 报 PoolRejectedInvalidated @@ -142,5 +143,6 @@ def test_01_4363(self): for tx_hash in tx3_list: response = self.node1.getClient().get_transaction(tx_hash) response2 = self.node2.getClient().get_transaction(tx_hash) - assert response['tx_status']['status'] == response2['tx_status']['status'] + # unknown: the transaction (tx) did not broadcast to node 2. + assert response2['tx_status']['status'] == 'rejected' or response2['tx_status']['status'] == 'unknown' assert response['tx_status']['status'] == 'rejected' From 98c7f1af1f17aaa1c3ba7aa70d645292b4e9749e Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Fri, 29 Mar 2024 17:05:43 +0800 Subject: [PATCH 15/33] fix ci --- Makefile | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 1fbef9f..7213b30 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,17 @@ check_failed_html: exit 1; \ fi +failed_cases= + +define run_test + echo "Running tests for $1"; \ + if ! bash test.sh "$1"; then \ + failed_cases+="$1 "; \ + fi +endef + +.PHONY: test + test_cases := \ test_cases/replace_rpc \ test_cases/ckb2023 \ @@ -32,20 +43,17 @@ test_cases := \ test_cases/tx_pool_refactor \ test_cases/feature -.PHONY: test test: @failed_cases=; \ for test_case in $(test_cases); do \ - echo "Running tests for $$test_case"; \ - if ! bash test.sh "$$test_case"; then \ - failed_cases+="$$test_case "; \ - fi; \ + $(call run_test,$$test_case); \ done; \ if [ -n "$$failed_cases" ]; then \ echo "Some test cases failed: $$failed_cases"; \ exit 1; \ fi + clean: pkill ckb rm -rf tmp From f20a295522cbb32f0c81927fbf36333c9a095836 Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Fri, 29 Mar 2024 17:24:12 +0800 Subject: [PATCH 16/33] fix ci --- Makefile | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 7213b30..ef2688c 100644 --- a/Makefile +++ b/Makefile @@ -19,33 +19,34 @@ check_failed_html: failed_cases= define run_test - echo "Running tests for $1"; \ - if ! bash test.sh "$1"; then \ - failed_cases+="$1 "; \ + echo "Running tests for $$1"; \ + if ! bash test.sh "$$1"; then \ + failed_cases+="$$1 "; \ fi endef .PHONY: test test_cases := \ - test_cases/replace_rpc \ - test_cases/ckb2023 \ - test_cases/ckb_cli \ - test_cases/contracts \ - test_cases/example \ - test_cases/framework \ - test_cases/light_client \ - test_cases/mocking \ - test_cases/node_compatible \ - test_cases/rpc \ - test_cases/soft_fork \ - test_cases/issue \ - test_cases/tx_pool_refactor \ - test_cases/feature + "test_cases/replace_rpc" \ +# "test_cases/ckb2023" \ +# "test_cases/ckb_cli" \ +# "test_cases/contracts" \ +# "test_cases/example" \ +# "test_cases/framework" \ +# "test_cases/light_client" \ +# "test_cases/mocking" \ +# "test_cases/node_compatible" \ +# "test_cases/rpc" \ +# "test_cases/soft_fork" \ +# "test_cases/issue" \ +# "test_cases/tx_pool_refactor" \ +# "test_cases/feature" test: @failed_cases=; \ for test_case in $(test_cases); do \ + echo "DEBUG: Test case: $$test_case"; \ $(call run_test,$$test_case); \ done; \ if [ -n "$$failed_cases" ]; then \ @@ -54,6 +55,7 @@ test: fi + clean: pkill ckb rm -rf tmp From c01a39331ee042fe50f4e1f5f73b6bf5c90c84fd Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Fri, 29 Mar 2024 17:28:48 +0800 Subject: [PATCH 17/33] fix ci --- Makefile | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index ef2688c..83f8568 100644 --- a/Makefile +++ b/Makefile @@ -29,19 +29,19 @@ endef test_cases := \ "test_cases/replace_rpc" \ -# "test_cases/ckb2023" \ -# "test_cases/ckb_cli" \ -# "test_cases/contracts" \ -# "test_cases/example" \ -# "test_cases/framework" \ -# "test_cases/light_client" \ -# "test_cases/mocking" \ -# "test_cases/node_compatible" \ -# "test_cases/rpc" \ -# "test_cases/soft_fork" \ -# "test_cases/issue" \ -# "test_cases/tx_pool_refactor" \ -# "test_cases/feature" + "test_cases/ckb2023" \ + "test_cases/ckb_cli" \ + "test_cases/contracts" \ + "test_cases/example" \ + "test_cases/framework" \ + "test_cases/light_client" \ + "test_cases/mocking" \ + "test_cases/node_compatible" \ + "test_cases/rpc" \ + "test_cases/soft_fork" \ + "test_cases/issue" \ + "test_cases/tx_pool_refactor" \ + "test_cases/feature" test: @failed_cases=; \ From 6e16fda5a5aecac18f4be945e33eb72dc6fb17b7 Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Fri, 29 Mar 2024 17:43:35 +0800 Subject: [PATCH 18/33] fix ci --- Makefile | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 7213b30..a7c864b 100644 --- a/Makefile +++ b/Makefile @@ -19,33 +19,35 @@ check_failed_html: failed_cases= define run_test - echo "Running tests for $1"; \ - if ! bash test.sh "$1"; then \ - failed_cases+="$1 "; \ + echo "Running tests for $$1"; \ + cd $$1; \ + if ! bash ./test.sh; then \ + failed_cases+="$$1 "; \ fi endef .PHONY: test test_cases := \ - test_cases/replace_rpc \ - test_cases/ckb2023 \ - test_cases/ckb_cli \ - test_cases/contracts \ - test_cases/example \ - test_cases/framework \ - test_cases/light_client \ - test_cases/mocking \ - test_cases/node_compatible \ - test_cases/rpc \ - test_cases/soft_fork \ - test_cases/issue \ - test_cases/tx_pool_refactor \ - test_cases/feature + "test_cases/replace_rpc" \ + "test_cases/ckb2023" \ + "test_cases/ckb_cli" \ + "test_cases/contracts" \ + "test_cases/example" \ + "test_cases/framework" \ + "test_cases/light_client" \ + "test_cases/mocking" \ + "test_cases/node_compatible" \ + "test_cases/rpc" \ + "test_cases/soft_fork" \ + "test_cases/issue" \ + "test_cases/tx_pool_refactor" \ + "test_cases/feature" test: @failed_cases=; \ for test_case in $(test_cases); do \ + echo "DEBUG: Test case: $$test_case"; \ $(call run_test,$$test_case); \ done; \ if [ -n "$$failed_cases" ]; then \ From 508c17e48335a0af166b2abb776c44c96a7e81d3 Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Fri, 29 Mar 2024 17:51:14 +0800 Subject: [PATCH 19/33] fix ci add debug --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 83f8568..ca350c4 100644 --- a/Makefile +++ b/Makefile @@ -28,8 +28,8 @@ endef .PHONY: test test_cases := \ + "test_cases/ckb2023" \ "test_cases/replace_rpc" \ - "test_cases/ckb2023" \ "test_cases/ckb_cli" \ "test_cases/contracts" \ "test_cases/example" \ From ed04a13f8c163cef7b2ed75c7aa2303094c405bb Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Mon, 1 Apr 2024 18:24:55 +0800 Subject: [PATCH 20/33] test --- Makefile | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 1fbef9f..9927e8b 100644 --- a/Makefile +++ b/Makefile @@ -18,19 +18,19 @@ check_failed_html: test_cases := \ test_cases/replace_rpc \ - test_cases/ckb2023 \ test_cases/ckb_cli \ - test_cases/contracts \ - test_cases/example \ - test_cases/framework \ - test_cases/light_client \ - test_cases/mocking \ - test_cases/node_compatible \ - test_cases/rpc \ - test_cases/soft_fork \ - test_cases/issue \ - test_cases/tx_pool_refactor \ - test_cases/feature +# test_cases/ckb2023 \ +# test_cases/contracts \ +# test_cases/example \ +# test_cases/framework \ +# test_cases/light_client \ +# test_cases/mocking \ +# test_cases/node_compatible \ +# test_cases/rpc \ +# test_cases/soft_fork \ +# test_cases/issue \ +# test_cases/tx_pool_refactor \ +# test_cases/feature .PHONY: test test: From 861eeb3a58827bdea423a2b7f93ec48f04f2bc1b Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Mon, 1 Apr 2024 18:37:37 +0800 Subject: [PATCH 21/33] test 2 --- Makefile | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index da00c40..2df3323 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,5 @@ +.PHONY: prepare test clean docs + prepare: python3 -m venv venv . venv/bin/activate @@ -10,12 +12,6 @@ prepare: echo "install ckb cli" sh prepare.sh -check_failed_html: - @if test -n "$$(ls report/*failed.html 2>/dev/null)"; then \ - echo "Error: Failed HTML files found in the 'report' directory"; \ - exit 1; \ - fi - test_cases := \ test_cases/replace_rpc \ test_cases/ckb_cli \ @@ -31,37 +27,20 @@ test_cases := \ # test_cases/issue \ # test_cases/tx_pool_refactor \ # test_cases/feature -.PHONY: test - -test_cases := \ - "test_cases/ckb2023" \ -# "test_cases/replace_rpc" \ -# "test_cases/ckb_cli" \ -# "test_cases/contracts" \ -# "test_cases/example" \ -# "test_cases/framework" \ -# "test_cases/light_client" \ -# "test_cases/mocking" \ -# "test_cases/node_compatible" \ -# "test_cases/rpc" \ -# "test_cases/soft_fork" \ -# "test_cases/issue" \ -# "test_cases/tx_pool_refactor" \ -# "test_cases/feature" test: @failed_cases=; \ for test_case in $(test_cases); do \ - echo "DEBUG: Test case: $$test_case"; \ - $(call run_test,$$test_case); \ + echo "Running tests for $$test_case"; \ + if ! bash test.sh "$$test_case"; then \ + failed_cases+="$$test_case "; \ + fi \ done; \ if [ -n "$$failed_cases" ]; then \ echo "Some test cases failed: $$failed_cases"; \ exit 1; \ fi - - clean: pkill ckb rm -rf tmp @@ -71,4 +50,4 @@ clean: rm -rf ckb-* docs: - python -m pytest --docs=docs/soft.md --doc-type=md test_cases/soft_fork \ No newline at end of file + python -m pytest --docs=docs/soft.md --doc-type=md test_cases/soft_fork From 95fcaf707139cf3552aec2302cb438fa2f5ddb19 Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Mon, 1 Apr 2024 18:41:50 +0800 Subject: [PATCH 22/33] test 3 --- test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.sh b/test.sh index 57db283..65e50a5 100644 --- a/test.sh +++ b/test.sh @@ -1,6 +1,6 @@ #!/bin/bash -python3 -m pytest "$1" +python3 -m pytest -rs "$1" pytest_exit_code=$? if [ "$pytest_exit_code" -ne 0 ]; then From 073b9169263c9ceccbfac9921788ffd8bc210d8c Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Mon, 1 Apr 2024 18:44:47 +0800 Subject: [PATCH 23/33] test 4 --- Makefile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 2df3323..1cc9a61 100644 --- a/Makefile +++ b/Makefile @@ -29,18 +29,20 @@ test_cases := \ # test_cases/feature test: - @failed_cases=; \ + @failed_cases=; \ for test_case in $(test_cases); do \ echo "Running tests for $$test_case"; \ if ! bash test.sh "$$test_case"; then \ - failed_cases+="$$test_case "; \ + echo "$$test_case" >> failed_test_cases.txt; \ fi \ done; \ - if [ -n "$$failed_cases" ]; then \ - echo "Some test cases failed: $$failed_cases"; \ + if [ -s failed_test_cases.txt ]; then \ + echo "Some test cases failed: $$(cat failed_test_cases.txt)"; \ + rm -f failed_test_cases.txt; \ exit 1; \ fi + clean: pkill ckb rm -rf tmp From 52c467db1bb1918353836fe1c6e23b9175bf1b75 Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Mon, 1 Apr 2024 18:46:28 +0800 Subject: [PATCH 24/33] test 5 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1cc9a61..9c01f9b 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ test_cases := \ # test_cases/feature test: - @failed_cases=; \ + @failed_cases=; \ for test_case in $(test_cases); do \ echo "Running tests for $$test_case"; \ if ! bash test.sh "$$test_case"; then \ From 709230c77fc1dd3d32a224bb419b4754a8e502ef Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Mon, 1 Apr 2024 18:50:06 +0800 Subject: [PATCH 25/33] test 6 --- test.sh | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/test.sh b/test.sh index 65e50a5..868db92 100644 --- a/test.sh +++ b/test.sh @@ -1,21 +1,31 @@ #!/bin/bash -python3 -m pytest -rs "$1" -pytest_exit_code=$? +# Run pytest and capture the output +pytest_output=$(python3 -m pytest "$1") -if [ "$pytest_exit_code" -ne 0 ]; then +# Check if pytest output contains "skipped" +if echo "$pytest_output" | grep -q "skipped"; then + echo "Test case $1 was skipped" + exit 0 # Exit with success code +fi + +# Check if pytest exited with non-zero status +if [ $? -ne 0 ]; then + # Handle failed test case pkill ckb sleep 3 rm -rf tmp - echo "run failed " + echo "Test case $1 failed" if [ -e report/report.html ]; then mv report/report.html "report/${1////_}_failed.html" fi - exit "$pytest_exit_code" + exit 1 fi +# Handle successful test case pkill ckb sleep 3 rm -rf tmp rm -rf report/report.html -echo "run successful" +echo "Test case $1 passed" +exit 0 From 33bc112d48ebf2d8c47a498e83267d8844da4bb9 Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Mon, 1 Apr 2024 18:54:54 +0800 Subject: [PATCH 26/33] test 7 --- test.sh | 57 ++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/test.sh b/test.sh index 868db92..07ded53 100644 --- a/test.sh +++ b/test.sh @@ -1,31 +1,42 @@ #!/bin/bash -# Run pytest and capture the output -pytest_output=$(python3 -m pytest "$1") +# Function to run pytest and process the output +run_test() { + # Run pytest and capture the output + pytest_output=$(python3 -m pytest "$1") -# Check if pytest output contains "skipped" -if echo "$pytest_output" | grep -q "skipped"; then - echo "Test case $1 was skipped" - exit 0 # Exit with success code -fi + # Check if pytest output contains "skipped" + if echo "$pytest_output" | grep -q "skipped"; then + echo "Test case $1 was skipped" + return 0 # Exit with success code + fi + + # Check if pytest exited with non-zero status + if [ $? -ne 0 ]; then + # Handle failed test case + echo "Test case $1 failed" + pkill ckb + sleep 3 + rm -rf tmp + if [ -e report/report.html ]; then + mv report/report.html "report/${1////_}_failed.html" + fi + return 1 + fi -# Check if pytest exited with non-zero status -if [ $? -ne 0 ]; then - # Handle failed test case + # Handle successful test case + echo "Test case $1 passed" pkill ckb sleep 3 rm -rf tmp - echo "Test case $1 failed" - if [ -e report/report.html ]; then - mv report/report.html "report/${1////_}_failed.html" - fi - exit 1 -fi + rm -rf report/report.html + return 0 +} -# Handle successful test case -pkill ckb -sleep 3 -rm -rf tmp -rm -rf report/report.html -echo "Test case $1 passed" -exit 0 +# Main loop to run tests for each test case +for test_case in "$@"; do + run_test "$test_case" + if [ $? -ne 0 ]; then + exit 1 # Exit with error code if any test case fails + fi +done From 82f6af9a755e3c6293e5e7fd918eea142bd88ce2 Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Mon, 1 Apr 2024 18:58:52 +0800 Subject: [PATCH 27/33] test 8 --- Makefile | 24 ++++++++++++------------ test.sh | 14 +++++++++++--- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 9c01f9b..5c71619 100644 --- a/Makefile +++ b/Makefile @@ -15,18 +15,18 @@ prepare: test_cases := \ test_cases/replace_rpc \ test_cases/ckb_cli \ -# test_cases/ckb2023 \ -# test_cases/contracts \ -# test_cases/example \ -# test_cases/framework \ -# test_cases/light_client \ -# test_cases/mocking \ -# test_cases/node_compatible \ -# test_cases/rpc \ -# test_cases/soft_fork \ -# test_cases/issue \ -# test_cases/tx_pool_refactor \ -# test_cases/feature + test_cases/ckb2023 \ + test_cases/contracts \ + test_cases/example \ + test_cases/framework \ + test_cases/light_client \ + test_cases/mocking \ + test_cases/node_compatible \ + test_cases/rpc \ + test_cases/soft_fork \ + test_cases/issue \ + test_cases/tx_pool_refactor \ + test_cases/feature test: @failed_cases=; \ diff --git a/test.sh b/test.sh index 07ded53..c464f0a 100644 --- a/test.sh +++ b/test.sh @@ -1,5 +1,9 @@ #!/bin/bash +# Initialize variables to store passed and failed test cases +passed_cases="" +failed_cases="" + # Function to run pytest and process the output run_test() { # Run pytest and capture the output @@ -15,6 +19,7 @@ run_test() { if [ $? -ne 0 ]; then # Handle failed test case echo "Test case $1 failed" + failed_cases+=" $1" pkill ckb sleep 3 rm -rf tmp @@ -26,6 +31,7 @@ run_test() { # Handle successful test case echo "Test case $1 passed" + passed_cases+=" $1" pkill ckb sleep 3 rm -rf tmp @@ -36,7 +42,9 @@ run_test() { # Main loop to run tests for each test case for test_case in "$@"; do run_test "$test_case" - if [ $? -ne 0 ]; then - exit 1 # Exit with error code if any test case fails - fi done + +# Display summary of test results +echo "Summary:" +echo "Passed test cases:${passed_cases}" +echo "Failed test cases:${failed_cases}" From 7b0477c775c859181a7abb804c07d26dad8dab38 Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Mon, 1 Apr 2024 19:17:21 +0800 Subject: [PATCH 28/33] test again --- test.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/test.sh b/test.sh index c464f0a..6846b89 100644 --- a/test.sh +++ b/test.sh @@ -1,13 +1,9 @@ #!/bin/bash -# Initialize variables to store passed and failed test cases -passed_cases="" -failed_cases="" - # Function to run pytest and process the output run_test() { - # Run pytest and capture the output - pytest_output=$(python3 -m pytest "$1") + # Run pytest with verbose and no capture + pytest_output=$(python3 -m pytest -v -s "$1") # Check if pytest output contains "skipped" if echo "$pytest_output" | grep -q "skipped"; then From cd97448df44fb53168306c25dba30ae489a6a780 Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Mon, 1 Apr 2024 19:25:05 +0800 Subject: [PATCH 29/33] test again 2 --- test.sh | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/test.sh b/test.sh index 6846b89..16c0f24 100644 --- a/test.sh +++ b/test.sh @@ -1,5 +1,9 @@ #!/bin/bash +# Initialize variables to store passed and failed test cases +passed_cases="" +failed_cases="None" + # Function to run pytest and process the output run_test() { # Run pytest with verbose and no capture @@ -11,27 +15,17 @@ run_test() { return 0 # Exit with success code fi - # Check if pytest exited with non-zero status - if [ $? -ne 0 ]; then + # Check if pytest output contains "failed" + if echo "$pytest_output" | grep -q "failed"; then # Handle failed test case echo "Test case $1 failed" failed_cases+=" $1" - pkill ckb - sleep 3 - rm -rf tmp - if [ -e report/report.html ]; then - mv report/report.html "report/${1////_}_failed.html" - fi return 1 fi # Handle successful test case echo "Test case $1 passed" passed_cases+=" $1" - pkill ckb - sleep 3 - rm -rf tmp - rm -rf report/report.html return 0 } From d3cdabcd0ca4783d6f1b54ea8eda88f509e18a56 Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Mon, 1 Apr 2024 20:51:18 +0800 Subject: [PATCH 30/33] test again 3 --- test.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/test.sh b/test.sh index 16c0f24..483d857 100644 --- a/test.sh +++ b/test.sh @@ -31,6 +31,7 @@ run_test() { # Main loop to run tests for each test case for test_case in "$@"; do + echo "Running tests for $test_case" run_test "$test_case" done From 21a502875fe7c87f0919acd900052a76ee5487ad Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Mon, 1 Apr 2024 21:06:32 +0800 Subject: [PATCH 31/33] test output --- test.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test.sh b/test.sh index 483d857..cce318f 100644 --- a/test.sh +++ b/test.sh @@ -4,19 +4,23 @@ passed_cases="" failed_cases="None" +# Function to run pytest and process the output # Function to run pytest and process the output run_test() { - # Run pytest with verbose and no capture - pytest_output=$(python3 -m pytest -v -s "$1") + # Run pytest with verbose and no capture, redirect stderr to stdout + pytest_output=$(python3 -m pytest -vv "$1" 2>&1) + + # Print pytest output + echo "$pytest_output" # Check if pytest output contains "skipped" - if echo "$pytest_output" | grep -q "skipped"; then + if grep -q "skipped" <<< "$pytest_output"; then echo "Test case $1 was skipped" return 0 # Exit with success code fi # Check if pytest output contains "failed" - if echo "$pytest_output" | grep -q "failed"; then + if grep -q "failed" <<< "$pytest_output"; then # Handle failed test case echo "Test case $1 failed" failed_cases+=" $1" @@ -29,9 +33,9 @@ run_test() { return 0 } + # Main loop to run tests for each test case for test_case in "$@"; do - echo "Running tests for $test_case" run_test "$test_case" done From 3d9905d19abd8818b76014d22d988104f7fd7cc5 Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Mon, 1 Apr 2024 21:11:18 +0800 Subject: [PATCH 32/33] ckb v115.0 cycle test --- download.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/download.py b/download.py index 934296c..b95cfac 100644 --- a/download.py +++ b/download.py @@ -11,7 +11,7 @@ import requests from tqdm import tqdm -versions = ['0.109.0', '0.110.2', '0.111.0', '0.112.1', '0.113.1', "0.114.0", "0.115.0-rc2"] # Replace with your versions +versions = ['0.109.0', '0.110.2', '0.111.0', '0.112.1', '0.113.1', "0.114.0", "0.115.0"] # Replace with your versions DOWNLOAD_DIR = "download" From e3be219cbfbd499d556ace5fdb52ed2d324d4c1b Mon Sep 17 00:00:00 2001 From: gpBlockchain <744158715@qq.com> Date: Thu, 11 Apr 2024 13:42:06 +0800 Subject: [PATCH 33/33] add sync failed test --- test_cases/soft_fork/test_sync_failed.py | 85 ++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 test_cases/soft_fork/test_sync_failed.py diff --git a/test_cases/soft_fork/test_sync_failed.py b/test_cases/soft_fork/test_sync_failed.py new file mode 100644 index 0000000..af804dc --- /dev/null +++ b/test_cases/soft_fork/test_sync_failed.py @@ -0,0 +1,85 @@ +import time + +from framework.basic import CkbTest +from framework.util import run_command, get_project_root + +# use ckb0.110.1-rc1: generate DaoLockSizeMismatch tx in softfork before and after +DATA_ERROR_TAT = f"{get_project_root()}/source/data/data.err.tar.gz" + + +class TestSyncFailed(CkbTest): + + def teardown_method(self, method): + super().teardown_method(method) + print("\nTearing down method", method.__name__) + self.node1.stop() + self.node1.clean() + + self.node2.stop() + self.node2.clean() + + self.node3.stop() + self.node3.clean() + + def test_sync_other_node_again_after_failed(self): + """ + can't sync DaoLockSizeMismatch tx + - after softFork active + - starting_block_limiting_dao_withdrawing_lock <= dao deposit tx block number + 6000 block contains DaoLockSizeMismatch tx + 8669 block contains DaoLockSizeMismatch tx + 1. can sync 6000 block + tip block num > 6000 + 2. node2 and node3 can't sync 8669 block + tip block == 8668 + 3. node2 miner + 4. node2 restart and miner + 5. node1 stop + 6. link node2 and node3 + 7. node3 sync node2 successful + + Returns: + """ + node1 = self.CkbNode.init_dev_by_port(self.CkbNodeConfigPath.V110_MAIN, "tx_pool_test/node1", 8114, 8227) + node2 = self.CkbNode.init_dev_by_port(self.CkbNodeConfigPath.CURRENT_MAIN, "tx_pool_test/node2", 8112, 8228) + node3 = self.CkbNode.init_dev_by_port(self.CkbNodeConfigPath.CURRENT_MAIN, "tx_pool_test/node3", 8113, 8229) + self.node1 = node1 + self.node2 = node2 + self.node3 = node3 + node1.prepare(other_ckb_spec_config={"starting_block_limiting_dao_withdrawing_lock": "5494"}) + node2.prepare(other_ckb_spec_config={"starting_block_limiting_dao_withdrawing_lock": "5494"}) + node3.prepare(other_ckb_spec_config={"starting_block_limiting_dao_withdrawing_lock": "5494"}) + tar_file(DATA_ERROR_TAT, node1.ckb_dir) + node1.start() + node2.start() + node3.start() + self.Miner.make_tip_height_number(node1, 15000) + node1.start_miner() + node1.connected(node2) + node1.connected(node3) + self.Node.wait_node_height(self.node2, 8668, 120) + self.Node.wait_node_height(self.node3, 8668, 120) + block_num = self.node2.getClient().get_tip_block_number() + assert block_num == 8668 + time.sleep(10) + block_num = self.node2.getClient().get_tip_block_number() + assert block_num == 8668 + node2_banned_result = node2.getClient().get_banned_addresses() + node3_banned_result = node3.getClient().get_banned_addresses() + assert "BlockIsInvalid" in node2_banned_result[0]['ban_reason'] + assert "BlockIsInvalid" in node3_banned_result[0]['ban_reason'] + node1.stop() + node2.getClient().clear_banned_addresses() + node3.getClient().clear_banned_addresses() + self.Miner.make_tip_height_number(node2, 10000) + node2.restart() + self.node2.start_miner() + node2.connected(node3) + node3.connected(node2) + + self.Node.wait_node_height(self.node2, 10001, 120) + self.Node.wait_node_height(self.node3, 10001, 120) + + +def tar_file(src_tar, dec_data): + run_command(f"tar -xvf {src_tar} -C {dec_data}")