From e124ea8becbcea2510275f5985711e57a5499ef4 Mon Sep 17 00:00:00 2001 From: wu-emma Date: Mon, 29 Apr 2024 12:38:51 +0400 Subject: [PATCH] Update test/functional --- test/functional/feature_assumeutxo.py | 4 ++-- test/functional/feature_filelock.py | 2 +- test/functional/feature_maxuploadtarget.py | 2 +- test/functional/feature_reindex_readonly.py | 4 ++-- test/functional/feature_settings.py | 2 +- test/functional/interface_zmq.py | 2 +- test/functional/mempool_accept_v3.py | 4 ++-- test/functional/p2p_handshake.py | 4 ++-- test/functional/p2p_ibd_txrelay.py | 17 ++++++++++++++++- test/functional/p2p_mutated_blocks.py | 4 ++-- test/functional/p2p_v2_earlykeyresponse.py | 4 ++-- test/functional/p2p_v2_encrypted.py | 4 ++-- test/functional/p2p_v2_transport.py | 4 ++-- test/functional/rpc_blockchain.py | 2 +- test/functional/rpc_deriveaddresses.py | 2 +- test/functional/test_framework/messages.py | 14 +++++++------- test/functional/test_framework/wallet.py | 2 +- test/functional/tool_wallet.py | 2 +- test/functional/wallet_assumeutxo.py | 4 ++-- test/functional/wallet_rescan_unconfirmed.py | 4 ++-- test/functional/wallet_sendmany.py | 4 ++-- test/functional/wallet_spend_unconfirmed.py | 4 ++-- 22 files changed, 55 insertions(+), 40 deletions(-) diff --git a/test/functional/feature_assumeutxo.py b/test/functional/feature_assumeutxo.py index 293b1a61bf..071a9254f0 100755 --- a/test/functional/feature_assumeutxo.py +++ b/test/functional/feature_assumeutxo.py @@ -36,7 +36,7 @@ from dataclasses import dataclass from test_framework.messages import tx_from_hex -from test_framework.test_framework import BitcoinTestFramework +from test_framework.test_framework import BGLTestFramework from test_framework.util import ( assert_equal, assert_raises_rpc_error, @@ -52,7 +52,7 @@ COMPLETE_IDX = {'synced': True, 'best_block_height': FINAL_HEIGHT} -class AssumeutxoTest(BitcoinTestFramework): +class AssumeutxoTest(BGLTestFramework): def set_test_params(self): """Use the pregenerated, deterministic chain up to height 199.""" diff --git a/test/functional/feature_filelock.py b/test/functional/feature_filelock.py index 8aa2e0e531..683bcf0127 100755 --- a/test/functional/feature_filelock.py +++ b/test/functional/feature_filelock.py @@ -33,7 +33,7 @@ def run_test(self): self.log.info("Check that cookie and PID file are not deleted when attempting to start a second bitcoind using the same datadir") cookie_file = datadir / ".cookie" assert cookie_file.exists() # should not be deleted during the second bitcoind instance shutdown - pid_file = datadir / "bitcoind.pid" + pid_file = datadir / "BGLd.pid" assert pid_file.exists() if self.is_wallet_compiled(): diff --git a/test/functional/feature_maxuploadtarget.py b/test/functional/feature_maxuploadtarget.py index 26915490c6..90da11180a 100755 --- a/test/functional/feature_maxuploadtarget.py +++ b/test/functional/feature_maxuploadtarget.py @@ -109,7 +109,7 @@ def run_test(self): getdata_request.inv.append(CInv(MSG_BLOCK, big_old_block)) max_bytes_per_day = UPLOAD_TARGET_MB * 1024 *1024 - daily_buffer = 144 * 4000000 + daily_buffer = 144 * 400000 max_bytes_available = max_bytes_per_day - daily_buffer success_count = max_bytes_available // old_block_size # 576MB will be reserved for relaying new blocks, so expect this to diff --git a/test/functional/feature_reindex_readonly.py b/test/functional/feature_reindex_readonly.py index 25cff87a3b..db3d30dd99 100755 --- a/test/functional/feature_reindex_readonly.py +++ b/test/functional/feature_reindex_readonly.py @@ -9,10 +9,10 @@ import os import stat import subprocess -from test_framework.test_framework import BitcoinTestFramework +from test_framework.test_framework import BGLTestFramework -class BlockstoreReindexTest(BitcoinTestFramework): +class BlockstoreReindexTest(BGLTestFramework): def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 1 diff --git a/test/functional/feature_settings.py b/test/functional/feature_settings.py index 6a8090c9ab..afd3c0527c 100755 --- a/test/functional/feature_settings.py +++ b/test/functional/feature_settings.py @@ -25,7 +25,7 @@ def run_test(self): # Assert default settings file was created self.stop_node(0) - default_settings = {"_warning_": "This file is automatically generated and updated by Bitcoin Core. Please do not edit this file while the node is running, as any changes might be ignored or overwritten."} + default_settings = {"_warning_": "This file is automatically generated and updated by Bitgesell Core. Please do not edit this file while the node is running, as any changes might be ignored or overwritten."} with settings.open() as fp: assert_equal(json.load(fp), default_settings) diff --git a/test/functional/interface_zmq.py b/test/functional/interface_zmq.py index 2fd1a75364..c7565b2278 100755 --- a/test/functional/interface_zmq.py +++ b/test/functional/interface_zmq.py @@ -213,7 +213,7 @@ def test_basic(self): assert block.is_valid() assert_equal(block.vtx[0].hash, tx.hash) assert_equal(len(block.vtx), 1) - assert_equal(genhashes[x], hash256_reversed(hex[:80]).hex()) + assert_equal(genhashes[x], keccak256_reversed(hex[:80]).hex()) # Should receive the generated block hash. hash = hashblock.receive().hex() diff --git a/test/functional/mempool_accept_v3.py b/test/functional/mempool_accept_v3.py index 1b55cd0a0d..3d57b7dbbd 100755 --- a/test/functional/mempool_accept_v3.py +++ b/test/functional/mempool_accept_v3.py @@ -7,7 +7,7 @@ from test_framework.messages import ( MAX_BIP125_RBF_SEQUENCE, ) -from test_framework.test_framework import BitcoinTestFramework +from test_framework.test_framework import BGLTestFramework from test_framework.util import ( assert_equal, assert_greater_than, @@ -37,7 +37,7 @@ def wrapper(self): return wrapper return decorator -class MempoolAcceptV3(BitcoinTestFramework): +class MempoolAcceptV3(BGLTestFramework): def set_test_params(self): self.num_nodes = 1 self.extra_args = [["-acceptnonstdtxn=1"]] diff --git a/test/functional/p2p_handshake.py b/test/functional/p2p_handshake.py index f0b62e291d..bc60c3f3f6 100755 --- a/test/functional/p2p_handshake.py +++ b/test/functional/p2p_handshake.py @@ -8,7 +8,7 @@ import itertools import time -from test_framework.test_framework import BitcoinTestFramework +from test_framework.test_framework import BGLTestFramework from test_framework.messages import ( NODE_NETWORK, NODE_NETWORK_LIMITED, @@ -27,7 +27,7 @@ DESIRABLE_SERVICE_FLAGS_PRUNED = NODE_NETWORK_LIMITED | NODE_WITNESS -class P2PHandshakeTest(BitcoinTestFramework): +class P2PHandshakeTest(BGLTestFramework): def set_test_params(self): self.num_nodes = 1 diff --git a/test/functional/p2p_ibd_txrelay.py b/test/functional/p2p_ibd_txrelay.py index dceba859e3..4f2f7985bb 100755 --- a/test/functional/p2p_ibd_txrelay.py +++ b/test/functional/p2p_ibd_txrelay.py @@ -5,8 +5,23 @@ """Test fee filters during and after IBD.""" from decimal import Decimal +import time -from test_framework.messages import COIN +from test_framework.messages import ( + CInv, + COIN, + CTransaction, + from_hex, + msg_inv, + msg_tx, + MSG_WTX, +) +from test_framework.p2p import ( + NONPREF_PEER_TX_DELAY, + P2PDataStore, + P2PInterface, + p2p_lock +) from test_framework.test_framework import BGLTestFramework MAX_FEE_FILTER = Decimal(9170997) / COIN diff --git a/test/functional/p2p_mutated_blocks.py b/test/functional/p2p_mutated_blocks.py index 737edaf5bf..0ad7ec3618 100755 --- a/test/functional/p2p_mutated_blocks.py +++ b/test/functional/p2p_mutated_blocks.py @@ -16,7 +16,7 @@ msg_blocktxn, HeaderAndShortIDs, ) -from test_framework.test_framework import BitcoinTestFramework +from test_framework.test_framework import BGLTestFramework from test_framework.blocktools import ( COINBASE_MATURITY, create_block, @@ -27,7 +27,7 @@ from test_framework.wallet import MiniWallet import copy -class MutatedBlocksTest(BitcoinTestFramework): +class MutatedBlocksTest(BGLTestFramework): def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 1 diff --git a/test/functional/p2p_v2_earlykeyresponse.py b/test/functional/p2p_v2_earlykeyresponse.py index 32d2e1148a..866e3369d3 100755 --- a/test/functional/p2p_v2_earlykeyresponse.py +++ b/test/functional/p2p_v2_earlykeyresponse.py @@ -5,7 +5,7 @@ import random -from test_framework.test_framework import BitcoinTestFramework +from test_framework.test_framework import BGLTestFramework from test_framework.crypto.ellswift import ellswift_create from test_framework.p2p import P2PInterface from test_framework.v2_p2p import EncryptedP2PState @@ -63,7 +63,7 @@ def data_received(self, t): def on_open(self): self.connection_opened = True -class P2PEarlyKey(BitcoinTestFramework): +class P2PEarlyKey(BGLTestFramework): def set_test_params(self): self.num_nodes = 1 self.extra_args = [["-v2transport=1", "-peertimeout=3"]] diff --git a/test/functional/p2p_v2_encrypted.py b/test/functional/p2p_v2_encrypted.py index 05755dece0..bca326accb 100755 --- a/test/functional/p2p_v2_encrypted.py +++ b/test/functional/p2p_v2_encrypted.py @@ -13,7 +13,7 @@ P2PDataStore, P2PInterface, ) -from test_framework.test_framework import BitcoinTestFramework +from test_framework.test_framework import BGLTestFramework from test_framework.util import ( assert_equal, assert_greater_than, @@ -22,7 +22,7 @@ from test_framework.crypto.chacha20 import REKEY_INTERVAL -class P2PEncrypted(BitcoinTestFramework): +class P2PEncrypted(BGLTestFramework): def set_test_params(self): self.num_nodes = 2 self.extra_args = [["-v2transport=1"], ["-v2transport=1"]] diff --git a/test/functional/p2p_v2_transport.py b/test/functional/p2p_v2_transport.py index fe2449124d..7fb55a7d53 100755 --- a/test/functional/p2p_v2_transport.py +++ b/test/functional/p2p_v2_transport.py @@ -8,7 +8,7 @@ import socket from test_framework.messages import MAGIC_BYTES, NODE_P2P_V2 -from test_framework.test_framework import BitcoinTestFramework +from test_framework.test_framework import BGLTestFramework from test_framework.util import ( assert_equal, p2p_port, @@ -16,7 +16,7 @@ ) -class V2TransportTest(BitcoinTestFramework): +class V2TransportTest(BGLTestFramework): def set_test_params(self): self.setup_clean_chain = True self.num_nodes = 5 diff --git a/test/functional/rpc_blockchain.py b/test/functional/rpc_blockchain.py index 1b8584491c..e834cdcc48 100755 --- a/test/functional/rpc_blockchain.py +++ b/test/functional/rpc_blockchain.py @@ -58,7 +58,7 @@ TIME_RANGE_MTP = TIME_GENESIS_BLOCK + (HEIGHT - 6) * TIME_RANGE_STEP TIME_RANGE_TIP = TIME_GENESIS_BLOCK + (HEIGHT - 1) * TIME_RANGE_STEP TIME_RANGE_END = TIME_GENESIS_BLOCK + HEIGHT * TIME_RANGE_STEP -DIFFICULTY_ADJUSTMENT_INTERVAL = 2016 +DIFFICULTY_ADJUSTMENT_INTERVAL = 144 class BlockchainTest(BGLTestFramework): diff --git a/test/functional/rpc_deriveaddresses.py b/test/functional/rpc_deriveaddresses.py index 911ef665ec..a20356beee 100755 --- a/test/functional/rpc_deriveaddresses.py +++ b/test/functional/rpc_deriveaddresses.py @@ -42,7 +42,7 @@ def run_test(self): assert_raises_rpc_error(-8, "Range should be greater or equal than 0", self.nodes[0].deriveaddresses, descsum_create("wpkh(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/1/1/*)"), [-1, 0]) combo_descriptor = descsum_create("combo(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK/1/1/0)") - assert_equal(self.nodes[0].deriveaddresses(combo_descriptor), ["mtfUoUax9L4tzXARpw1oTGxWyoogp52KhJ", address, "2NDvEwGfpEqJWfybzpKPHF2XH3jwoQV3D7x"]) + assert_equal(self.nodes[0].deriveaddresses(combo_descriptor), ["Eue2z7dmUSPS29RkwdNG7czwWxy48pNHSq", address, "MUaBBR9kaVebGhFMF4kkSinRA6L5aRtPoC"]) # P2PK does not have a valid address assert_raises_rpc_error(-5, "Descriptor does not have a corresponding address", self.nodes[0].deriveaddresses, descsum_create("pk(tprv8ZgxMBicQKsPd7Uf69XL1XwhmjHopUGep8GuEiJDZmbQz6o58LninorQAfcKZWARbtRtfnLcJ5MQ2AtHcQJCCRUcMRvmDUjyEmNUWwx8UbK)")) diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py index 6f38e0a6e5..ed4dd3422b 100755 --- a/test/functional/test_framework/messages.py +++ b/test/functional/test_framework/messages.py @@ -29,6 +29,8 @@ import time import unittest +import sha3 + from test_framework.crypto.siphash import siphash256 from test_framework.util import assert_equal @@ -86,14 +88,12 @@ def keccak256(s): return h.digest() MAGIC_BYTES = { - "mainnet": b"\xf9\xbe\xb4\xd9", # mainnet + "mainnet": b"\x8a\xb4\x91\xe8", # mainnet "testnet3": b"\x0b\x11\x09\x07", # testnet3 - "regtest": b"\xfa\xbf\xb5\xda", # regtest - "signet": b"\x0a\x03\xcf\x40", # signet + "regtest": b"\xd9\x8c\xbf\xba", # regtest + "signet": b"\x0a\x03\xcf\x40", # signet } -def sha256(s): - return hashlib.sha256(s).digest() def sha256(s): return hashlib.new('sha256', s).digest() @@ -748,8 +748,8 @@ def calc_sha256(self): r += self.nTime.to_bytes(4, "little") r += self.nBits.to_bytes(4, "little") r += self.nNonce.to_bytes(4, "little") - self.sha256 = uint256_from_str(hash256(r)) - self.hash = hash256(r)[::-1].hex() + self.sha256 = uint256_from_str(keccak256(r)) + self.hash = keccak256(r)[::-1].hex() def rehash(self): self.sha256 = None diff --git a/test/functional/test_framework/wallet.py b/test/functional/test_framework/wallet.py index 0655abbc9a..b0e0ce2987 100644 --- a/test/functional/test_framework/wallet.py +++ b/test/functional/test_framework/wallet.py @@ -102,7 +102,7 @@ def __init__(self, test_node, *, mode=MiniWalletMode.ADDRESS_OP_TRUE): # When the pre-mined test framework chain is used, it contains coinbase # outputs to the MiniWallet's default address in blocks 76-100 - # (see method BitcoinTestFramework._initialize_chain()) + # (see method BGLTestFramework._initialize_chain()) # The MiniWallet needs to rescan_utxos() in order to account # for those mature UTXOs, so that all txs spend confirmed coins self.rescan_utxos() diff --git a/test/functional/tool_wallet.py b/test/functional/tool_wallet.py index 7fdd4a5d6b..c13d131424 100755 --- a/test/functional/tool_wallet.py +++ b/test/functional/tool_wallet.py @@ -337,7 +337,7 @@ def test_dump_createfromdump(self): self.log.info('Checking basic dump') wallet_dump = self.nodes[0].datadir_path / "wallet.dump" - self.assert_tool_output('The dumpfile may contain private keys. To ensure the safety of your Bitgesell, do not share the dumpfile.\n', '-wallet=todump', '-dumpfile={}'.format(wallet_dump), 'dump') + self.assert_tool_output('The dumpfile may contain private keys. To ensure the safety of your BGL, do not share the dumpfile.\n', '-wallet=todump', '-dumpfile={}'.format(wallet_dump), 'dump') dump_data = self.read_dump(wallet_dump) orig_dump = dump_data.copy() diff --git a/test/functional/wallet_assumeutxo.py b/test/functional/wallet_assumeutxo.py index 30396da015..718b07c494 100755 --- a/test/functional/wallet_assumeutxo.py +++ b/test/functional/wallet_assumeutxo.py @@ -11,7 +11,7 @@ - TODO: test loading a wallet (backup) on a pruned node """ -from test_framework.test_framework import BitcoinTestFramework +from test_framework.test_framework import BGLTestFramework from test_framework.util import ( assert_equal, assert_raises_rpc_error, @@ -23,7 +23,7 @@ FINAL_HEIGHT = 399 -class AssumeutxoTest(BitcoinTestFramework): +class AssumeutxoTest(BGLTestFramework): def skip_test_if_missing_module(self): self.skip_if_no_wallet() diff --git a/test/functional/wallet_rescan_unconfirmed.py b/test/functional/wallet_rescan_unconfirmed.py index ad9fa081c2..a4f1de9e62 100755 --- a/test/functional/wallet_rescan_unconfirmed.py +++ b/test/functional/wallet_rescan_unconfirmed.py @@ -9,13 +9,13 @@ ADDRESS_BCRT1_UNSPENDABLE, ) from test_framework.messages import COIN -from test_framework.test_framework import BitcoinTestFramework +from test_framework.test_framework import BGLTestFramework from test_framework.util import assert_equal from test_framework.wallet import MiniWallet from test_framework.wallet_util import test_address -class WalletRescanUnconfirmed(BitcoinTestFramework): +class WalletRescanUnconfirmed(BGLTestFramework): def add_options(self, parser): self.add_wallet_options(parser, legacy=False) diff --git a/test/functional/wallet_sendmany.py b/test/functional/wallet_sendmany.py index 5751993143..063502c4c9 100755 --- a/test/functional/wallet_sendmany.py +++ b/test/functional/wallet_sendmany.py @@ -4,9 +4,9 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. """Test the sendmany RPC command.""" -from test_framework.test_framework import BitcoinTestFramework +from test_framework.test_framework import BGLTestFramework -class SendmanyTest(BitcoinTestFramework): +class SendmanyTest(BGLTestFramework): # Setup and helpers def add_options(self, parser): self.add_wallet_options(parser) diff --git a/test/functional/wallet_spend_unconfirmed.py b/test/functional/wallet_spend_unconfirmed.py index bfcdeaeaa8..387eaf3118 100755 --- a/test/functional/wallet_spend_unconfirmed.py +++ b/test/functional/wallet_spend_unconfirmed.py @@ -5,14 +5,14 @@ from decimal import Decimal, getcontext -from test_framework.test_framework import BitcoinTestFramework +from test_framework.test_framework import BGLTestFramework from test_framework.util import ( assert_greater_than_or_equal, assert_equal, find_vout_for_address, ) -class UnconfirmedInputTest(BitcoinTestFramework): +class UnconfirmedInputTest(BGLTestFramework): def add_options(self, parser): self.add_wallet_options(parser)