Skip to content

Commit

Permalink
Merge pull request #83 from madnadyka/functional_tests_actualization
Browse files Browse the repository at this point in the history
actualize functional tests
  • Loading branch information
madnadyka authored Jul 8, 2022
2 parents 29eed96 + 76a046d commit ea3713b
Show file tree
Hide file tree
Showing 49 changed files with 187 additions and 242 deletions.
2 changes: 2 additions & 0 deletions src/rpc/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "gettxout", 1, "n" },
{ "gettxout", 2, "include_mempool" },
{ "gettxoutproof", 0, "txids" },
{ "gettxoutsetinfo", 1, "hash_or_height" },
{ "gettxoutsetinfo", 2, "use_index"},
{ "lockunspent", 0, "unlock" },
{ "lockunspent", 1, "transactions" },
{ "lockunspent", 2, "persistent" },
Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_addrman.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from test_framework.messages import ser_uint256, hash256
from test_framework.p2p import MAGIC_BYTES
from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_framework import BGLTestFramework
from test_framework.test_node import ErrorMatch
from test_framework.util import assert_equal

Expand Down Expand Up @@ -48,7 +48,7 @@ def write_addrman(peers_dat, **kwargs):
f.write(serialize_addrman(**kwargs))


class AddrmanTest(BitcoinTestFramework):
class AddrmanTest(BGLTestFramework):
def set_test_params(self):
self.num_nodes = 1

Expand Down
7 changes: 3 additions & 4 deletions test/functional/feature_asmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ def test_asmap_with_relative_path(self):
name = 'ASN_map'
filename = os.path.join(self.datadir, name)
shutil.copyfile(self.asmap_raw, filename)

with self.node.assert_debug_log(expected_messages(filename)):
self.start_node(0, [f'-asmap={name}'])
os.remove(filename)
Expand All @@ -82,16 +81,16 @@ def test_default_asmap(self):
os.remove(self.default_asmap)

def test_asmap_interaction_with_addrman_containing_entries(self):
self.log.info("Test bitcoind -asmap restart with addrman containing new and tried entries")
self.log.info("Test BGLd -asmap restart with addrman containing new and tried entries")
self.stop_node(0)
shutil.copyfile(self.asmap_raw, self.default_asmap)
self.start_node(0, ["-asmap", "-checkaddrman=1"])
self.fill_addrman(node_id=0)
self.restart_node(0, ["-asmap", "-checkaddrman=1"])
with self.node.assert_debug_log(
expected_msgs=[
"Addrman checks started: new 1, tried 1, total 2",
"Addrman checks completed successfully",
"CheckAddrman: new 1, tried 1, total 2 started",
"CheckAddrman: completed",
]
):
self.node.getnodeaddresses() # getnodeaddresses re-runs the addrman checks
Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_bind_extra.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
get_bind_addrs,
)
from test_framework.test_framework import (
BitcoinTestFramework,
BGLTestFramework,
SkipTest,
)
from test_framework.util import (
Expand All @@ -24,7 +24,7 @@
rpc_port,
)

class BindExtraTest(BitcoinTestFramework):
class BindExtraTest(BGLTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
# Avoid any -bind= on the command line. Force the framework to avoid
Expand Down
67 changes: 0 additions & 67 deletions test/functional/feature_blockfilterindex_prune.py

This file was deleted.

13 changes: 2 additions & 11 deletions test/functional/feature_cltv.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test BIP65 (CHECKLOCKTIMEVERIFY).
Test that the CHECKLOCKTIMEVERIFY soft-fork activates.
"""

Expand Down Expand Up @@ -67,10 +66,6 @@ def cltv_invalidate(tx, failure_reason):

cltv_modify_tx(tx, prepend_scriptsig=scheme[0], nsequence=scheme[1], nlocktime=scheme[2])

TODO: test more ways that transactions using CLTV could be invalid (eg
locktime requirements fail, sequence time requirements fail, etc).
'''
cltv_modify_tx(None, tx, [OP_1NEGATE, OP_CHECKLOCKTIMEVERIFY, OP_DROP])

def cltv_validate(tx, height):
# Modify the signature in vin 0 and nSequence/nLockTime of the tx to pass CLTV
Expand Down Expand Up @@ -124,10 +119,7 @@ def run_test(self):

tip = self.nodes[0].getbestblockhash()
block_time = self.nodes[0].getblockheader(tip)['mediantime'] + 1
block = create_block(int(tip, 16), create_coinbase(CLTV_HEIGHT - 1), block_time)
block.nVersion = 3
block.vtx.extend(invalid_cltv_txs)
block.hashMerkleRoot = block.calc_merkle_root()
block = create_block(int(tip, 16), create_coinbase(CLTV_HEIGHT - 1), block_time, version=3, txlist=invalid_cltv_txs)
block.solve()

self.test_cltv_info(is_active=False) # Not active as of current tip and next block does not need to obey rules
Expand All @@ -138,8 +130,7 @@ def run_test(self):
self.log.info("Test that blocks must now be at least version 4")
tip = block.sha256
block_time += 1
block = create_block(tip, create_coinbase(CLTV_HEIGHT), block_time)
block.nVersion = 3
block = create_block(tip, create_coinbase(CLTV_HEIGHT), block_time, version=3)
block.solve()

with self.nodes[0].assert_debug_log(expected_msgs=[f'{block.hash}, bad-version(0x00000003)']):
Expand Down
2 changes: 1 addition & 1 deletion test/functional/feature_csv_activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def all_rlt_txs(txs):
CSV_ACTIVATION_HEIGHT = 432


class BIP68_112_113Test(BitcoinTestFramework):
class BIP68_112_113Test(BGLTestFramework):
def set_test_params(self):
self.num_nodes = 1
self.setup_clean_chain = True
Expand Down
6 changes: 6 additions & 0 deletions test/functional/feature_fee_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ def split_inputs(from_node, txins, txouts, initial_split=False):
txouts.append({"txid": txid, "vout": 1, "amount": rem_change})


def check_raw_estimates(node, fees_seen):
"""Call estimaterawfee and verify that the estimates meet certain invariants."""

delta = 1.0e-6 # account for rounding error
for i in range(1, 26):
for _, e in node.estimaterawfee(i).items():
Expand Down Expand Up @@ -151,6 +154,9 @@ def check_smart_estimates(node, fees_seen):
assert_greater_than_or_equal(i + 1, e["blocks"])


def check_estimates(node, fees_seen):
check_raw_estimates(node, fees_seen)
check_smart_estimates(node, fees_seen)

def send_tx(node, utxo, feerate):
"""Broadcast a 1in-1out transaction with a specific input and feerate (sat/vb)."""
Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_nulldummy.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
)
from test_framework.messages import CTransaction
from test_framework.script import CScript
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 @@ -45,7 +45,7 @@ def trueDummy(tx):
tx.rehash()


class NULLDUMMYTest(BitcoinTestFramework):
class NULLDUMMYTest(BGLTestFramework):
def set_test_params(self):
self.num_nodes = 1
self.setup_clean_chain = True
Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_presegwit_node_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test a pre-segwit node upgrading to segwit consensus"""

from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_framework import BGLTestFramework
from test_framework.util import (
assert_equal,
softfork_active,
)
import os


class SegwitUpgradeTest(BitcoinTestFramework):
class SegwitUpgradeTest(BGLTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 1
Expand Down
5 changes: 4 additions & 1 deletion test/functional/feature_segwit.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
assert_raises_rpc_error,
try_rpc,
)
from test_framework.wallet_util import (
get_generate_key,
)

NODE_0 = 0
NODE_2 = 2
Expand Down Expand Up @@ -128,7 +131,7 @@ def run_test(self):
self.log.info("Verify sigops are counted in GBT with pre-BIP141 rules before the fork")
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1)
tmpl = self.nodes[0].getblocktemplate({'rules': ['segwit']})
assert_equal(tmpl['sizelimit'], 1000000)
assert_equal(tmpl['sizelimit'], 100000)
assert 'weightlimit' not in tmpl
assert_equal(tmpl['sigoplimit'], 20000)
assert_equal(tmpl['transactions'][0]['hash'], txid)
Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_syscall_sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test bitcoind aborts if a disallowed syscall is used when compiled with the syscall sandbox."""

from test_framework.test_framework import BitcoinTestFramework, SkipTest
from test_framework.test_framework import BGLTestFramework, SkipTest


class SyscallSandboxTest(BitcoinTestFramework):
class SyscallSandboxTest(BGLTestFramework):
def set_test_params(self):
self.num_nodes = 1

Expand Down
8 changes: 4 additions & 4 deletions test/functional/interface_BGL_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# COINBASE_MATURITY (100) blocks. Therefore, after mining 101 blocks we expect
# node 0 to have a balance of (BLOCKS - COINBASE_MATURITY) * 50 BTC/block.
BLOCKS = COINBASE_MATURITY + 1
BALANCE = (BLOCKS - 100) * 50
BALANCE = (BLOCKS - 100) * 200

JSON_PARSING_ERROR = 'error: Error parsing JSON: foo'
BLOCKS_VALUE_OF_ZERO = 'error: the first argument (number of blocks to generate, default: 1) must be an integer value greater than zero'
Expand Down Expand Up @@ -64,7 +64,7 @@ def cli_get_info_string_to_dict(cli_get_info_string):
return cli_get_info


class TestBitcoinCli(BitcoinTestFramework):
class TestBGLCli(BGLTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 1
Expand Down Expand Up @@ -155,8 +155,8 @@ def run_test(self):
wallet_info = self.nodes[0].getwalletinfo()
assert_equal(int(cli_get_info['Keypool size']), wallet_info['keypoolsize'])
assert_equal(int(cli_get_info['Unlocked until']), wallet_info['unlocked_until'])
assert_equal(Decimal(cli_get_info['Transaction fee rate (-paytxfee) (BTC/kvB)']), wallet_info['paytxfee'])
assert_equal(Decimal(cli_get_info['Min tx relay fee rate (BTC/kvB)']), network_info['relayfee'])
assert_equal(Decimal(cli_get_info['Transaction fee rate (-paytxfee) (BGL/kvB)']), wallet_info['paytxfee'])
assert_equal(Decimal(cli_get_info['Min tx relay fee rate (BGL/kvB)']), network_info['relayfee'])
assert_equal(self.nodes[0].cli.getwalletinfo(), wallet_info)

# Setup to test -getinfo, -generate, and -rpcwallet= with multiple wallets.
Expand Down
2 changes: 1 addition & 1 deletion test/functional/mempool_accept.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from decimal import Decimal
import math

from test_framework.key import ECKey
from test_framework.test_framework import BGLTestFramework
from test_framework.messages import (
BIP125_SEQUENCE_NUMBER,
Expand Down
4 changes: 2 additions & 2 deletions test/functional/mempool_accept_wtxid.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@
OP_TRUE,
hash160,
)
from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_framework import BGLTestFramework
from test_framework.util import (
assert_equal,
)

class MempoolWtxidTest(BitcoinTestFramework):
class MempoolWtxidTest(BGLTestFramework):
def set_test_params(self):
self.num_nodes = 1
self.setup_clean_chain = True
Expand Down
4 changes: 2 additions & 2 deletions test/functional/mempool_package_limits.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from decimal import Decimal

from test_framework.address import ADDRESS_BCRT1_P2WSH_OP_TRUE
from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_framework import BGLTestFramework
from test_framework.messages import (
COIN,
CTransaction,
Expand All @@ -29,7 +29,7 @@
DEFAULT_FEE,
)

class MempoolPackageLimitsTest(BitcoinTestFramework):
class MempoolPackageLimitsTest(BGLTestFramework):
def set_test_params(self):
self.num_nodes = 1
self.setup_clean_chain = True
Expand Down
3 changes: 1 addition & 2 deletions test/functional/mempool_updatefromblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ def transaction_graph_test(self, size, n_tx_to_mine=None, start_input_txid='', e
assert_equal(entry['ancestorsize'], sum(tx_size[0:(k + 1)]))

def run_test(self):
# Use batch size limited by DEFAULT_ANCESTOR_LIMIT = 25 to not fire "too many unconfirmed parents" error.
self.transaction_graph_test(size=100, n_tx_to_mine=[25, 50, 75])
self.transaction_graph_test(size=90, n_tx_to_mine=[15, 30, 45, 60, 75])


if __name__ == '__main__':
Expand Down
4 changes: 2 additions & 2 deletions test/functional/p2p_compactblocks_blocksonly.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
msg_sendcmpct,
)
from test_framework.p2p import P2PInterface
from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_framework import BGLTestFramework
from test_framework.util import assert_equal


class P2PCompactBlocksBlocksOnly(BitcoinTestFramework):
class P2PCompactBlocksBlocksOnly(BGLTestFramework):
def set_test_params(self):
self.extra_args = [["-blocksonly"], [], [], []]
self.num_nodes = 4
Expand Down
4 changes: 2 additions & 2 deletions test/functional/p2p_dns_seeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"""Test ThreadDNSAddressSeed logic for querying DNS seeds."""

from test_framework.p2p import P2PInterface
from test_framework.test_framework import BitcoinTestFramework
from test_framework.test_framework import BGLTestFramework


class P2PDNSSeeds(BitcoinTestFramework):
class P2PDNSSeeds(BGLTestFramework):
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 1
Expand Down
Loading

0 comments on commit ea3713b

Please sign in to comment.