From 4e58b2f05395b392561a3bf9b443fa41bee749f0 Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Wed, 14 Aug 2024 15:34:01 +0800 Subject: [PATCH 1/6] support tx index in tx status --- test_cases/feature/test_get_live_cell.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/test_cases/feature/test_get_live_cell.py b/test_cases/feature/test_get_live_cell.py index 6592812..a9db14a 100644 --- a/test_cases/feature/test_get_live_cell.py +++ b/test_cases/feature/test_get_live_cell.py @@ -38,7 +38,6 @@ def test_get_live_cell_with_unspend(self): Returns: """ - # 1. get cells and tx is pending and with unspend account = self.Ckb_cli.util_key_info_by_private_key(self.Config.MINER_PRIVATE_1) tx_hash = self.Ckb_cli.wallet_transfer_by_private_key( self.Config.MINER_PRIVATE_1, @@ -48,7 +47,6 @@ def test_get_live_cell_with_unspend(self): "1500", ) print(f"txHash:{tx_hash}") - # 2. query cell status will be live transaction = self.node.getClient().get_transaction(tx_hash) result = self.node.getClient().get_live_cell_with_include_tx_pool( transaction["transaction"]["inputs"][0]["previous_output"]["index"], @@ -58,10 +56,8 @@ def test_get_live_cell_with_unspend(self): def test_get_live_cell_with_spend(self): """ - 1. generate account and build normal tx - 2. get live cells and cell is spend - 3. send link tx and test_tx_pool_accept check success - 4. query cell status will be unknown + 1. get live cells and cell is spend + 2. query cell status will be unknown Returns: """ @@ -69,7 +65,6 @@ def test_get_live_cell_with_spend(self): account = self.Ckb_cli.util_key_info_by_private_key( self.Config.ACCOUNT_PRIVATE_1 ) - # 2. get live cells and cell is spend father_tx_hash = self.Ckb_cli.wallet_transfer_by_private_key( self.Config.ACCOUNT_PRIVATE_1, account["address"]["testnet"], @@ -78,7 +73,7 @@ def test_get_live_cell_with_spend(self): "1500000", ) tx_hash = father_tx_hash - # 3. send link tx and test_tx_pool_accept check success + # 2. send link tx and test_tx_pool_accept check success for i in range(3): tx = self.Tx.build_send_transfer_self_tx_with_input( [tx_hash], @@ -96,5 +91,4 @@ def test_get_live_cell_with_spend(self): transaction["transaction"]["inputs"][0]["previous_output"]["tx_hash"], include_tx_pool=True, ) - # 4. query cell status will be unknown assert result["status"] == "unknown" From 77dd0b3938c7f6e2d9f62c89ba3566a74bab1d60 Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Tue, 25 Jun 2024 16:34:33 +0800 Subject: [PATCH 2/6] update comment --- test_cases/feature/test_get_live_cell.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test_cases/feature/test_get_live_cell.py b/test_cases/feature/test_get_live_cell.py index a9db14a..6592812 100644 --- a/test_cases/feature/test_get_live_cell.py +++ b/test_cases/feature/test_get_live_cell.py @@ -38,6 +38,7 @@ def test_get_live_cell_with_unspend(self): Returns: """ + # 1. get cells and tx is pending and with unspend account = self.Ckb_cli.util_key_info_by_private_key(self.Config.MINER_PRIVATE_1) tx_hash = self.Ckb_cli.wallet_transfer_by_private_key( self.Config.MINER_PRIVATE_1, @@ -47,6 +48,7 @@ def test_get_live_cell_with_unspend(self): "1500", ) print(f"txHash:{tx_hash}") + # 2. query cell status will be live transaction = self.node.getClient().get_transaction(tx_hash) result = self.node.getClient().get_live_cell_with_include_tx_pool( transaction["transaction"]["inputs"][0]["previous_output"]["index"], @@ -56,8 +58,10 @@ def test_get_live_cell_with_unspend(self): def test_get_live_cell_with_spend(self): """ - 1. get live cells and cell is spend - 2. query cell status will be unknown + 1. generate account and build normal tx + 2. get live cells and cell is spend + 3. send link tx and test_tx_pool_accept check success + 4. query cell status will be unknown Returns: """ @@ -65,6 +69,7 @@ def test_get_live_cell_with_spend(self): account = self.Ckb_cli.util_key_info_by_private_key( self.Config.ACCOUNT_PRIVATE_1 ) + # 2. get live cells and cell is spend father_tx_hash = self.Ckb_cli.wallet_transfer_by_private_key( self.Config.ACCOUNT_PRIVATE_1, account["address"]["testnet"], @@ -73,7 +78,7 @@ def test_get_live_cell_with_spend(self): "1500000", ) tx_hash = father_tx_hash - # 2. send link tx and test_tx_pool_accept check success + # 3. send link tx and test_tx_pool_accept check success for i in range(3): tx = self.Tx.build_send_transfer_self_tx_with_input( [tx_hash], @@ -91,4 +96,5 @@ def test_get_live_cell_with_spend(self): transaction["transaction"]["inputs"][0]["previous_output"]["tx_hash"], include_tx_pool=True, ) + # 4. query cell status will be unknown assert result["status"] == "unknown" From 98f062f4dae4375fc9299368b3f255979ed21588 Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Wed, 14 Aug 2024 15:35:49 +0800 Subject: [PATCH 3/6] support tx index in tx status --- prepare.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/prepare.sh b/prepare.sh index b23dd3a..a112c51 100644 --- a/prepare.sh +++ b/prepare.sh @@ -1,4 +1,10 @@ set -e +# git clone https://github.com/nervosnetwork/ckb-cli.git +# cd ckb-cli +# git checkout pkg/v1.7.0 +# make prod +# cp target/release/ckb-cli ../source/ckb-cli +# cd ../ cp download/0.110.2/ckb-cli ./source/ckb-cli-old cp download/0.117.0/ckb-cli ./source/ckb-cli #git clone https://github.com/quake/ckb-light-client.git From 2895d792e7b17ccf884502bf212d797bc56b0fb5 Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Wed, 14 Aug 2024 15:50:59 +0800 Subject: [PATCH 4/6] support tx index in tx status --- test_cases/feature/test_get_transaction.py | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 test_cases/feature/test_get_transaction.py diff --git a/test_cases/feature/test_get_transaction.py b/test_cases/feature/test_get_transaction.py new file mode 100644 index 0000000..e5dad47 --- /dev/null +++ b/test_cases/feature/test_get_transaction.py @@ -0,0 +1,62 @@ +from framework.basic import CkbTest +import pytest + + +class TestGetTransaction(CkbTest): + + @classmethod + def setup_class(cls): + """ + 1. start 1 ckb node in tmp/get_transaction/node1 node dir + 2. miner 100block + Returns: + + """ + # 1. start 1 ckb node in tmp/get_transaction/node1 node dir + cls.node = cls.CkbNode.init_dev_by_port( + cls.CkbNodeConfigPath.develop, "get_transaction/node1", 8120, 8225 + ) + cls.node.prepare(other_ckb_config={"ckb_tx_pool_max_tx_pool_size": "180_000"}) + cls.node.start() + # 2. miner 100 block + cls.Miner.make_tip_height_number(cls.node, 100) + + @classmethod + def teardown_class(cls): + """ + 1. stop ckb node + 2. clean ckb node tmp dir + Returns: + + """ + cls.node.stop() + cls.node.clean() + + # @pytest.mark.skip("util v118 rc") + def test_get_transaction_by_tx_index(self): + """ + 1. new tx in block + 2. query tx index is null + 3. miner block until tx committed, query tx index is 0x1 + Returns: + + """ + # 1. new tx in block + account = self.Ckb_cli.util_key_info_by_private_key(self.Config.MINER_PRIVATE_1) + tx_hash = self.Ckb_cli.wallet_transfer_by_private_key( + self.Config.MINER_PRIVATE_1, + account["address"]["testnet"], + 100, + self.node.getClient().url, + "1500", + ) + print(f"txHash:{tx_hash}") + # 2. query tx index is null + transaction1 = self.node.getClient().get_transaction(tx_hash) + print(f"tx_index:{transaction1['tx_status']['tx_index']}") + assert transaction1["tx_status"]["tx_index"] is None + # 3. miner block until tx committed, query tx index is 0x1 + self.Miner.miner_until_tx_committed(self.node, tx_hash) + transaction2 = self.node.getClient().get_transaction(tx_hash) + print(f"after miner tx_hash, tx_index:{transaction2['tx_status']['tx_index']}") + assert transaction2["tx_status"]["tx_index"] == "0x1" From 62a4f5efc9c519acb843efd0b9b5e61d4dc47f14 Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Wed, 14 Aug 2024 15:55:31 +0800 Subject: [PATCH 5/6] format config.py --- framework/config.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/framework/config.py b/framework/config.py index 4f3d4a4..1e8d9f9 100644 --- a/framework/config.py +++ b/framework/config.py @@ -47,9 +47,7 @@ # contract ALWAYS_SUCCESS_CONTRACT_PATH = f"{get_project_root()}/source/contract/always_success" -SPAWN_CONTRACT_PATH = ( - f"{get_project_root()}/source/contract/test_cases/spawn_demo" -) +SPAWN_CONTRACT_PATH = f"{get_project_root()}/source/contract/test_cases/spawn_demo" def get_tmp_path(): From ddfced7f3ae95c8b60763ac49fcd60918ec82fb8 Mon Sep 17 00:00:00 2001 From: 15168316096 <15168316096@163.com> Date: Wed, 14 Aug 2024 17:24:03 +0800 Subject: [PATCH 6/6] del pytest.mark.skip --- test_cases/feature/test_get_transaction.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/test_cases/feature/test_get_transaction.py b/test_cases/feature/test_get_transaction.py index e5dad47..0f33aa9 100644 --- a/test_cases/feature/test_get_transaction.py +++ b/test_cases/feature/test_get_transaction.py @@ -1,5 +1,4 @@ from framework.basic import CkbTest -import pytest class TestGetTransaction(CkbTest): @@ -32,7 +31,6 @@ def teardown_class(cls): cls.node.stop() cls.node.clean() - # @pytest.mark.skip("util v118 rc") def test_get_transaction_by_tx_index(self): """ 1. new tx in block