diff --git a/Makefile b/Makefile index 34bd856..915606c 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,6 @@ prepare: + python -m venv venv + . venv/bin/activate python -m pip install --upgrade pip pip install -r requirements.txt echo "install ckb" @@ -32,14 +34,14 @@ test: echo "Error: Failed HTML files found in the 'report' directory"; \ exit 1; \ fi + clean: - -pkill ckb + pkill ckb rm -rf tmp rm -rf download rm -rf report - rm -rf source/ckb-cli - rm -rf source/ckb-cli-old - + rm -rf source/ckb-cli* + rm -rf ckb-* docs: python -m pytest --docs=docs/soft.md --doc-type=md test_cases/soft_fork \ No newline at end of file diff --git a/download.py b/download.py index b3af8f9..57ecbe2 100644 --- a/download.py +++ b/download.py @@ -11,7 +11,8 @@ import requests from tqdm import tqdm -versions = ['0.109.0', '0.110.2', '0.111.0', '0.112.1', '0.113.1'] # Replace with your versions +versions = ['0.109.0', '0.110.2', '0.111.0', '0.112.1', '0.113.1', "0.114.0-rc3"] # Replace with your versions + DOWNLOAD_DIR = "download" SYSTEMS = { 'Windows': { diff --git a/download_ckb_light_client.py b/download_ckb_light_client.py index d21889f..ee2bac9 100644 --- a/download_ckb_light_client.py +++ b/download_ckb_light_client.py @@ -11,7 +11,9 @@ import requests from tqdm import tqdm -versions = ['0.2.4', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5'] # Replace with your versions + +versions = ['0.2.4', '0.3.0', '0.3.1', '0.3.2', '0.3.3', '0.3.4', '0.3.5', '0.3.6'] # Replace with your versions + DOWNLOAD_DIR = "download" SYSTEMS = { 'Windows': { diff --git a/framework/test_light_client.py b/framework/test_light_client.py index e53f41f..4486231 100644 --- a/framework/test_light_client.py +++ b/framework/test_light_client.py @@ -13,7 +13,9 @@ class CkbLightClientConfigPath(Enum): V0_3_3 = ("source/template/ckb_light_client/0.3.0/testnet.toml.j2", "download/0.3.3/ckb-light-client") V0_3_4 = ("source/template/ckb_light_client/0.3.0/testnet.toml.j2", "download/0.3.4/ckb-light-client") V0_3_5 = ("source/template/ckb_light_client/0.3.0/testnet.toml.j2", "download/0.3.5/ckb-light-client") - CURRENT_TEST = ("source/template/ckb_light_client/0.3.0/testnet.toml.j2", "download/0.3.5/ckb-light-client") + V0_3_6 = ("source/template/ckb_light_client/0.3.0/testnet.toml.j2", "download/0.3.6/ckb-light-client") + + CURRENT_TEST = ("source/template/ckb_light_client/0.3.0/testnet.toml.j2", "download/0.3.6/ckb-light-client") def __init__(self, ckb_light_client_config_path, ckb_light_bin_path): self.ckb_light_client_config_path = ckb_light_client_config_path diff --git a/framework/test_node.py b/framework/test_node.py index 90a2c97..b26ca26 100644 --- a/framework/test_node.py +++ b/framework/test_node.py @@ -10,15 +10,24 @@ class CkbNodeConfigPath(Enum): CURRENT_TEST = ( - "source/template/ckb/v113/ckb.toml.j2", + "source/template/ckb/v112/ckb.toml.j2", "source/template/ckb/v112/ckb-miner.toml.j2", "source/template/ckb/v112/specs/dev.toml", - "download/0.113.1" + "download/develop" ) CURRENT_MAIN = ("source/template/ckb/v112/ckb.toml.j2", "source/template/ckb/v112/ckb-miner.toml.j2", "source/template/specs/mainnet.toml.j2", - "download/0.113.1") + "download/develop") + + v114 = ( + "source/template/ckb/v114/ckb.toml.j2", + "source/template/ckb/v114/ckb-miner.toml.j2", + "source/template/ckb/v114/specs/dev.toml", + "download/0.114.0" + ) + + V113 = ( "source/template/ckb/v113/ckb.toml.j2", @@ -41,7 +50,6 @@ class CkbNodeConfigPath(Enum): "download/0.112.1" ) - V111 = ( "source/template/ckb/v111/ckb.toml.j2", "source/template/ckb/v111/ckb-miner.toml.j2", diff --git a/prepare.sh b/prepare.sh index e24b8df..9beb6e1 100644 --- a/prepare.sh +++ b/prepare.sh @@ -1,10 +1,18 @@ set -e git clone https://github.com/gpBlockchain/ckb-cli.git cd ckb-cli +git checkout v114 make prod cp target/release/ckb-cli ../source/ckb-cli cd ../ cp download/0.110.2/ckb-cli ./source/ckb-cli-old +git clone https://github.com/nervosnetwork/ckb.git +cd ckb +git checkout pkg/ckb-async-download-rc0 +make prod +cd ../ +cp -rf download/0.114.0 download/develop +cp ckb/target/prod/ckb download/develop/ckb #git clone https://github.com/quake/ckb-light-client.git #cd ckb-light-client #git checkout quake/fix-set-scripts-partial-bug diff --git a/requirements.txt b/requirements.txt index 2c10de7..fbfd3ab 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ pytest==7.3.2 requests==2.31.0 tqdm==4.65.0 pytest-html==3.2.0 -PyYAML==6.0 +PyYAML==6.0.1 pytest-docs==0.1.0 parameterized==0.9.0 toml==0.10.2 diff --git a/source/template/ckb/v113/specs/dev.toml b/source/template/ckb/v113/specs/dev.toml index a238e87..f25a259 100644 --- a/source/template/ckb/v113/specs/dev.toml +++ b/source/template/ckb/v113/specs/dev.toml @@ -94,7 +94,7 @@ genesis_epoch_length = 1000 permanent_difficulty_in_dummy = true [params.hardfork] -ckb2023 = 1000000 +ckb2023 = 1 [pow] func = "Dummy" diff --git a/test_cases/ckb2023/test_03_ckb_light_client_after_hardfork.py b/test_cases/ckb2023/test_03_ckb_light_client_after_hardfork.py index 0730282..da7cee2 100644 --- a/test_cases/ckb2023/test_03_ckb_light_client_after_hardfork.py +++ b/test_cases/ckb2023/test_03_ckb_light_client_after_hardfork.py @@ -34,8 +34,7 @@ def get_successful_files(): return [ f"{get_project_root()}/source/contract/test_cases/ckb_get_memory_limit", f"{get_project_root()}/source/contract/test_cases/atomic_i32", - f"{get_project_root()}/source/contract/test_cases/spawn_current_cycles", - f"{get_project_root()}/source/contract/test_cases/load_block_extension", + f"{get_project_root()}/source/contract/test_cases/spawn_current_cycles" ] @@ -71,6 +70,7 @@ def setup_class(cls): cls.ckb_light_node_current.getClient().set_scripts([{"script": { "code_hash": "0x9bd7e06f3ecf4be0f2fcd2188b23f1b9fcc88e5d4b65a8637b17723bbda3cce8", "hash_type": "type", "args": account['lock_arg']}, "script_type": "lock", "block_number": "0x0"}]) + cls.cluster.ckb_nodes[0].start_miner() cls.Node.wait_light_sync_height(cls.ckb_light_node_current, 2000, 200) @@ -102,6 +102,7 @@ def test_01_ckb_light_client_0_3_1_link_node(self): ckb_light_node.stop() ckb_light_node.clean() + def test_02_ckb_light_client_current_link_node(self): """ 1. setScript miner account @@ -117,6 +118,7 @@ def test_02_ckb_light_client_current_link_node(self): "args": account['lock_arg']}, "script_type": "lock", "block_number": "0x0"}]) self.Node.wait_light_sync_height(self.ckb_light_node_current, 2000, 200) + def test_03_ckb_light_client_current_set_script_data2(self): """ 1. set data2 account @@ -130,6 +132,7 @@ def test_03_ckb_light_client_current_set_script_data2(self): "args": account['lock_arg']}, "script_type": "lock", "block_number": "0x0"}]) self.Node.wait_light_sync_height(self.ckb_light_node_current, 2000, 200) + def test_04_ckb_light_client_current_transfer_data2_tx(self): """ 1. send data2 tx on the ckb light client @@ -143,6 +146,7 @@ def test_04_ckb_light_client_current_transfer_data2_tx(self): "args": account['lock_arg']}, "script_type": "lock", "block_number": "0x0"}]) self.Node.wait_light_sync_height(self.ckb_light_node_current, 2000, 200) + tx_hash = self.Ckb_cli.wallet_transfer_by_private_key(self.Config.MINER_PRIVATE_1, "ckt1qp5usrt2syzfjj7acyetk45vj57kp7hq4jfg4ky8e9k7ss6v52neqpqh7xtq0", 140, @@ -155,6 +159,7 @@ def test_04_ckb_light_client_current_transfer_data2_tx(self): assert tx_hash == light_tx_hash + def test_05_ckb_light_client_current_spawn_contract_use_data2(self): """ 1. send spawn tx ( hash type : data2), on the ckb light client @@ -188,6 +193,7 @@ def test_05_ckb_light_client_current_spawn_contract_use_data2(self): assert tx_hash == light_tx_hash + def test_05_ckb_light_client_current_spawn_contract_use_type(self): """ 1. send spawn tx ( hash type : type), on the ckb light client @@ -220,17 +226,11 @@ def test_05_ckb_light_client_current_spawn_contract_use_type(self): assert tx_hash == light_tx_hash # @pytest.mark.skip - @parameterized.expand(success_files) - def test_06_ckb_light_client_deploy_and_invoke_contract(self, path): - self.cluster.ckb_nodes[0].start_miner() - self.deploy_and_invoke(self.Config.MINER_PRIVATE_1, path, self.cluster.ckb_nodes[0]) - self.cluster.ckb_nodes[0].start_miner() - - # def test_07_ckb_light_client_deploy_and_invoke_contract(self): + # @parameterized.expand(success_files) + # def test_06_ckb_light_client_deploy_and_invoke_contract(self, path): + # self.cluster.ckb_nodes[0].start_miner() + # self.deploy_and_invoke(self.Config.MINER_PRIVATE_1, path, self.cluster.ckb_nodes[0]) # self.cluster.ckb_nodes[0].start_miner() - # self.deploy_and_invoke(self.Config.MINER_PRIVATE_1, - # f"{get_project_root()}/source/contract/test_cases/spawn_demo", self.cluster.ckb_nodes[0]) - # self.cluster.ckb_nodes[0].stop_miner() def deploy_and_invoke(self, account, path, node, try_count=5): if try_count < 0: @@ -241,6 +241,7 @@ def deploy_and_invoke(self, account, path, node, try_count=5): enable_type_id=True, api_url=node.getClient().url) self.Miner.miner_until_tx_committed(node, deploy_hash) + self.Node.wait_light_sync_height(self.ckb_light_node_current, node.getClient().get_tip_block_number(), 200) self.Node.wait_fetch_transaction(self.ckb_light_node_current, deploy_hash, "fetched") tx_msg = self.Contract.build_invoke_ckb_contract(account_private=account, @@ -250,8 +251,8 @@ def deploy_and_invoke(self, account, path, node, try_count=5): hash_type="type", api_url=node.getClient().url) self.Node.wait_light_sync_height(self.ckb_light_node_current, node.getClient().get_tip_block_number(), 200) + light_tx_hash = self.ckb_light_node_current.getClient().send_transaction(tx_msg) for i in range(100): - light_tx_hash = self.ckb_light_node_current.getClient().send_transaction(tx_msg) light_ret = node.getClient().get_transaction(light_tx_hash) time.sleep(1) print("light ret status:", light_ret['tx_status']['status']) diff --git a/test_cases/ckb2023/test_04_ckb_light_client_before_hardfork.py b/test_cases/ckb2023/test_04_ckb_light_client_before_hardfork.py index bfcd68e..378cee9 100644 --- a/test_cases/ckb2023/test_04_ckb_light_client_before_hardfork.py +++ b/test_cases/ckb2023/test_04_ckb_light_client_before_hardfork.py @@ -71,8 +71,8 @@ def deploy_and_invoke(self, account, path, node, try_count=5): hash_type="type", api_url=node.getClient().url) self.Node.wait_light_sync_height(self.ckb_light_node_current, node.getClient().get_tip_block_number(), 200) + light_tx_hash = self.ckb_light_node_current.getClient().send_transaction(tx_msg) for i in range(100): - light_tx_hash = self.ckb_light_node_current.getClient().send_transaction(tx_msg) light_ret = node.getClient().get_transaction(light_tx_hash) time.sleep(1) print("light ret status:", light_ret['tx_status']['status']) diff --git a/test_cases/issue/test_4111.py b/test_cases/issue/test_4111.py index 0f65444..8f4103b 100644 --- a/test_cases/issue/test_4111.py +++ b/test_cases/issue/test_4111.py @@ -60,7 +60,6 @@ def deploy_and_invoke(self, account, path, node, try_count=5): api_url=node.getClient().url, fee=-100) return invoke_hash except Exception as e: - print("!!!e:", e) if "Resolve failed Dead" in e.args[0]: try_count -= 1 time.sleep(3) diff --git a/test_cases/replace_rpc/test_rpc.py b/test_cases/replace_rpc/test_rpc.py index 18b84df..1c8533c 100644 --- a/test_cases/replace_rpc/test_rpc.py +++ b/test_cases/replace_rpc/test_rpc.py @@ -166,7 +166,9 @@ def test_websocket(self): # 113 support with pytest.raises(Exception) as exc_info: socket = self.node113.subscribe_websocket("new_tip_header", self.node113.rpcUrl.replace("http://", "")) + expected_error_message = "not allowed. POST or OPTIONS is required" + assert expected_error_message in exc_info.value.args[0], \ f"Expected substring '{expected_error_message}' not found in actual string '{exc_info.value.args[0]}'" diff --git a/test_cases/replace_rpc/test_telnet.py b/test_cases/replace_rpc/test_telnet.py index 22c4aba..9d9a5de 100644 --- a/test_cases/replace_rpc/test_telnet.py +++ b/test_cases/replace_rpc/test_telnet.py @@ -170,9 +170,9 @@ def test_unsubscribe(self): unsubscribe topic 1 unsubscribe successful """ + client = self.node113.getClient() client.url = f"http://{self.node113.ckb_config['ckb_rpc_listen_address']}" - socket = self.node113.subscribe_telnet("new_tip_header") self.Miner.miner_with_version(self.node113, "0x0") ret = socket.read_very_eager() diff --git a/test_cases/rpc/test_get_cells.py b/test_cases/rpc/test_get_cells.py new file mode 100644 index 0000000..b3434ac --- /dev/null +++ b/test_cases/rpc/test_get_cells.py @@ -0,0 +1,95 @@ +from framework.helper.contract import deploy_ckb_contract, invoke_ckb_contract, get_ckb_contract_codehash +from framework.util import get_project_root +from framework.config import MINER_PRIVATE_1 +from framework.helper.miner import miner_until_tx_committed +from test_cases.rpc.node_fixture import get_cluster + + +class TestGetCells: + + def test_get_cells_output_data_filter_mode(self, get_cluster): + cluster = get_cluster + deploy_hash = deploy_ckb_contract(MINER_PRIVATE_1, + f"{get_project_root()}/source/contract/always_success", + enable_type_id=True, + api_url=cluster.ckb_nodes[0].getClient().url) + miner_until_tx_committed(cluster.ckb_nodes[0], deploy_hash) + for i in range(1, 10): + invoke_hash = invoke_ckb_contract(account_private=MINER_PRIVATE_1, + contract_out_point_tx_hash=deploy_hash, + contract_out_point_tx_index=0, + type_script_arg="0x02", data=f"0x{i:02x}{i:02x}", + hash_type="type", + api_url=cluster.ckb_nodes[0].getClient().url) + miner_until_tx_committed(cluster.ckb_nodes[0], invoke_hash) + invoke_hash = invoke_ckb_contract(account_private=MINER_PRIVATE_1, + contract_out_point_tx_hash=deploy_hash, + contract_out_point_tx_index=0, + type_script_arg="0x02", data="0xffff00000000ffff", + hash_type="type", + api_url=cluster.ckb_nodes[0].getClient().url) + miner_until_tx_committed(cluster.ckb_nodes[0], invoke_hash) + + codehash = get_ckb_contract_codehash(deploy_hash, 0, + enable_type_id=True, + api_url=cluster.ckb_nodes[0].getClient().url) + + # output_data_filter_mode : prefix + + ret = cluster.ckb_nodes[0].getClient().get_cells({ + "script": { + "code_hash": codehash, + "hash_type": "type", + "args": "0x02" + }, + "script_type": "type", + "filter": { + "output_data": "0x01", + "output_data_filter_mode": "prefix" + } + }, "asc", "0xff", None) + + assert ret['objects'][0]['output_data'] == '0x0101' + ret = cluster.ckb_nodes[0].getClient().get_cells({ + "script": { + "code_hash": codehash, + "hash_type": "type", + "args": "0x02" + }, + "script_type": "type", + "filter": { + "output_data": "0x02", + "output_data_filter_mode": "prefix" + } + }, "asc", "0xff", None) + assert ret['objects'][0]['output_data'] == '0x0202' + + # output_data_filter_mode : exact + ret = cluster.ckb_nodes[0].getClient().get_cells({ + "script": { + "code_hash": codehash, + "hash_type": "type", + "args": "0x02" + }, + "script_type": "type", + "filter": { + "output_data": "0x0303", + "output_data_filter_mode": "exact" + } + }, "asc", "0xff", None) + assert ret['objects'][0]['output_data'] == '0x0303' + + # output_data_filter_mode : partial + ret = cluster.ckb_nodes[0].getClient().get_cells({ + "script": { + "code_hash": codehash, + "hash_type": "type", + "args": "0x02" + }, + "script_type": "type", + "filter": { + "output_data": "0x00000000ffff", + "output_data_filter_mode": "partial" + } + }, "asc", "0xff", None) + assert ret['objects'][0]['output_data'] == '0xffff00000000ffff' diff --git a/test_cases/rpc/test_get_cells_capacity.py b/test_cases/rpc/test_get_cells_capacity.py new file mode 100644 index 0000000..e5c319f --- /dev/null +++ b/test_cases/rpc/test_get_cells_capacity.py @@ -0,0 +1,148 @@ +from framework.helper.contract import deploy_ckb_contract, invoke_ckb_contract, get_ckb_contract_codehash +from framework.util import get_project_root +from framework.config import MINER_PRIVATE_1 +from framework.helper.miner import miner_until_tx_committed +from test_cases.rpc.node_fixture import get_cluster + + +class TestGetCellsCapacity: + + def test_get_cells_capacity_output_data_filter_mode(self, get_cluster): + cluster = get_cluster + deploy_hash = deploy_ckb_contract(MINER_PRIVATE_1, + f"{get_project_root()}/source/contract/always_success", + enable_type_id=True, + api_url=cluster.ckb_nodes[0].getClient().url) + miner_until_tx_committed(cluster.ckb_nodes[0], deploy_hash) + for i in range(1, 10): + invoke_hash = invoke_ckb_contract(account_private=MINER_PRIVATE_1, + contract_out_point_tx_hash=deploy_hash, + contract_out_point_tx_index=0, + type_script_arg="0x02", data=f"0x{i:02x}{i:02x}", + hash_type="type", + api_url=cluster.ckb_nodes[0].getClient().url) + miner_until_tx_committed(cluster.ckb_nodes[0], invoke_hash) + invoke_hash = invoke_ckb_contract(account_private=MINER_PRIVATE_1, + contract_out_point_tx_hash=deploy_hash, + contract_out_point_tx_index=0, + type_script_arg="0x02", data="0xffff00000000ffff", + hash_type="type", + api_url=cluster.ckb_nodes[0].getClient().url) + miner_until_tx_committed(cluster.ckb_nodes[0], invoke_hash) + + codehash = get_ckb_contract_codehash(deploy_hash, 0, + enable_type_id=True, + api_url=cluster.ckb_nodes[0].getClient().url) + # output_data_filter_mode : prefix + + ret = cluster.ckb_nodes[0].getClient().get_cells({ + "script": { + "code_hash": codehash, + "hash_type": "type", + "args": "0x02" + }, + "script_type": "type", + "filter": { + "output_data": "0x01", + "output_data_filter_mode": "prefix" + } + }, "asc", "0xff", None) + + get_cells_capacity_ret = cluster.ckb_nodes[0].getClient().get_cells_capacity({ + "script": { + "code_hash": codehash, + "hash_type": "type", + "args": "0x02" + }, + "script_type": "type", + "filter": { + "output_data": "0x01", + "output_data_filter_mode": "prefix" + } + }) + + assert ret['objects'][0]['output_data'] == '0x0101' + assert get_cells_capacity_ret['capacity'] == ret['objects'][0]['output']['capacity'] + + ret = cluster.ckb_nodes[0].getClient().get_cells({ + "script": { + "code_hash": codehash, + "hash_type": "type", + "args": "0x02" + }, + "script_type": "type", + "filter": { + "output_data": "0x02", + "output_data_filter_mode": "prefix" + } + }, "asc", "0xff", None) + get_cells_capacity_ret = cluster.ckb_nodes[0].getClient().get_cells_capacity({ + "script": { + "code_hash": codehash, + "hash_type": "type", + "args": "0x02" + }, + "script_type": "type", + "filter": { + "output_data": "0x02", + "output_data_filter_mode": "prefix" + } + }) + assert ret['objects'][0]['output_data'] == '0x0202' + assert get_cells_capacity_ret['capacity'] == ret['objects'][0]['output']['capacity'] + + # output_data_filter_mode : exact + ret = cluster.ckb_nodes[0].getClient().get_cells({ + "script": { + "code_hash": codehash, + "hash_type": "type", + "args": "0x02" + }, + "script_type": "type", + "filter": { + "output_data": "0x0303", + "output_data_filter_mode": "exact" + } + }, "asc", "0xff", None) + get_cells_capacity_ret = cluster.ckb_nodes[0].getClient().get_cells_capacity({ + "script": { + "code_hash": codehash, + "hash_type": "type", + "args": "0x02" + }, + "script_type": "type", + "filter": { + "output_data": "0x0303", + "output_data_filter_mode": "exact" + } + }) + assert ret['objects'][0]['output_data'] == '0x0303' + assert get_cells_capacity_ret['capacity'] == ret['objects'][0]['output']['capacity'] + + # output_data_filter_mode : partial + ret = cluster.ckb_nodes[0].getClient().get_cells({ + "script": { + "code_hash": codehash, + "hash_type": "type", + "args": "0x02" + }, + "script_type": "type", + "filter": { + "output_data": "0x00000000ffff", + "output_data_filter_mode": "partial" + } + }, "asc", "0xff", None) + get_cells_capacity_ret = cluster.ckb_nodes[0].getClient().get_cells_capacity({ + "script": { + "code_hash": codehash, + "hash_type": "type", + "args": "0x02" + }, + "script_type": "type", + "filter": { + "output_data": "0x00000000ffff", + "output_data_filter_mode": "partial" + } + }) + assert ret['objects'][0]['output_data'] == '0xffff00000000ffff' + assert get_cells_capacity_ret['capacity'] == ret['objects'][0]['output']['capacity'] diff --git a/test_cases/rpc/test_get_transaction.py b/test_cases/rpc/test_get_transaction.py index 47c1ad1..f89225b 100644 --- a/test_cases/rpc/test_get_transaction.py +++ b/test_cases/rpc/test_get_transaction.py @@ -25,9 +25,9 @@ def test_query_tx_only_commit_is_true(self, get_cluster): cluster = get_cluster account1 = CkbTest.Ckb_cli.util_key_info_by_private_key(CkbTest.Config.ACCOUNT_PRIVATE_1) tx_hash = CkbTest.Ckb_cli.wallet_transfer_by_private_key(CkbTest.Config.ACCOUNT_PRIVATE_1, - account1["address"]["testnet"], - 140, - cluster.ckb_nodes[0].client.url) + account1["address"]["testnet"], + 140, + cluster.ckb_nodes[0].client.url) # pending tx response_enable_commit = cluster.ckb_nodes[0].getClient().get_transaction(tx_hash, None, True) @@ -74,9 +74,9 @@ def test_query_tx_without_only_commit(self, get_cluster): cluster = get_cluster account1 = CkbTest.Ckb_cli.util_key_info_by_private_key(CkbTest.Config.ACCOUNT_PRIVATE_1) tx_hash = CkbTest.Ckb_cli.wallet_transfer_by_private_key(CkbTest.Config.ACCOUNT_PRIVATE_1, - account1["address"]["testnet"], - 140, - cluster.ckb_nodes[0].client.url) + account1["address"]["testnet"], + 140, + cluster.ckb_nodes[0].client.url) # pending tx response_use_default = cluster.ckb_nodes[0].getClient().get_transaction(tx_hash) @@ -84,3 +84,32 @@ def test_query_tx_without_only_commit(self, get_cluster): assert response['tx_status']['status'] == "pending" assert response_use_default['tx_status']['status'] == "pending" CkbTest.Miner.miner_until_tx_committed(cluster.ckb_nodes[0], tx_hash) + + def test_tx_status_with_cell_base_tx(self, get_cluster): + """ + https://github.com/nervosnetwork/ckb/pull/4283 + """ + cluster = get_cluster + tip_number = cluster.ckb_nodes[0].getClient().get_tip_block_number() + block = cluster.ckb_nodes[0].getClient().get_block_by_number(hex(tip_number)) + tx = cluster.ckb_nodes[0].getClient().get_transaction(block['transactions'][0]['hash']) + assert tx['tx_status']['block_number'] == hex(tip_number) + assert tx['tx_status']['block_hash'] == block['header']['hash'] + + def test_tx_status_normal_tx(self, get_cluster): + cluster = get_cluster + account1 = CkbTest.Ckb_cli.util_key_info_by_private_key(CkbTest.Config.ACCOUNT_PRIVATE_1) + tx_hash = CkbTest.Ckb_cli.wallet_transfer_by_private_key(CkbTest.Config.ACCOUNT_PRIVATE_1, + account1["address"]["testnet"], + 140, + cluster.ckb_nodes[0].client.url) + + # pending tx + response_use_default = cluster.ckb_nodes[0].getClient().get_transaction(tx_hash) + response = cluster.ckb_nodes[0].getClient().get_transaction(tx_hash, None, False) + assert response['tx_status']['status'] == "pending" + assert response_use_default['tx_status']['status'] == "pending" + CkbTest.Miner.miner_until_tx_committed(cluster.ckb_nodes[0], tx_hash) + tx = cluster.ckb_nodes[0].getClient().get_transaction(tx_hash) + block_hash = cluster.ckb_nodes[0].getClient().get_block_hash(tx['tx_status']['block_number']) + assert block_hash == tx['tx_status']['block_hash'] \ No newline at end of file diff --git a/test_cases/tx_pool_refactor/test_10_issues.py b/test_cases/tx_pool_refactor/test_10_issues.py index 21cb15f..6f72e49 100644 --- a/test_cases/tx_pool_refactor/test_10_issues.py +++ b/test_cases/tx_pool_refactor/test_10_issues.py @@ -18,7 +18,6 @@ def teardown_class(cls): cls.node1.stop() cls.node1.clean() - @pytest.mark.skip def test_4315(self): """ 1. 发送 tx1