mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-03 17:54:19 +02:00
test: use in for two-value equality asserts
Some tests spell a two-value membership check as `assert x == a or x == b`. Rewrite those sites as `assert x in (a, b)`. This keeps the check the same and removes `==` forms that the later cleanup should not touch.
This commit is contained in:
@@ -75,9 +75,9 @@ class ZMQSubscriber:
|
||||
label = chr(body[32])
|
||||
mempool_sequence = None if len(body) != 32+1+8 else struct.unpack("<Q", body[32+1:])[0]
|
||||
if mempool_sequence is not None:
|
||||
assert label == "A" or label == "R"
|
||||
assert label in ("A", "R")
|
||||
else:
|
||||
assert label == "D" or label == "C"
|
||||
assert label in ("D", "C")
|
||||
return (hash, label, mempool_sequence)
|
||||
|
||||
|
||||
@@ -480,7 +480,7 @@ class ZMQTest (BitcoinTestFramework):
|
||||
while zmq_mem_seq is None:
|
||||
(hash_str, label, zmq_mem_seq) = seq.receive_sequence()
|
||||
|
||||
assert label == "A" or label == "R"
|
||||
assert label in ("A", "R")
|
||||
assert hash_str is not None
|
||||
|
||||
# 2) We need to "seed" our view of the mempool
|
||||
|
||||
@@ -551,8 +551,7 @@ class CompactBlocksTest(BitcoinTestFramework):
|
||||
|
||||
# We should receive a getdata request
|
||||
test_node.wait_for_getdata([block.hash_int], timeout=10)
|
||||
assert test_node.last_message["getdata"].inv[0].type == MSG_BLOCK or \
|
||||
test_node.last_message["getdata"].inv[0].type == MSG_BLOCK | MSG_WITNESS_FLAG
|
||||
assert test_node.last_message["getdata"].inv[0].type in (MSG_BLOCK, MSG_BLOCK | MSG_WITNESS_FLAG)
|
||||
|
||||
# Deliver the block
|
||||
test_node.send_and_ping(msg_block(block))
|
||||
@@ -586,8 +585,7 @@ class CompactBlocksTest(BitcoinTestFramework):
|
||||
|
||||
# We should receive a getdata request
|
||||
test_node.wait_for_getdata([block.hash_int], timeout=10)
|
||||
assert test_node.last_message["getdata"].inv[0].type == MSG_BLOCK or \
|
||||
test_node.last_message["getdata"].inv[0].type == MSG_BLOCK | MSG_WITNESS_FLAG
|
||||
assert test_node.last_message["getdata"].inv[0].type in (MSG_BLOCK, MSG_BLOCK | MSG_WITNESS_FLAG)
|
||||
|
||||
# Send the same blocktxn and assert the sender gets disconnected.
|
||||
with node.assert_debug_log(['previous compact block reconstruction attempt failed']):
|
||||
|
||||
@@ -392,7 +392,7 @@ class WalletSendTest(BitcoinTestFramework):
|
||||
res = self.test_send(from_wallet=w0, to_wallet=w1, amount=1, add_to_wallet=False, change_type="legacy", change_position=0)
|
||||
assert res["complete"]
|
||||
change_address = self.nodes[0].decodepsbt(res["psbt"])["tx"]["vout"][0]["scriptPubKey"]["address"]
|
||||
assert change_address[0] == "m" or change_address[0] == "n"
|
||||
assert change_address[0] in ("m", "n")
|
||||
|
||||
self.log.info("Set lock time...")
|
||||
height = self.nodes[0].getblockchaininfo()["blocks"]
|
||||
|
||||
Reference in New Issue
Block a user