diff --git a/test/functional/feature_bind_port_discover.py b/test/functional/feature_bind_port_discover.py index 6046ba5e24ba8e..46bf384c5ec0fe 100755 --- a/test/functional/feature_bind_port_discover.py +++ b/test/functional/feature_bind_port_discover.py @@ -74,7 +74,7 @@ def run_test(self): if local['address'] == ADDR1: found_addr1 = True assert_equal(local['port'], BIND_PORT) - assert local['address'] != ADDR2 + assert_not_equal(local['address'], ADDR2) assert found_addr1 if __name__ == '__main__': diff --git a/test/functional/feature_coinstatsindex.py b/test/functional/feature_coinstatsindex.py index 45db3d1824df5f..e4c190fdf171d4 100755 --- a/test/functional/feature_coinstatsindex.py +++ b/test/functional/feature_coinstatsindex.py @@ -276,12 +276,12 @@ def _test_reorg_index(self): res2 = index_node.gettxoutsetinfo(hash_type='muhash', hash_or_height=112) assert_equal(res["bestblock"], block) assert_equal(res["muhash"], res2["muhash"]) - assert res["muhash"] != res_invalid["muhash"] + assert_not_equal(res["muhash"], res_invalid["muhash"]) # Test that requesting reorged out block by hash is still returning correct results res_invalid2 = index_node.gettxoutsetinfo(hash_type='muhash', hash_or_height=reorg_block) assert_equal(res_invalid2["muhash"], res_invalid["muhash"]) - assert res["muhash"] != res_invalid2["muhash"] + assert_not_equal(res["muhash"], res_invalid2["muhash"]) # Add another block, so we don't depend on reconsiderblock remembering which # blocks were touched by invalidateblock diff --git a/test/functional/feature_dbcrash.py b/test/functional/feature_dbcrash.py index f4bae533357d03..83cac4b2c37d6b 100755 --- a/test/functional/feature_dbcrash.py +++ b/test/functional/feature_dbcrash.py @@ -275,7 +275,7 @@ def run_test(self): self.log.info(f"Restarted nodes: {self.restart_counts}; crashes on restart: {self.crashed_on_restart}") # If no nodes were restarted, we didn't test anything. - assert self.restart_counts != [0, 0, 0] + assert_not_equal(self.restart_counts, [0, 0, 0]) # Make sure we tested the case of crash-during-recovery. assert self.crashed_on_restart > 0 diff --git a/test/functional/feature_fee_estimation.py b/test/functional/feature_fee_estimation.py index 21ba4924612aeb..61db186de17be5 100755 --- a/test/functional/feature_fee_estimation.py +++ b/test/functional/feature_fee_estimation.py @@ -364,7 +364,7 @@ def test_estimate_dat_is_flushed_periodically(self): self.nodes[0].mockscheduler(SECONDS_PER_HOUR) fee_dat_current_content = open(fee_dat, "rb").read() - assert fee_dat_current_content != fee_dat_initial_content + assert_not_equal(fee_dat_current_content, fee_dat_initial_content) fee_dat_initial_content = fee_dat_current_content @@ -372,7 +372,7 @@ def test_estimate_dat_is_flushed_periodically(self): self.generate(self.nodes[0], 5, sync_fun=self.no_op) self.restart_node(0) fee_dat_current_content = open(fee_dat, "rb").read() - assert fee_dat_current_content != fee_dat_initial_content + assert_not_equal(fee_dat_current_content, fee_dat_initial_content) def test_acceptstalefeeestimates_option(self): diff --git a/test/functional/feature_minchainwork.py b/test/functional/feature_minchainwork.py index 62bb488f7cc068..f255d94ef3e024 100755 --- a/test/functional/feature_minchainwork.py +++ b/test/functional/feature_minchainwork.py @@ -75,7 +75,7 @@ def run_test(self): assert_equal(len(self.nodes[2].getchaintips()), 1) assert_equal(self.nodes[2].getchaintips()[0]['height'], 0) - assert self.nodes[1].getbestblockhash() != self.nodes[0].getbestblockhash() + assert_not_equal(self.nodes[1].getbestblockhash(), self.nodes[0].getbestblockhash()) assert_equal(self.nodes[2].getblockcount(), starting_blockcount) self.log.info("Check that getheaders requests to node2 are ignored") diff --git a/test/functional/feature_taproot.py b/test/functional/feature_taproot.py index 7f64588eb1239f..e1835ac494ad5c 100755 --- a/test/functional/feature_taproot.py +++ b/test/functional/feature_taproot.py @@ -1572,20 +1572,20 @@ def gen_test_vectors(self): # Require negated taps[0] assert taps[0].negflag # Require one negated and one non-negated in taps 1 and 2. - assert taps[1].negflag != taps[2].negflag + assert_not_equal(taps[1].negflag, taps[2].negflag) # Require one negated and one non-negated in taps 3 and 4. - assert taps[3].negflag != taps[4].negflag + assert_not_equal(taps[3].negflag, taps[4].negflag) # Require one negated and one non-negated in taps 5 and 6. - assert taps[5].negflag != taps[6].negflag + assert_not_equal(taps[5].negflag, taps[6].negflag) cblks = [{leaf: get({**DEFAULT_CONTEXT, 'tap': taps[i], 'leaf': leaf}, 'controlblock') for leaf in taps[i].leaves} for i in range(7)] # Require one swapped and one unswapped in taps 3 and 4. - assert (cblks[3]['0'][33:65] < cblks[3]['1'][33:65]) != (cblks[4]['0'][33:65] < cblks[4]['1'][33:65]) + assert_not_equal((cblks[3]['0'][33:65] < cblks[3]['1'][33:65]), (cblks[4]['0'][33:65] < cblks[4]['1'][33:65])) # Require one swapped and one unswapped in taps 5 and 6, both at the top and child level. - assert (cblks[5]['0'][33:65] < cblks[5]['1'][65:]) != (cblks[6]['0'][33:65] < cblks[6]['1'][65:]) - assert (cblks[5]['1'][33:65] < cblks[5]['2'][33:65]) != (cblks[6]['1'][33:65] < cblks[6]['2'][33:65]) + assert_not_equal((cblks[5]['0'][33:65] < cblks[5]['1'][65:]), (cblks[6]['0'][33:65] < cblks[6]['1'][65:])) + assert_not_equal((cblks[5]['1'][33:65] < cblks[5]['2'][33:65]), (cblks[6]['1'][33:65] < cblks[6]['2'][33:65])) # Require within taps 5 (and thus also 6) that one level is swapped and the other is not. - assert (cblks[5]['0'][33:65] < cblks[5]['1'][65:]) != (cblks[5]['1'][33:65] < cblks[5]['2'][33:65]) + assert_not_equal((cblks[5]['0'][33:65] < cblks[5]['1'][65:]), (cblks[5]['1'][33:65] < cblks[5]['2'][33:65])) # Compute a deterministic set of scriptPubKeys tap_spks = [] diff --git a/test/functional/mempool_accept_wtxid.py b/test/functional/mempool_accept_wtxid.py index d3b5f215d3ae53..3db711da0ad20f 100755 --- a/test/functional/mempool_accept_wtxid.py +++ b/test/functional/mempool_accept_wtxid.py @@ -87,7 +87,7 @@ def run_test(self): child_two_txid = child_two.rehash() assert_equal(child_one_txid, child_two_txid) - assert child_one_wtxid != child_two_wtxid + assert_not_equal(child_one_wtxid, child_two_wtxid) self.log.info("Submit child_one to the mempool") txid_submitted = node.sendrawtransaction(child_one.serialize().hex()) diff --git a/test/functional/mempool_truc.py b/test/functional/mempool_truc.py index e7acccb0fb654f..a6d9fd9832e334 100755 --- a/test/functional/mempool_truc.py +++ b/test/functional/mempool_truc.py @@ -480,7 +480,7 @@ def test_reorg_2child_rbf(self): child_1_conflict = self.wallet.send_self_transfer(from_node=node, version=3, utxo_to_spend=ancestor_tx["new_utxos"][0], fee_rate=Decimal("0.01")) # Ensure child_1 and child_1_conflict are different transactions - assert (child_1_conflict["txid"] != child_1["txid"]) + assert_not_equal(child_1_conflict["txid"], child_1["txid"]) self.check_mempool([ancestor_tx["txid"], child_1_conflict["txid"], child_2["txid"]]) assert_equal(node.getmempoolentry(ancestor_tx["txid"])["descendantcount"], 3) diff --git a/test/functional/mining_prioritisetransaction.py b/test/functional/mining_prioritisetransaction.py index c83d5c05a4b325..2cb5d85b44f909 100755 --- a/test/functional/mining_prioritisetransaction.py +++ b/test/functional/mining_prioritisetransaction.py @@ -303,7 +303,7 @@ def run_test(self): self.nodes[0].setmocktime(mock_time+10) new_template = self.nodes[0].getblocktemplate({'rules': ['segwit']}) - assert template != new_template + assert_not_equal(template, new_template) if __name__ == '__main__': PrioritiseTransactionTest(__file__).main() diff --git a/test/functional/p2p_blockfilters.py b/test/functional/p2p_blockfilters.py index 028f14d9c0892f..24ea28c96db32a 100755 --- a/test/functional/p2p_blockfilters.py +++ b/test/functional/p2p_blockfilters.py @@ -70,11 +70,11 @@ def run_test(self): assert_equal(self.nodes[1].getblockcount(), 2000) # Check that nodes have signalled NODE_COMPACT_FILTERS correctly. - assert peer_0.nServices & NODE_COMPACT_FILTERS != 0 + assert_not_equal(peer_0.nServices & NODE_COMPACT_FILTERS, 0) assert peer_1.nServices & NODE_COMPACT_FILTERS == 0 # Check that the localservices is as expected. - assert int(self.nodes[0].getnetworkinfo()['localservices'], 16) & NODE_COMPACT_FILTERS != 0 + assert_not_equal(int(self.nodes[0].getnetworkinfo()['localservices'], 16) & NODE_COMPACT_FILTERS, 0) assert int(self.nodes[1].getnetworkinfo()['localservices'], 16) & NODE_COMPACT_FILTERS == 0 self.log.info("get cfcheckpt on chain to be re-orged out.") @@ -94,7 +94,7 @@ def run_test(self): self.nodes[0].syncwithvalidationinterfacequeue() main_block_hash = self.nodes[0].getblockhash(1000) - assert main_block_hash != stale_block_hash, "node 0 chain did not reorganize" + assert_not_equal(main_block_hash, stale_block_hash, "node 0 chain did not reorganize") self.log.info("Check that peers can fetch cfcheckpt on active chain.") tip_hash = self.nodes[0].getbestblockhash() diff --git a/test/functional/p2p_compactblocks.py b/test/functional/p2p_compactblocks.py index accaea54ba45dd..566d89b2b2a5ff 100755 --- a/test/functional/p2p_compactblocks.py +++ b/test/functional/p2p_compactblocks.py @@ -792,7 +792,7 @@ def announce_cmpct_block(node, peer): 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 @@ -869,19 +869,19 @@ def announce_cmpct_block(node, peer, txn_count): 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() diff --git a/test/functional/p2p_getaddr_caching.py b/test/functional/p2p_getaddr_caching.py index 3dce1c5d946082..b12a7912d4d927 100755 --- a/test/functional/p2p_getaddr_caching.py +++ b/test/functional/p2p_getaddr_caching.py @@ -83,9 +83,9 @@ def run_test(self): if i > 0: # Responses from different binds should be unique - assert last_response_on_local_bind != addr_receiver_onion1.get_received_addrs() - assert last_response_on_local_bind != addr_receiver_onion2.get_received_addrs() - assert last_response_on_onion_bind1 != addr_receiver_onion2.get_received_addrs() + assert_not_equal(last_response_on_local_bind, addr_receiver_onion1.get_received_addrs()) + assert_not_equal(last_response_on_local_bind, addr_receiver_onion2.get_received_addrs()) + assert_not_equal(last_response_on_onion_bind1, addr_receiver_onion2.get_received_addrs()) # Responses on from the same bind should be the same assert_equal(last_response_on_local_bind, addr_receiver_local.get_received_addrs()) assert_equal(last_response_on_onion_bind1, addr_receiver_onion1.get_received_addrs()) @@ -114,9 +114,9 @@ def run_test(self): addr_receiver_onion2.wait_until(addr_receiver_onion2.addr_received) # new response is different - assert set(last_response_on_local_bind) != set(addr_receiver_local.get_received_addrs()) - assert set(last_response_on_onion_bind1) != set(addr_receiver_onion1.get_received_addrs()) - assert set(last_response_on_onion_bind2) != set(addr_receiver_onion2.get_received_addrs()) + assert_not_equal(set(last_response_on_local_bind), set(addr_receiver_local.get_received_addrs())) + assert_not_equal(set(last_response_on_onion_bind1), set(addr_receiver_onion1.get_received_addrs())) + assert_not_equal(set(last_response_on_onion_bind2), set(addr_receiver_onion2.get_received_addrs())) if __name__ == '__main__': diff --git a/test/functional/p2p_handshake.py b/test/functional/p2p_handshake.py index 9a9630d5ac6b67..00d90e6a1d7b40 100755 --- a/test/functional/p2p_handshake.py +++ b/test/functional/p2p_handshake.py @@ -56,7 +56,7 @@ def test_desirable_service_flags(self, node, service_flag_tests, desirable_servi expected_result = "disconnect" if expect_disconnect else "connect" self.log.info(f' - services 0x{services:08x}, type "{conn_type}" [{expected_result}]') if expect_disconnect: - assert (services & desirable_service_flags) != desirable_service_flags + assert_not_equal((services & desirable_service_flags), desirable_service_flags) expected_debug_log = f'does not offer the expected services ' \ f'({services:08x} offered, {desirable_service_flags:08x} expected)' with node.assert_debug_log([expected_debug_log]): diff --git a/test/functional/p2p_invalid_block.py b/test/functional/p2p_invalid_block.py index 68307fd13de4e2..c28ee47f9ceb22 100755 --- a/test/functional/p2p_invalid_block.py +++ b/test/functional/p2p_invalid_block.py @@ -84,7 +84,7 @@ def run_test(self): block2.vtx.append(tx2) assert_equal(block2.hashMerkleRoot, block2.calc_merkle_root()) assert_equal(orig_hash, block2.rehash()) - assert block2_orig.vtx != block2.vtx + assert_not_equal(block2_orig.vtx, block2.vtx) peer.send_blocks_and_test([block2], node, success=False, reject_reason='bad-txns-duplicate') diff --git a/test/functional/p2p_orphan_handling.py b/test/functional/p2p_orphan_handling.py index 4f8502dbba9beb..95a651d666f4f9 100755 --- a/test/functional/p2p_orphan_handling.py +++ b/test/functional/p2p_orphan_handling.py @@ -112,7 +112,7 @@ def assert_never_requested(self, txhash): """Check that the node has never sent us a getdata for this hash (int type)""" for getdata in self.getdata_received: for request in getdata.inv: - assert request.hash != txhash + assert_not_equal(request.hash, txhash) class OrphanHandlingTest(BitcoinTestFramework): def set_test_params(self): @@ -145,7 +145,7 @@ def create_malleated_version(self, tx): tx_bad_wit.wit.vtxinwit[0].scriptWitness.stack = [b'garbage'] assert_equal(tx["txid"], tx_bad_wit.rehash()) - assert tx["wtxid"] != tx_bad_wit.getwtxid() + assert_not_equal(tx["wtxid"], tx_bad_wit.getwtxid()) return tx_bad_wit @@ -402,8 +402,8 @@ def test_orphan_inherit_rejection(self): assert_equal(parent_low_fee_nonsegwit["txid"], parent_low_fee_nonsegwit["tx"].getwtxid()) child = self.wallet.create_self_transfer(utxo_to_spend=parent_low_fee_nonsegwit["new_utxo"]) grandchild = self.wallet.create_self_transfer(utxo_to_spend=child["new_utxo"]) - assert child["txid"] != child["tx"].getwtxid() - assert grandchild["txid"] != grandchild["tx"].getwtxid() + assert_not_equal(child["txid"], child["tx"].getwtxid()) + assert_not_equal(grandchild["txid"], grandchild["tx"].getwtxid()) # Relay the parent. It should be rejected because it pays 0 fees. self.relay_transaction(peer1, parent_low_fee_nonsegwit["tx"]) diff --git a/test/functional/p2p_ping.py b/test/functional/p2p_ping.py index 992ee8bfa76a1e..fa719f88a6704a 100755 --- a/test/functional/p2p_ping.py +++ b/test/functional/p2p_ping.py @@ -55,7 +55,7 @@ def run_test(self): self.log.info('Check that ping is sent after connection is established') no_pong_node = self.nodes[0].add_p2p_connection(NodeNoPong()) self.mock_forward(3) - assert no_pong_node.last_message.pop('ping').nonce != 0 + assert_not_equal(no_pong_node.last_message.pop('ping').nonce, 0) self.check_peer_info(pingtime=None, minping=None, pingwait=3) self.log.info('Reply without nonce cancels ping') diff --git a/test/functional/p2p_segwit.py b/test/functional/p2p_segwit.py index 723d0fd797f7de..29f89a95576cbd 100755 --- a/test/functional/p2p_segwit.py +++ b/test/functional/p2p_segwit.py @@ -249,7 +249,7 @@ def run_test(self): # self.std_wtx_node is for testing node1 with wtxid relay self.std_wtx_node = self.nodes[1].add_p2p_connection(TestP2PConn(wtxidrelay=True), services=P2P_SERVICES) - assert self.test_node.nServices & NODE_WITNESS != 0 + assert_not_equal(self.test_node.nServices & NODE_WITNESS, 0) # Keep a place to store utxo's that can be used in later tests self.utxo = [] @@ -336,7 +336,7 @@ def test_unnecessary_witness_before_segwit_activation(self): # Verify the hash with witness differs from the txid # (otherwise our testing framework must be broken!) tx.rehash() - assert tx.sha256 != tx.calc_sha256(with_witness=True) + assert_not_equal(tx.sha256, tx.calc_sha256(with_witness=True)) # Construct a block that includes the transaction. block = self.build_next_block() @@ -751,7 +751,7 @@ def test_witness_commitments(self): block.solve() # Test the test -- witness serialization should be different - assert msg_block(block).serialize() != msg_no_witness_block(block).serialize() + assert_not_equal(msg_block(block).serialize(), msg_no_witness_block(block).serialize()) # This empty block should be valid. test_witness_block(self.nodes[0], self.test_node, block, accepted=True) @@ -762,7 +762,7 @@ def test_witness_commitments(self): block_2.solve() # The commitment should have changed! - assert block_2.vtx[0].vout[-1] != block.vtx[0].vout[-1] + assert_not_equal(block_2.vtx[0].vout[-1], block.vtx[0].vout[-1]) # This should also be valid. test_witness_block(self.nodes[0], self.test_node, block_2, accepted=True) @@ -843,7 +843,7 @@ def test_block_malleability(self): # TODO: repeat this test with a block that can be relayed assert_equal('bad-witness-nonce-size', self.nodes[0].submitblock(block.serialize().hex())) - assert self.nodes[0].getbestblockhash() != block.hash + assert_not_equal(self.nodes[0].getbestblockhash(), block.hash) block.vtx[0].wit.vtxinwit[0].scriptWitness.stack.pop() assert block.get_weight() < MAX_BLOCK_WEIGHT @@ -952,7 +952,7 @@ def test_submit_block(self): block.vtx[0].wit = CTxWitness() # drop the nonce block.solve() assert_equal('bad-witness-merkle-match', self.nodes[0].submitblock(block.serialize().hex())) - assert self.nodes[0].getbestblockhash() != block.hash + assert_not_equal(self.nodes[0].getbestblockhash(), block.hash) # Now redo commitment with the standard nonce, but let bitcoind fill it in. add_witness_commitment(block, nonce=0) @@ -975,7 +975,7 @@ def test_submit_block(self): assert_equal('bad-txnmrklroot', self.nodes[0].submitblock(block_2.serialize().hex())) # Tip should not advance! - assert self.nodes[0].getbestblockhash() != block_2.hash + assert_not_equal(self.nodes[0].getbestblockhash(), block_2.hash) @subtest def test_extra_witness_data(self): @@ -1303,7 +1303,7 @@ def test_tx_relay_after_segwit_activation(self): assert_equal(raw_tx["weight"], tx3.get_weight()) assert_equal(len(raw_tx["vin"][0]["txinwitness"]), 1) assert_equal(raw_tx["vin"][0]["txinwitness"][0], witness_script.hex()) - assert vsize != raw_tx["size"] + assert_not_equal(vsize, raw_tx["size"]) # Cleanup: mine the transactions and update utxo for next test self.generate(self.nodes[0], 1) diff --git a/test/functional/p2p_sendtxrcncl.py b/test/functional/p2p_sendtxrcncl.py index c3ad407189e892..0a9fed46966916 100755 --- a/test/functional/p2p_sendtxrcncl.py +++ b/test/functional/p2p_sendtxrcncl.py @@ -122,7 +122,7 @@ def run_test(self): no_txrelay_version_msg.relay = 0 peer.send_message(no_txrelay_version_msg) peer.wait_for_verack() - assert peer.nServices & NODE_BLOOM != 0 + assert_not_equal(peer.nServices & NODE_BLOOM, 0) assert not peer.sendtxrcncl_msg_received self.nodes[0].disconnect_p2ps() diff --git a/test/functional/p2p_v2_transport.py b/test/functional/p2p_v2_transport.py index 9ae8575e84caf0..b09fe1a6e9e139 100755 --- a/test/functional/p2p_v2_transport.py +++ b/test/functional/p2p_v2_transport.py @@ -71,7 +71,7 @@ def run_test(self): self.connect_nodes(2, 3, peer_advertises_v2=False) self.generate(self.nodes[2], 8, sync_fun=lambda: self.sync_all(self.nodes[2:4])) assert_equal(self.nodes[3].getblockcount(), 8) - assert self.nodes[0].getbestblockhash() != self.nodes[2].getbestblockhash() + assert_not_equal(self.nodes[0].getbestblockhash(), self.nodes[2].getbestblockhash()) # verify there is a v1 connection between node 2 and 3 node_2_info = self.nodes[2].getpeerinfo() node_3_info = self.nodes[3].getpeerinfo() @@ -90,7 +90,7 @@ def run_test(self): self.connect_nodes(2, 1, peer_advertises_v2=False) # cannot enable v2 on v1 node self.sync_all(self.nodes[1:3]) assert_equal(self.nodes[1].getblockcount(), 8) - assert self.nodes[0].getbestblockhash() != self.nodes[1].getbestblockhash() + assert_not_equal(self.nodes[0].getbestblockhash(), self.nodes[1].getbestblockhash()) # verify there is a v1 connection between node 1 and 2 node_1_info = self.nodes[1].getpeerinfo() node_2_info = self.nodes[2].getpeerinfo() diff --git a/test/functional/rpc_blockchain.py b/test/functional/rpc_blockchain.py index cca71b0c37e41c..a6915b117eb6b3 100755 --- a/test/functional/rpc_blockchain.py +++ b/test/functional/rpc_blockchain.py @@ -383,7 +383,7 @@ def _test_gettxoutsetinfo(self): # hash_type muhash should return a different UTXO set hash. res6 = node.gettxoutsetinfo(hash_type='muhash') assert 'muhash' in res6 - assert res['hash_serialized_3'] != res6['muhash'] + assert_not_equal(res['hash_serialized_3'], res6['muhash']) # muhash should not be returned unless requested. for r in [res, res2, res3, res4, res5]: diff --git a/test/functional/rpc_preciousblock.py b/test/functional/rpc_preciousblock.py index 20a0f6e4b095c4..1bc9d4b76bf044 100755 --- a/test/functional/rpc_preciousblock.py +++ b/test/functional/rpc_preciousblock.py @@ -56,7 +56,7 @@ def run_test(self): self.log.info("Mine competing blocks E-F-G on Node 1") hashG = self.generate(self.nodes[1], 3, sync_fun=self.no_op)[-1] assert_equal(self.nodes[1].getblockcount(), 5) - assert hashC != hashG + assert_not_equal(hashC, hashG) self.log.info("Connect nodes and check no reorg occurs") # Submit competing blocks via RPC so any reorg should occur before we proceed (no way to wait on inaction for p2p sync) node_sync_via_rpc(self.nodes[0:2]) diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py index cb84357f0e7ca1..68e9d74f9b2199 100755 --- a/test/functional/rpc_psbt.py +++ b/test/functional/rpc_psbt.py @@ -293,7 +293,7 @@ def run_test(self): processed_finalized_psbt = self.nodes[0].walletprocesspsbt(psbt=psbtx, finalize=True) finalized_psbt = processed_finalized_psbt['psbt'] finalized_psbt_hex = processed_finalized_psbt['hex'] - assert signed_psbt != finalized_psbt + assert_not_equal(signed_psbt, finalized_psbt) assert finalized_psbt_hex == finalized_hex # Manually selected inputs can be locked: diff --git a/test/functional/test_framework/crypto/secp256k1.py b/test/functional/test_framework/crypto/secp256k1.py index 1b36406fb5678b..9d85d557a19378 100644 --- a/test/functional/test_framework/crypto/secp256k1.py +++ b/test/functional/test_framework/crypto/secp256k1.py @@ -41,7 +41,7 @@ def __init__(self, a=0, b=1): num = (num * b._den) % FE.SIZE else: den = (den * b) % FE.SIZE - assert den != 0 + assert_not_equal(den, 0) if num == 0: den = 1 self._num = num diff --git a/test/functional/test_framework/key.py b/test/functional/test_framework/key.py index ec37a315f8928c..682c2de35feb6c 100644 --- a/test/functional/test_framework/key.py +++ b/test/functional/test_framework/key.py @@ -283,7 +283,7 @@ def sign_schnorr(key, msg, aux=None, flip_p=False, flip_r=False): sec = ORDER - sec t = (sec ^ int.from_bytes(TaggedHash("BIP0340/aux", aux), 'big')).to_bytes(32, 'big') kp = int.from_bytes(TaggedHash("BIP0340/nonce", t + P.to_bytes_xonly() + msg), 'big') % ORDER - assert kp != 0 + assert_not_equal(kp, 0) R = kp * secp256k1.G k = kp if R.y.is_even() != flip_r else ORDER - kp e = int.from_bytes(TaggedHash("BIP0340/challenge", R.to_bytes_xonly() + P.to_bytes_xonly() + msg), 'big') % ORDER diff --git a/test/functional/test_framework/p2p.py b/test/functional/test_framework/p2p.py index 9b4e81f0d0ba0f..06978f851dae57 100755 --- a/test/functional/test_framework/p2p.py +++ b/test/functional/test_framework/p2p.py @@ -892,7 +892,7 @@ def send_blocks_and_test(self, blocks, node, *, success=True, force_send=False, if success: self.wait_until(lambda: node.getbestblockhash() == blocks[-1].hash, timeout=timeout) else: - assert node.getbestblockhash() != blocks[-1].hash + assert_not_equal(node.getbestblockhash(), blocks[-1].hash) def send_txs_and_test(self, txs, node, *, success=True, expect_disconnect=False, reject_reason=None): """Send txs to test node and test whether they're accepted to the mempool. diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py index 327ae59fb306aa..5f4d5ccf82ddb7 100755 --- a/test/functional/test_framework/test_node.py +++ b/test/functional/test_framework/test_node.py @@ -666,7 +666,7 @@ def assert_start_raises_init_error(self, extra_args=None, expected_msg=None, mat self.start(extra_args, stdout=log_stdout, stderr=log_stderr, *args, **kwargs) ret = self.process.wait(timeout=self.rpc_timeout) self.log.debug(self._node_msg(f'bitcoind exited with status {ret} during initialization')) - assert ret != 0 # Exit code must indicate failure + assert_not_equal(ret, 0) # Exit code must indicate failure self.running = False self.process = None # Check stderr for expected message diff --git a/test/functional/wallet_avoidreuse.py b/test/functional/wallet_avoidreuse.py index c8a6e354a5a4ea..5bd0438b0d7b3e 100755 --- a/test/functional/wallet_avoidreuse.py +++ b/test/functional/wallet_avoidreuse.py @@ -167,7 +167,7 @@ def test_change_remains_change(self, node): # Make sure it's starting out as change as expected assert node.getaddressinfo(changeaddr)['ischange'] for logical_tx in node.listtransactions(): - assert logical_tx.get('address') != changeaddr + assert_not_equal(logical_tx.get('address'), changeaddr) # Spend it reset_balance(node, node.getnewaddress()) @@ -175,7 +175,7 @@ def test_change_remains_change(self, node): # It should still be change assert node.getaddressinfo(changeaddr)['ischange'] for logical_tx in node.listtransactions(): - assert logical_tx.get('address') != changeaddr + assert_not_equal(logical_tx.get('address'), changeaddr) def test_sending_from_reused_address_without_avoid_reuse(self): ''' diff --git a/test/functional/wallet_descriptor.py b/test/functional/wallet_descriptor.py index 62fdee69a724b4..6132cccaf3b412 100755 --- a/test/functional/wallet_descriptor.py +++ b/test/functional/wallet_descriptor.py @@ -171,7 +171,7 @@ def run_test(self): with WalletUnlock(send_wrpc, "pass"): addr = send_wrpc.getnewaddress() info2 = send_wrpc.getaddressinfo(addr) - assert info1['hdmasterfingerprint'] != info2['hdmasterfingerprint'] + assert_not_equal(info1['hdmasterfingerprint'], info2['hdmasterfingerprint']) assert 'hdmasterfingerprint' in send_wrpc.getaddressinfo(send_wrpc.getnewaddress()) info3 = send_wrpc.getaddressinfo(addr) assert_equal(info2['desc'], info3['desc']) diff --git a/test/functional/wallet_dump.py b/test/functional/wallet_dump.py index 21ce42a0119442..3e1488ec2e9f67 100755 --- a/test/functional/wallet_dump.py +++ b/test/functional/wallet_dump.py @@ -57,7 +57,7 @@ def read_dump(file_name, addrs, script_addrs, hd_master_addr_old): assert hd_master_addr_old == addr elif keytype == "hdseed=1": # ensure we have generated a new hd master key - assert hd_master_addr_old != addr + assert_not_equal(hd_master_addr_old, addr) hd_master_addr_ret = addr elif keytype == "script=1": # scripts don't have keypaths diff --git a/test/functional/wallet_fundrawtransaction.py b/test/functional/wallet_fundrawtransaction.py index 05b5696530e318..096558c4ef4c64 100755 --- a/test/functional/wallet_fundrawtransaction.py +++ b/test/functional/wallet_fundrawtransaction.py @@ -658,7 +658,7 @@ def test_locked_wallet(self): outputs = {self.nodes[0].getnewaddress():1.1} rawtx = wallet.createrawtransaction(inputs, outputs) fundedTx = wallet.fundrawtransaction(rawtx) - assert fundedTx["changepos"] != -1 + assert_not_equal(fundedTx["changepos"], -1) # Now we need to unlock. with WalletUnlock(wallet, "test"): @@ -901,10 +901,10 @@ def test_address_reuse(self): for out in res_dec['vout']: if out['value'] > 1.0: changeaddress += out['scriptPubKey']['address'] - assert changeaddress != "" + assert_not_equal(changeaddress, "") nextaddr = self.nodes[3].getnewaddress() # Now the change address key should be removed from the keypool. - assert changeaddress != nextaddr + assert_not_equal(changeaddress, nextaddr) def test_option_subtract_fee_from_outputs(self): self.log.info("Test fundrawtxn subtractFeeFromOutputs option") diff --git a/test/functional/wallet_gethdkeys.py b/test/functional/wallet_gethdkeys.py index eec039589058d7..920e0045763fb1 100755 --- a/test/functional/wallet_gethdkeys.py +++ b/test/functional/wallet_gethdkeys.py @@ -60,7 +60,7 @@ def test_basic_gethdkeys(self): # New key is active, should be able to get only that one and its descriptors xpub_info = wallet.gethdkeys(active_only=True) assert_equal(len(xpub_info), 1) - assert xpub_info[0]["xpub"] != xpub + assert_not_equal(xpub_info[0]["xpub"], xpub) assert "xprv" not in xpub_info[0] assert_equal(xpub_info[0]["has_private"], True) @@ -68,7 +68,7 @@ def test_basic_gethdkeys(self): assert_raises_rpc_error(-13, "Error: Please enter the wallet passphrase with walletpassphrase first", wallet.gethdkeys, private=True) with WalletUnlock(wallet, "pass"): xpub_info = wallet.gethdkeys(active_only=True, private=True)[0] - assert xpub_info["xprv"] != xprv + assert_not_equal(xpub_info["xprv"], xprv) for desc in wallet.listdescriptors(True)["descriptors"]: if desc["active"]: # After encrypting, HD key was rotated and should appear in all active descriptors diff --git a/test/functional/wallet_hd.py b/test/functional/wallet_hd.py index 602a2f52c9ca53..7822830810193d 100755 --- a/test/functional/wallet_hd.py +++ b/test/functional/wallet_hd.py @@ -151,7 +151,7 @@ def run_test(self): orig_masterkeyid = self.nodes[1].getwalletinfo()['hdseedid'] self.nodes[1].sethdseed() new_masterkeyid = self.nodes[1].getwalletinfo()['hdseedid'] - assert orig_masterkeyid != new_masterkeyid + assert_not_equal(orig_masterkeyid, new_masterkeyid) addr = self.nodes[1].getnewaddress() # Make sure the new address is the first from the keypool assert_equal(self.nodes[1].getaddressinfo(addr)['hdkeypath'], 'm/0\'/0\'/0\'') @@ -162,7 +162,7 @@ def run_test(self): orig_masterkeyid = new_masterkeyid self.nodes[1].sethdseed(False, new_seed) new_masterkeyid = self.nodes[1].getwalletinfo()['hdseedid'] - assert orig_masterkeyid != new_masterkeyid + assert_not_equal(orig_masterkeyid, new_masterkeyid) addr = self.nodes[1].getnewaddress() assert_equal(orig_masterkeyid, self.nodes[1].getaddressinfo(addr)['hdseedid']) # Make sure the new address continues previous keypool @@ -174,7 +174,7 @@ def run_test(self): assert_equal(new_masterkeyid, self.nodes[1].getaddressinfo(next_addr)['hdseedid']) # Make sure the new address is not from previous keypool assert_equal(self.nodes[1].getaddressinfo(next_addr)['hdkeypath'], 'm/0\'/0\'/0\'') - assert next_addr != addr + assert_not_equal(next_addr, addr) # Sethdseed parameter validity assert_raises_rpc_error(-1, 'sethdseed', self.nodes[0].sethdseed, False, new_seed, 0) diff --git a/test/functional/wallet_keypool.py b/test/functional/wallet_keypool.py index a969ec2709634b..360c8430e0f859 100755 --- a/test/functional/wallet_keypool.py +++ b/test/functional/wallet_keypool.py @@ -84,7 +84,7 @@ def run_test(self): addr = nodes[0].getnewaddress() addr_data = nodes[0].getaddressinfo(addr) wallet_info = nodes[0].getwalletinfo() - assert addr_before_encrypting_data['hdmasterfingerprint'] != addr_data['hdmasterfingerprint'] + assert_not_equal(addr_before_encrypting_data['hdmasterfingerprint'], addr_data['hdmasterfingerprint']) if not self.options.descriptors: assert addr_data['hdseedid'] == wallet_info['hdseedid'] assert_raises_rpc_error(-12, "Error: Keypool ran out, please call keypoolrefill first", nodes[0].getnewaddress) diff --git a/test/functional/wallet_listdescriptors.py b/test/functional/wallet_listdescriptors.py index b4512c31118f23..2abd19314339ab 100755 --- a/test/functional/wallet_listdescriptors.py +++ b/test/functional/wallet_listdescriptors.py @@ -54,7 +54,7 @@ def run_test(self): assert_equal(8, len([d for d in result['descriptors'] if d['active']])) assert_equal(4, len([d for d in result['descriptors'] if d['internal']])) for item in result['descriptors']: - assert item['desc'] != '' + assert_not_equal(item['desc'], '') assert item['next_index'] == 0 assert item['range'] == [0, 0] assert item['timestamp'] is not None diff --git a/test/functional/wallet_listtransactions.py b/test/functional/wallet_listtransactions.py index b1874b7bd72ef7..7cbd8f59f95db7 100755 --- a/test/functional/wallet_listtransactions.py +++ b/test/functional/wallet_listtransactions.py @@ -309,7 +309,7 @@ def run_coinjoin_test(self): fee_join = self.nodes[0].getmempoolentry(txid_join)["fees"]["base"] # Fee should be correct: assert_equal(fee_join, self.nodes[0].gettransaction(txid_join)['fee']) # But it is not, see for example https://github.com/bitcoin/bitcoin/issues/14136: - assert fee_join != self.nodes[0].gettransaction(txid_join)["fee"] + assert_not_equal(fee_join, self.nodes[0].gettransaction(txid_join)["fee"]) def run_invalid_parameters_test(self): self.log.info("Test listtransactions RPC parameter validity") diff --git a/test/functional/wallet_reorgsrestore.py b/test/functional/wallet_reorgsrestore.py index f1785e6336c194..4ffd617a887ba7 100755 --- a/test/functional/wallet_reorgsrestore.py +++ b/test/functional/wallet_reorgsrestore.py @@ -95,11 +95,11 @@ def run_test(self): tx_after_reorg = self.nodes[1].gettransaction(txid) # Check that normal confirmed tx is confirmed again but with different blockhash assert_equal(tx_after_reorg["confirmations"], 2) - assert tx_before_reorg["blockhash"] != tx_after_reorg["blockhash"] + assert_not_equal(tx_before_reorg["blockhash"], tx_after_reorg["blockhash"]) conflicted_after_reorg = self.nodes[1].gettransaction(conflicted_txid) # Check that conflicted tx is confirmed again with blockhash different than previously conflicting tx assert_equal(conflicted_after_reorg["confirmations"], 1) - assert conflicting["blockhash"] != conflicted_after_reorg["blockhash"] + assert_not_equal(conflicting["blockhash"], conflicted_after_reorg["blockhash"]) if __name__ == '__main__': ReorgsRestoreTest(__file__).main() diff --git a/test/functional/wallet_send.py b/test/functional/wallet_send.py index 4be6ae9ba1cd0f..ccf86b96cc0f2f 100755 --- a/test/functional/wallet_send.py +++ b/test/functional/wallet_send.py @@ -47,7 +47,7 @@ def test_send(self, from_wallet, to_wallet=None, amount=None, data=None, inputs=None, add_inputs=None, include_unsafe=None, change_address=None, change_position=None, change_type=None, include_watching=None, locktime=None, lock_unspents=None, replaceable=None, subtract_fee_from_outputs=None, expect_error=None, solving_data=None, minconf=None): - assert (amount is None) != (data is None) + assert_not_equal((amount is None), (data is None)) from_balance_before = from_wallet.getbalances()["mine"]["trusted"] if include_unsafe: