From 00d8ccf040674fb6c7d1980fad56b0cc33300163 Mon Sep 17 00:00:00 2001 From: Kevin Heifner Date: Sat, 9 Mar 2024 15:10:20 -0600 Subject: [PATCH] GH-2125 Improve test robustness --- tests/lib_advance_test.py | 2 +- tests/trx_finality_status_forked_test.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/lib_advance_test.py b/tests/lib_advance_test.py index d4d8fa992f..cb2ddd104c 100755 --- a/tests/lib_advance_test.py +++ b/tests/lib_advance_test.py @@ -72,7 +72,7 @@ prodNodes=[ prodNode0, prodNode1, prodNode2, prodNode3 ] prodA=prodNode0 # defproducera - prodD=prodNode3 # defproducerc + prodD=prodNode3 # defproducerd # *** Identify a block where production is stable *** diff --git a/tests/trx_finality_status_forked_test.py b/tests/trx_finality_status_forked_test.py index ac6a776d25..9fc88d8edd 100755 --- a/tests/trx_finality_status_forked_test.py +++ b/tests/trx_finality_status_forked_test.py @@ -167,6 +167,10 @@ def getState(status): if state == forkedOutState or ( info['head_block_producer'] == 'defproducerd' and info['last_irreversible_block_num'] > transBlockNum ): break + if state == irreversibleState: + Print(f"Transaction became irreversible before it could be found forked out: {json.dumps(retStatus, indent=1)}") + sys.exit(0) + assert state == forkedOutState, \ f"ERROR: getTransactionStatus didn't return \"{forkedOutState}\" state.\n\nstatus: {json.dumps(retStatus, indent=1)}" + \ f"\n\nprod A info: {json.dumps(prodA.getInfo(), indent=1)}\n\nprod D info: {json.dumps(prodD.getInfo(), indent=1)}" @@ -182,6 +186,18 @@ def getState(status): retStatus = prodD.getTransactionStatus(transId) state = getState(retStatus) + # it is possible for another fork switch to cause the trx to be forked out again + if state == forkedOutState: + while True: + info = prodD.getInfo() + retStatus = prodD.getTransactionStatus(transId) + state = getState(retStatus) + if state == localState or ( info['head_block_producer'] == 'defproducerd' and info['last_irreversible_block_num'] > retBlockNum ): + continue + retBlockNum = retStatus["block_number"] + if (state == inBlockState or state == irreversibleState) or ( info['head_block_producer'] == 'defproducerd' and info['last_irreversible_block_num'] > retBlockNum ): + break + assert state == inBlockState or state == irreversibleState, \ f"ERROR: getTransactionStatus didn't return \"{inBlockState}\" or \"{irreversibleState}\" state.\n\nstatus: {json.dumps(retStatus, indent=1)}" + \ f"\n\nprod A info: {json.dumps(prodA.getInfo(), indent=1)}\n\nprod D info: {json.dumps(prodD.getInfo(), indent=1)}"