Skip to content

Commit

Permalink
Update test/functional
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-emma committed Apr 29, 2024
1 parent 0013ab2 commit e124ea8
Show file tree
Hide file tree
Showing 22 changed files with 55 additions and 40 deletions.
4 changes: 2 additions & 2 deletions test/functional/feature_assumeutxo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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."""
Expand Down
2 changes: 1 addition & 1 deletion test/functional/feature_filelock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion test/functional/feature_maxuploadtarget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_reindex_readonly.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/functional/feature_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion test/functional/interface_zmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions test/functional/mempool_accept_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"]]
Expand Down
4 changes: 2 additions & 2 deletions test/functional/p2p_handshake.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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

Expand Down
17 changes: 16 additions & 1 deletion test/functional/p2p_ibd_txrelay.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/functional/p2p_mutated_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/functional/p2p_v2_earlykeyresponse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]]
Expand Down
4 changes: 2 additions & 2 deletions test/functional/p2p_v2_encrypted.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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"]]
Expand Down
4 changes: 2 additions & 2 deletions test/functional/p2p_v2_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
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,
assert_raises_rpc_error
)


class V2TransportTest(BitcoinTestFramework):
class V2TransportTest(BGLTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 5
Expand Down
2 changes: 1 addition & 1 deletion test/functional/rpc_blockchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion test/functional/rpc_deriveaddresses.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)"))
Expand Down
14 changes: 7 additions & 7 deletions test/functional/test_framework/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import time
import unittest

import sha3

from test_framework.crypto.siphash import siphash256
from test_framework.util import assert_equal

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/functional/test_framework/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion test/functional/tool_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions test/functional/wallet_assumeutxo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions test/functional/wallet_rescan_unconfirmed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions test/functional/wallet_sendmany.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions test/functional/wallet_spend_unconfirmed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit e124ea8

Please sign in to comment.