Compare commits

...

3 Commits

Author SHA1 Message Date
hodlinator
78c92e317d
Merge 790c509a4796ec47be2275d86b35370ff25a599a into cd8089c20baaaee329cbf7951195953a9f86d7cf 2025-03-16 17:16:16 +01:00
Hodlinator
790c509a47
qa wallet: Actually make use of conditions
The two ones in run_test() were basically no-ops.
2025-02-17 14:31:44 +01:00
Hodlinator
ae4730ea12
qa: Add assert_true()
This follows the style of ASSERT_TRUE() in GoogleTest: https://google.github.io/googletest/reference/assertions.html
2025-02-17 14:31:44 +01:00
2 changed files with 12 additions and 3 deletions

View File

@ -69,6 +69,14 @@ def summarise_dict_differences(thing1, thing2):
d2[k] = thing2[k]
return d1, d2
def assert_true(condition: bool) -> None:
"""Separate from the `assert` keyword in that it should not be optimized out
when environment var `PYTHONOPTIMIZE=1`, or Python is run with `-O`."""
if not condition:
raise AssertionError
def assert_equal(thing1, thing2, *args):
if thing1 != thing2 and not args and isinstance(thing1, dict) and isinstance(thing2, dict):
d1,d2 = summarise_dict_differences(thing1, thing2)

View File

@ -11,6 +11,7 @@ from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_approx,
assert_equal,
assert_true,
)
@ -68,7 +69,7 @@ class WalletMultisigDescriptorPSBTTest(BitcoinTestFramework):
"timestamp": "now",
},
])
assert all(r["success"] for r in result)
assert_true(all(r["success"] for r in result))
yield multisig
def run_test(self):
@ -95,9 +96,9 @@ class WalletMultisigDescriptorPSBTTest(BitcoinTestFramework):
self.log.info("Check that every participant's multisig generates the same addresses...")
for _ in range(10): # we check that the first 10 generated addresses are the same for all participant's multisigs
receive_addresses = [multisig.getnewaddress() for multisig in participants["multisigs"]]
all(address == receive_addresses[0] for address in receive_addresses)
assert_true(all(address == receive_addresses[0] for address in receive_addresses))
change_addresses = [multisig.getrawchangeaddress() for multisig in participants["multisigs"]]
all(address == change_addresses[0] for address in change_addresses)
assert_true(all(address == change_addresses[0] for address in change_addresses))
self.log.info("Get a mature utxo to send to the multisig...")
coordinator_wallet = participants["signers"][0]