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

fix: fix miner_until_tx_committed #7

Merged
merged 1 commit into from
Jun 28, 2023
Merged
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
15 changes: 10 additions & 5 deletions framework/helper/miner.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@ def make_tip_height_number(node, number):
def miner_until_tx_committed(node, tx_hash):
for i in range(100):
tx_response = node.getClient().get_transaction(tx_hash)
if tx_response['tx_status']['status'] != "pending" and tx_response['tx_status']['status'] != "proposed":
# miner_with_version(node, "0x0")
if tx_response['tx_status']['status'] == "committed":
return
miner_with_version(node, "0x0")
time.sleep(1)
assert f"miner 100 block ,but tx_response always pending:{tx_hash}"
if tx_response['tx_status']['status'] == "pending" or tx_response['tx_status']['status'] == "proposed":
miner_with_version(node, "0x0")
time.sleep(1)
continue

if tx_response['tx_status']['status'] == "rejected" or tx_response['tx_status']['status'] == "unknown":
raise Exception(f"status:{tx_response['tx_status']['status']},reason:{tx_response['tx_status']['reason']}")

raise Exception (f"miner 100 block ,but tx_response always pending:{tx_hash}")


# https://github.com/nervosnetwork/rfcs/pull/416
Expand Down
3 changes: 1 addition & 2 deletions test_cases/ckb2023/test_01_before_hardfork.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ def test_0049_transfer_tx_when_10th_block_before_fork(self):
self.cluster.ckb_nodes[0].client.url)
print(f"txHash:{tx_hash}")
miner_with_version(self.cluster.ckb_nodes[0], "0x0")
miner_until_tx_committed(self.cluster.ckb_nodes[0], tx_hash)
tx_response = self.cluster.ckb_nodes[0].getClient().get_transaction(tx_hash)
print(f"tx response:{tx_response['tx_status']['status']}")
assert tx_response['tx_status']['status'] == "rejected" or tx_response['tx_status']['status'] == "unknown"
Expand Down Expand Up @@ -169,7 +168,7 @@ def test_send_transfer_tx_when_10th_block_before_fork(self):
140,
self.cluster.ckb_nodes[0].client.url)
print(f"txHash:{tx_hash}")
miner_until_tx_committed(self.cluster.ckb_nodes[0], tx_hash)
miner_with_version(self.cluster.ckb_nodes[0], '0x0')
tx_response = self.cluster.ckb_nodes[0].getClient().get_transaction(tx_hash)
print(f"tx response:{tx_response['tx_status']['status']}")
assert tx_response['tx_status']['status'] == 'unknown'
Expand Down
2 changes: 1 addition & 1 deletion test_cases/ckb2023/test_02_after_hardfork.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def test_send_tx_when_after_0th_fork(self):
140,
self.cluster.ckb_nodes[0].client.url)
print(f"txHash:{tx_hash}")
miner_until_tx_committed(self.cluster.ckb_nodes[0], tx_hash)
miner_with_version(self.cluster.ckb_nodes[0], '0x0')
tx_response = self.cluster.ckb_nodes[0].getClient().get_transaction(tx_hash)
print(f"tx response:{tx_response['tx_status']['status']}")
assert tx_response['tx_status']['status'] == 'unknown'
Expand Down