test: create assert_not_equal util and add to where imports are needed

In the functional tests there are lots of cases where we assert != which
this new util will replace, we also are adding the imports and the new assertion
This commit is contained in:
kevkevin
2024-02-27 19:41:12 -06:00
committed by kevkevinpal
parent 930b237f16
commit 7bb83f6718
41 changed files with 137 additions and 83 deletions

View File

@@ -57,6 +57,7 @@ from test_framework.script import (
)
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import (
assert_not_equal,
assert_equal,
softfork_active,
)
@@ -735,7 +736,7 @@ class CompactBlocksTest(BitcoinTestFramework):
test_node.send_and_ping(msg)
# Check that the tip didn't advance
assert int(node.getbestblockhash(), 16) != block.sha256
assert_not_equal(int(node.getbestblockhash(), 16), block.sha256)
test_node.sync_with_ping()
# Helper for enabling cb announcements
@@ -788,7 +789,7 @@ class CompactBlocksTest(BitcoinTestFramework):
cmpct_block.use_witness = True
delivery_peer.send_and_ping(msg_cmpctblock(cmpct_block.to_p2p()))
assert int(node.getbestblockhash(), 16) != block.sha256
assert_not_equal(int(node.getbestblockhash(), 16), block.sha256)
msg = msg_no_witness_blocktxn()
msg.block_transactions.blockhash = block.sha256
@@ -865,19 +866,19 @@ class CompactBlocksTest(BitcoinTestFramework):
with p2p_lock:
# The second peer to announce should still get a getblocktxn
assert "getblocktxn" in delivery_peer.last_message
assert int(node.getbestblockhash(), 16) != block.sha256
assert_not_equal(int(node.getbestblockhash(), 16), block.sha256)
inbound_peer.send_and_ping(msg_cmpctblock(cmpct_block.to_p2p()))
with p2p_lock:
# The third inbound peer to announce should *not* get a getblocktxn
assert "getblocktxn" not in inbound_peer.last_message
assert int(node.getbestblockhash(), 16) != block.sha256
assert_not_equal(int(node.getbestblockhash(), 16), block.sha256)
outbound_peer.send_and_ping(msg_cmpctblock(cmpct_block.to_p2p()))
with p2p_lock:
# The third peer to announce should get a getblocktxn if outbound
assert "getblocktxn" in outbound_peer.last_message
assert int(node.getbestblockhash(), 16) != block.sha256
assert_not_equal(int(node.getbestblockhash(), 16), block.sha256)
# Second peer completes the compact block first
msg = msg_blocktxn()