Page MenuHomePhabricator

tests: Represent proof IDs as hex strings when sync_proofs fails
ClosedPublic

Authored by PiRK on Sep 2 2021, 14:17.

Details

Summary

Internally, the test framework computes and stores proof IDs as
integers. This is not a convenient format when debugging, as the
debug.log message all show proof IDs as hex strings.

Format the proof IDs as hex strings for the AssertionError message.

Test Plan

Run abc_p2p_proof_inventory with the following patch, to cause the error message to be displayed:

diff --git a/test/functional/test_framework/test_framework.py b/test/functional/test_framework/test_framework.py
index c4581f787d..1befe966d7 100755
--- a/test/functional/test_framework/test_framework.py
+++ b/test/functional/test_framework/test_framework.py
@@ -579,7 +579,7 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
             "".join("\n  {!r}".format(m) for m in pool),
         ))

-    def sync_proofs(self, nodes=None, wait=1, timeout=60):
+    def sync_proofs(self, nodes=None, wait=1, timeout=10):
         """
         Wait until everybody has the same proofs in their proof pools
         """
@@ -592,8 +592,8 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
         while time.time() <= stop_time:
             nodes_proofs = [
                 set(format_ids(get_proof_ids(r))) for r in rpc_connections]
-            if nodes_proofs.count(nodes_proofs[0]) == len(rpc_connections):
-                return
             # Check that each peer has at least one connection
             assert (all([len(x.getpeerinfo()) for x in rpc_connections]))
             time.sleep(wait)

Diff Detail

Event Timeline

PiRK requested review of this revision.Sep 2 2021, 14:17
test/functional/test_framework/test_framework.py
593 ↗(On Diff #29752)

The lint message does not take into account the autofix that was done when creating the revision.

This revision is now accepted and ready to land.Sep 2 2021, 14:46