Page MenuHomePhabricator

[test framework] Add a facility to format an uint256 in hex
ClosedPublic

Authored by Fabien on Aug 17 2022, 14:52.

Details

Reviewers
PiRK
Group Reviewers
Restricted Project
Commits
rABC37f4e734b1d8: [test framework] Add a facility to format an uint256 in hex
Summary

This is a long overdue factorization of the f strings that are scattered in all the functional tests to print/call rpcs on hashes.

Test Plan
ninja all check-functional-extended

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Fabien requested review of this revision.Aug 17 2022, 14:52

Failed tests logs:

====== Bitcoin ABC functional tests: abc_rpc_getavalancheinfo.py --nolegacyavaproof ======

------- Stdout: -------
2022-08-17T15:01:27.988000Z TestFramework (INFO): Initializing test directory /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20220817_145851/abc_rpc_getavalancheinfo_38
2022-08-17T15:01:28.388000Z TestFramework (INFO): The test node has no proof
2022-08-17T15:01:28.389000Z TestFramework (INFO): The test node has a proof
2022-08-17T15:01:29.134000Z TestFramework (INFO): Connect a bunch of peers and nodes
2022-08-17T15:01:31.107000Z TestFramework (INFO): Disconnect some nodes
2022-08-17T15:01:31.261000Z TestFramework (INFO): Add some pending nodes
2022-08-17T15:01:31.783000Z TestFramework (INFO): Finalize the proofs for some peers
2022-08-17T15:01:37.505000Z TestFramework (INFO): Disconnect all the nodes, so we are the only node left on the network
2022-08-17T15:01:37.561000Z TestFramework (ERROR): Assertion failed
Traceback (most recent call last):
  File "/work/test/functional/test_framework/test_framework.py", line 136, in main
    self.run_test()
  File "/work/test/functional/abc_rpc_getavalancheinfo.py", line 373, in run_test
    "pending_node_count": 0,
  File "/work/test/functional/abc_rpc_getavalancheinfo.py", line 65, in assert_avalancheinfo
    handle_legacy_format(expected)
  File "/work/test/functional/test_framework/util.py", line 60, in assert_equal
    for arg in (thing1, thing2) + args)))
AssertionError: not({'ready_to_poll': False, 'local': {'verified': True, 'proofid': 'd7031ba5083237d3e4545c40c47b3412d823532ecdc87b088a64268a2b92ec85', 'limited_proofid': '1f008ccfc24eb9739f81535423b2bfb03759ca61ae839633857577f50f05d1fc', 'master': '02b1df7f2e0fd49cff79979a58d491ae47ee95840e2c644d242229ae5749ab167f', 'payout_address': 'ecregtest:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqcrl5mqkt', 'stake_amount': Decimal('25000000.00')}, 'network': {'proof_count': 15, 'connected_proof_count': 1, 'dangling_proof_count': 14, 'finalized_proof_count': 13, 'conflicting_proof_count': 0, 'immature_proof_count': 0, 'total_stake_amount': Decimal('375000000.00'), 'connected_stake_amount': Decimal('25000000.00'), 'dangling_stake_amount': Decimal('350000000.00'), 'node_count': 1, 'connected_node_count': 1, 'pending_node_count': 0}} == {'ready_to_poll': False, 'local': {'verified': True, 'proofid': 'd7031ba5083237d3e4545c40c47b3412d823532ecdc87b088a64268a2b92ec85', 'limited_proofid': '1f008ccfc24eb9739f81535423b2bfb03759ca61ae839633857577f50f05d1fc', 'master': '02b1df7f2e0fd49cff79979a58d491ae47ee95840e2c644d242229ae5749ab167f', 'stake_amount': Decimal('25000000.00'), 'payout_address': 'ecregtest:qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqcrl5mqkt'}, 'network': {'proof_count': 15, 'connected_proof_count': 1, 'dangling_proof_count': 14, 'finalized_proof_count': 14, 'conflicting_proof_count': 0, 'immature_proof_count': 0, 'total_stake_amount': Decimal('375000000.00'), 'connected_stake_amount': Decimal('25000000.00'), 'dangling_stake_amount': Decimal('350000000.00'), 'node_count': 1, 'connected_node_count': 1, 'pending_node_count': 0}})
2022-08-17T15:01:37.612000Z TestFramework (INFO): Stopping nodes
2022-08-17T15:01:37.966000Z TestFramework (WARNING): Not cleaning up dir /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20220817_145851/abc_rpc_getavalancheinfo_38
2022-08-17T15:01:37.966000Z TestFramework (ERROR): Test failed. Test logging available at /work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20220817_145851/abc_rpc_getavalancheinfo_38/test_framework.log
2022-08-17T15:01:37.966000Z TestFramework (ERROR): 
2022-08-17T15:01:37.966000Z TestFramework (ERROR): Hint: Call /work/test/functional/combine_logs.py '/work/abc-ci-builds/build-diff/test/tmp/test_runner_₿₵_  _20220817_145851/abc_rpc_getavalancheinfo_38' to consolidate all logs
2022-08-17T15:01:37.966000Z TestFramework (ERROR): 
2022-08-17T15:01:37.966000Z TestFramework (ERROR): If this failure happened unexpectedly or intermittently, please file a bug and provide a link or upload of the combined log.
2022-08-17T15:01:37.966000Z TestFramework (ERROR): https://github.com/Bitcoin-ABC/bitcoin-abc/issues
2022-08-17T15:01:37.966000Z TestFramework (ERROR):

Each failure log is accessible here:
Bitcoin ABC functional tests: abc_rpc_getavalancheinfo.py --nolegacyavaproof

PiRK added inline comments.
test/functional/test_framework/util.py
542 ↗(On Diff #34685)

It is never going to be a problem here, but note that python has a builtin function hash, which will be shadowed in the scope if this function

This revision is now accepted and ready to land.Aug 17 2022, 15:29
test/functional/test_framework/util.py
542 ↗(On Diff #34685)

good point, I'll rename hash_int to avoid shadowing