0index ff67207c4e..2a4cc9dfba 100755
1--- a/test/functional/p2p_segwit.py
2+++ b/test/functional/p2p_segwit.py
3@@ -85,6 +85,7 @@ from test_framework.test_framework import BitcoinTestFramework
4 from test_framework.util import (
5 assert_equal,
6 assert_greater_than,
7+ assert_greater_than_or_equal,
8 softfork_active,
9 assert_raises_rpc_error,
10 )
11@@ -376,14 +377,14 @@ class SegWitTest(BitcoinTestFramework):
12 self.test_node.send_message(msg_headers())
13
14 self.test_node.announce_block_and_wait_for_getdata(block1, use_header=False)
15- assert self.test_node.last_message["getdata"].inv[0].type == blocktype
16+ assert_equal(self.test_node.last_message["getdata"].inv[0].type, blocktype)
17 test_witness_block(self.nodes[0], self.test_node, block1, True)
18
19 block2 = self.build_next_block()
20 block2.solve()
21
22 self.test_node.announce_block_and_wait_for_getdata(block2, use_header=True)
23- assert self.test_node.last_message["getdata"].inv[0].type == blocktype
24+ assert_equal(self.test_node.last_message["getdata"].inv[0].type, blocktype)
25 test_witness_block(self.nodes[0], self.test_node, block2, True)
26
27 # Check that we can getdata for witness blocks or regular blocks,
28@@ -412,8 +413,8 @@ class SegWitTest(BitcoinTestFramework):
29 block = self.build_next_block()
30 self.update_witness_block_with_transactions(block, [])
31 # This gives us a witness commitment.
32- assert len(block.vtx[0].wit.vtxinwit) == 1
33- assert len(block.vtx[0].wit.vtxinwit[0].scriptWitness.stack) == 1
34+ assert_equal(len(block.vtx[0].wit.vtxinwit), 1)
35+ assert_equal(len(block.vtx[0].wit.vtxinwit[0].scriptWitness.stack), 1)
36 test_witness_block(self.nodes[0], self.test_node, block, accepted=True)
37 # Now try to retrieve it...
38 rpc_block = self.nodes[0].getblock(block.hash, False)
39@@ -539,7 +540,7 @@ class SegWitTest(BitcoinTestFramework):
40 # Verify that if a peer doesn't set nServices to include NODE_WITNESS,
41 # the getdata is just for the non-witness portion.
42 self.old_node.announce_tx_and_wait_for_getdata(tx)
43- assert self.old_node.last_message["getdata"].inv[0].type == MSG_TX
44+ assert_equal(self.old_node.last_message["getdata"].inv[0].type, MSG_TX)
45
46 # Since we haven't delivered the tx yet, inv'ing the same tx from
47 # a witness transaction ought not result in a getdata.
48@@ -807,7 +808,7 @@ class SegWitTest(BitcoinTestFramework):
49 block_3.vtx[0].vout[-1].nValue += 1
50 block_3.vtx[0].rehash()
51 block_3.hashMerkleRoot = block_3.calc_merkle_root()
52- assert len(block_3.vtx[0].vout) == 4 # 3 OP_returns
53+ assert_equal(len(block_3.vtx[0].vout), 4) # 3 OP_returns
54 block_3.solve()
55 test_witness_block(self.nodes[0], self.test_node, block_3, accepted=True)
56
57@@ -838,7 +839,7 @@ class SegWitTest(BitcoinTestFramework):
58 block.solve()
59
60 block.vtx[0].wit.vtxinwit[0].scriptWitness.stack.append(b'a' * 5000000)
61- assert block.get_weight() > MAX_BLOCK_WEIGHT
62+ assert_greater_than(block.get_weight(), MAX_BLOCK_WEIGHT)
63
64 # We can't send over the p2p network, because this is too big to relay
65 # TODO: repeat this test with a block that can be relayed
66@@ -850,7 +851,7 @@ class SegWitTest(BitcoinTestFramework):
67 assert_greater_than(MAX_BLOCK_WEIGHT, block.get_weight())
68 assert_equal(None, self.nodes[0].submitblock(block.serialize().hex()))
69
70- assert self.nodes[0].getbestblockhash() == block.hash
71+ assert_equal(self.nodes[0].getbestblockhash(), block.hash)
72
73 # Now make sure that malleating the witness reserved value doesn't
74 # result in a block permanently marked bad.
75@@ -875,7 +876,7 @@ class SegWitTest(BitcoinTestFramework):
76 # Test that witness-bearing blocks are limited at ceil(base + wit/4) <= 1MB.
77 block = self.build_next_block()
78
79- assert len(self.utxo) > 0
80+ assert_greater_than(len(self.utxo), 0)
81
82 # Create a P2WSH transaction.
83 # The witness script will be a bunch of OP_2DROP's, followed by OP_TRUE.
84@@ -896,7 +897,7 @@ class SegWitTest(BitcoinTestFramework):
85 for _ in range(NUM_OUTPUTS):
86 parent_tx.vout.append(CTxOut(child_value, script_pubkey))
87 parent_tx.vout[0].nValue -= 50000
88- assert parent_tx.vout[0].nValue > 0
89+ assert_greater_than(parent_tx.vout[0].nValue, 0)
90 parent_tx.rehash()
91
92 child_tx = CTransaction()
93@@ -924,7 +925,7 @@ class SegWitTest(BitcoinTestFramework):
94 assert_equal(block.get_weight(), MAX_BLOCK_WEIGHT + 1)
95 # Make sure that our test case would exceed the old max-network-message
96 # limit
97- assert len(block.serialize()) > 2 * 1024 * 1024
98+ assert_greater_than(len(block.serialize()), 2 * 1024 * 1024)
99
100 test_witness_block(self.nodes[0], self.test_node, block, accepted=False, reason='bad-blk-we
101ight')
102
103@@ -934,7 +935,7 @@ class SegWitTest(BitcoinTestFramework):
104 block.vtx[0].vout.pop()
105 add_witness_commitment(block)
106 block.solve()
107- assert block.get_weight() == MAX_BLOCK_WEIGHT
108+ assert_equal(block.get_weight(), MAX_BLOCK_WEIGHT)
109
110 test_witness_block(self.nodes[0], self.test_node, block, accepted=True)
111
112@@ -1098,7 +1099,7 @@ class SegWitTest(BitcoinTestFramework):
113
114 # This script is 19 max pushes (9937 bytes), then 64 more opcode-bytes.
115 long_witness_script = CScript([b'a' * MAX_SCRIPT_ELEMENT_SIZE] * 19 + [OP_DROP] * 63 + [OP_
116TRUE])
117- assert len(long_witness_script) == MAX_WITNESS_SCRIPT_LENGTH + 1
118+ assert_equal(len(long_witness_script), MAX_WITNESS_SCRIPT_LENGTH + 1)
119 long_script_pubkey = script_to_p2wsh_script(long_witness_script)
120
121 block = self.build_next_block()
122@@ -1122,7 +1123,7 @@ class SegWitTest(BitcoinTestFramework):
123
124 # Try again with one less byte in the witness script
125 witness_script = CScript([b'a' * MAX_SCRIPT_ELEMENT_SIZE] * 19 + [OP_DROP] * 62 + [OP_TRUE]
126)
127- assert len(witness_script) == MAX_WITNESS_SCRIPT_LENGTH
128+ assert_equal(len(witness_script), MAX_WITNESS_SCRIPT_LENGTH)
129 script_pubkey = script_to_p2wsh_script(witness_script)
130
131 tx.vout[0] = CTxOut(tx.vout[0].nValue, script_pubkey)
132@@ -1151,7 +1152,7 @@ class SegWitTest(BitcoinTestFramework):
133 for _ in range(10):
134 tx.vout.append(CTxOut(int(value / 10), script_pubkey))
135 tx.vout[0].nValue -= 1000
136- assert tx.vout[0].nValue >= 0
137+ assert_greater_than_or_equal(tx.vout[0].nValue, 0)
138
139 block = self.build_next_block()
140 self.update_witness_block_with_transactions(block, [tx])
141@@ -1358,7 +1359,7 @@ class SegWitTest(BitcoinTestFramework):
142 temp_utxo.append(UTXO(tx.sha256, 0, tx.vout[0].nValue))
143
144 self.generate(self.nodes[0], 1) # Mine all the transactions
145- assert len(self.nodes[0].getrawmempool()) == 0
146+ assert_equal(len(self.nodes[0].getrawmempool()), 0)
147
148 # Finally, verify that version 0 -> version 2 transactions
149 # are standard
150@@ -1622,7 +1623,7 @@ class SegWitTest(BitcoinTestFramework):
151 # Create a slight bias for producing more utxos
152 num_outputs = random.randint(1, 11)
153 random.shuffle(temp_utxos)
154- assert len(temp_utxos) > num_inputs
155+ assert_greater_than(len(temp_utxos), num_inputs)
156 tx = CTransaction()
157 total_value = 0
158 for i in range(num_inputs):