From 8ad196fcf13464afef1fab4c5dade540f87356ba Mon Sep 17 00:00:00 2001 From: lateminer <9951982+lateminer@users.noreply.github.com> Date: Wed, 24 Jan 2024 19:21:53 +0100 Subject: [PATCH] test: Set some Blackcoin values in test framework --- test/functional/test_framework/blocktools.py | 4 +-- test/functional/test_framework/messages.py | 9 +++--- test/functional/test_framework/p2p.py | 12 +++++--- test/functional/wallet_basic.py | 31 ++++++++++---------- test/functional/wallet_create_tx.py | 4 +-- 5 files changed, 33 insertions(+), 27 deletions(-) diff --git a/test/functional/test_framework/blocktools.py b/test/functional/test_framework/blocktools.py index cfd923bab3..17603358c7 100644 --- a/test/functional/test_framework/blocktools.py +++ b/test/functional/test_framework/blocktools.py @@ -50,12 +50,12 @@ MAX_BLOCK_SIGOPS_WEIGHT = MAX_BLOCK_SIGOPS * WITNESS_SCALE_FACTOR # Genesis block time (regtest) -TIME_GENESIS_BLOCK = 1296688602 +TIME_GENESIS_BLOCK = 1393221600 MAX_FUTURE_BLOCK_TIME = 2 * 60 * 60 # Coinbase transaction outputs can only be spent after this number of new blocks (network rule) -COINBASE_MATURITY = 100 +COINBASE_MATURITY = 10 # From BIP141 WITNESS_COMMITMENT_HEADER = b"\xaa\x21\xa9\xed" diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py index 07301955fa..b3ce380775 100755 --- a/test/functional/test_framework/messages.py +++ b/test/functional/test_framework/messages.py @@ -26,6 +26,7 @@ import random import socket import struct +import sys import time from test_framework.siphash import siphash256 @@ -36,8 +37,8 @@ MAX_BLOOM_FILTER_SIZE = 36000 MAX_BLOOM_HASH_FUNCS = 50 -COIN = 100000000 # 1 btc in satoshis -MAX_MONEY = 21000000 * COIN +COIN = 100000000 # 1 BLK in satoshis +MAX_MONEY = sys.maxsize MAX_BIP125_RBF_SEQUENCE = 0xfffffffd # Sequence number that is rbf-opt-in (BIP 125) and csv-opt-out (BIP 68) SEQUENCE_FINAL = 0xffffffff # Sequence number that disables nLockTime if set for every input of a tx @@ -68,8 +69,8 @@ DEFAULT_ANCESTOR_LIMIT = 25 # default max number of in-mempool ancestors DEFAULT_DESCENDANT_LIMIT = 25 # default max number of in-mempool descendants -# Default setting for -datacarriersize. 80 bytes of data, +1 for OP_RETURN, +2 for the pushdata opcodes. -MAX_OP_RETURN_RELAY = 83 +# Default setting for -datacarriersize. 220 bytes of data, +1 for OP_RETURN, +2 for the pushdata opcodes. +MAX_OP_RETURN_RELAY = 223 DEFAULT_MEMPOOL_EXPIRY_HOURS = 336 # hours diff --git a/test/functional/test_framework/p2p.py b/test/functional/test_framework/p2p.py index 2433e52671..441c1387eb 100755 --- a/test/functional/test_framework/p2p.py +++ b/test/functional/test_framework/p2p.py @@ -88,7 +88,11 @@ # Version 70016 supports wtxid relay P2P_VERSION = 70016 # The services that this test framework offers in its `version` message -P2P_SERVICES = NODE_NETWORK | NODE_WITNESS +''' +# Blackcoin +# NODE_NETWORK | NODE_WITNESS +''' +P2P_SERVICES = NODE_NETWORK # The P2P user agent string that this test framework sends in its `version` message P2P_SUBVERSION = "/python-p2p-tester:0.0.3/" # Value for relay that this test framework sends in its `version` message @@ -135,9 +139,9 @@ } MAGIC_BYTES = { - "mainnet": b"\xf9\xbe\xb4\xd9", # mainnet - "testnet3": b"\x0b\x11\x09\x07", # testnet3 - "regtest": b"\xfa\xbf\xb5\xda", # regtest + "mainnet": b"\x70\x32\x22\x05", # mainnet + "testnet": b"\xcd\xf2\xc0\xef", # testnet + "regtest": b"\x70\x35\x22\x06", # regtest "signet": b"\x0a\x03\xcf\x40", # signet } diff --git a/test/functional/wallet_basic.py b/test/functional/wallet_basic.py index 5ec41a1cf4..f141a480c0 100755 --- a/test/functional/wallet_basic.py +++ b/test/functional/wallet_basic.py @@ -67,14 +67,14 @@ def run_test(self): self.generate(self.nodes[0], 1, sync_fun=self.no_op) walletinfo = self.nodes[0].getwalletinfo() - assert_equal(walletinfo['immature_balance'], 50) + assert_equal(walletinfo['immature_balance'], 10000) assert_equal(walletinfo['balance'], 0) self.sync_all(self.nodes[0:3]) self.generate(self.nodes[1], COINBASE_MATURITY + 1, sync_fun=lambda: self.sync_all(self.nodes[0:3])) - assert_equal(self.nodes[0].getbalance(), 50) - assert_equal(self.nodes[1].getbalance(), 50) + assert_equal(self.nodes[0].getbalance(), 10000) + assert_equal(self.nodes[1].getbalance(), 10000) assert_equal(self.nodes[2].getbalance(), 0) # Check that only first and second nodes have UTXOs @@ -88,11 +88,11 @@ def run_test(self): # First, outputs that are unspent both in the chain and in the # mempool should appear with or without include_mempool txout = self.nodes[0].gettxout(txid=confirmed_txid, n=confirmed_index, include_mempool=False) - assert_equal(txout['value'], 50) + assert_equal(txout['value'], 10000) txout = self.nodes[0].gettxout(txid=confirmed_txid, n=confirmed_index, include_mempool=True) - assert_equal(txout['value'], 50) + assert_equal(txout['value'], 10000) - # Send 21 BTC from 0 to 2 using sendtoaddress call. + # Send 21 BLK from 0 to 2 using sendtoaddress call. self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 11) mempool_txid = self.nodes[0].sendtoaddress(self.nodes[2].getnewaddress(), 10) @@ -100,7 +100,7 @@ def run_test(self): # utxo spent in mempool should be visible if you exclude mempool # but invisible if you include mempool txout = self.nodes[0].gettxout(confirmed_txid, confirmed_index, False) - assert_equal(txout['value'], 50) + assert_equal(txout['value'], 10000) txout = self.nodes[0].gettxout(confirmed_txid, confirmed_index) # by default include_mempool=True assert txout is None txout = self.nodes[0].gettxout(confirmed_txid, confirmed_index, True) @@ -200,9 +200,9 @@ def run_test(self): # Have node1 generate 100 blocks (so node0 can recover the fee) self.generate(self.nodes[1], COINBASE_MATURITY, sync_fun=lambda: self.sync_all(self.nodes[0:3])) - # node0 should end up with 100 btc in block rewards plus fees, but + # node0 should end up with 20000 BLK in block rewards plus fees, but # minus the 21 plus fees sent to node2 - assert_equal(self.nodes[0].getbalance(), 100 - 21) + assert_equal(self.nodes[0].getbalance(), 20000 - 21) assert_equal(self.nodes[2].getbalance(), 21) # Node0 should have two unspent outputs. @@ -229,22 +229,23 @@ def run_test(self): self.generate(self.nodes[1], 1, sync_fun=lambda: self.sync_all(self.nodes[0:3])) assert_equal(self.nodes[0].getbalance(), 0) - assert_equal(self.nodes[2].getbalance(), 94) + assert_equal(self.nodes[2].getbalance(), 19994) # Verify that a spent output cannot be locked anymore spent_0 = {"txid": node0utxos[0]["txid"], "vout": node0utxos[0]["vout"]} assert_raises_rpc_error(-8, "Invalid parameter, expected unspent output", self.nodes[0].lockunspent, False, [spent_0]) - # Send 10 BTC normal + # Send 10 BLK normal address = self.nodes[0].getnewaddress("test") fee_per_byte = Decimal('0.001') / 1000 self.nodes[2].settxfee(fee_per_byte * 1000) txid = self.nodes[2].sendtoaddress(address, 10, "", "", False) self.generate(self.nodes[2], 1, sync_fun=lambda: self.sync_all(self.nodes[0:3])) - node_2_bal = self.check_fee_amount(self.nodes[2].getbalance(), Decimal('84'), fee_per_byte, self.get_vsize(self.nodes[2].gettransaction(txid)['hex'])) + + node_2_bal = self.check_fee_amount(self.nodes[2].getbalance(), Decimal('19984'), fee_per_byte, self.get_vsize(self.nodes[2].gettransaction(txid)['hex'])) assert_equal(self.nodes[0].getbalance(), Decimal('10')) - # Send 10 BTC with subtract fee from amount + # Send 10 BLK with subtract fee from amount txid = self.nodes[2].sendtoaddress(address, 10, "", "", True) self.generate(self.nodes[2], 1, sync_fun=lambda: self.sync_all(self.nodes[0:3])) node_2_bal -= Decimal('10') @@ -253,14 +254,14 @@ def run_test(self): self.log.info("Test sendmany") - # Sendmany 10 BTC + # Sendmany 10 BLK txid = self.nodes[2].sendmany('', {address: 10}, 0, "", []) self.generate(self.nodes[2], 1, sync_fun=lambda: self.sync_all(self.nodes[0:3])) node_0_bal += Decimal('10') node_2_bal = self.check_fee_amount(self.nodes[2].getbalance(), node_2_bal - Decimal('10'), fee_per_byte, self.get_vsize(self.nodes[2].gettransaction(txid)['hex'])) assert_equal(self.nodes[0].getbalance(), node_0_bal) - # Sendmany 10 BTC with subtract fee from amount + # Sendmany 10 BLK with subtract fee from amount txid = self.nodes[2].sendmany('', {address: 10}, 0, "", [address]) self.generate(self.nodes[2], 1, sync_fun=lambda: self.sync_all(self.nodes[0:3])) node_2_bal -= Decimal('10') diff --git a/test/functional/wallet_create_tx.py b/test/functional/wallet_create_tx.py index af5248378e..31f6baf245 100755 --- a/test/functional/wallet_create_tx.py +++ b/test/functional/wallet_create_tx.py @@ -52,7 +52,7 @@ def test_tx_size_too_large(self): outputs = {self.nodes[0].getnewaddress(address_type='bech32'): 0.000025 for _ in range(400)} raw_tx = self.nodes[0].createrawtransaction(inputs=[], outputs=outputs) - for fee_setting in ['-minrelaytxfee=0.01', '-paytxfee=0.01']: + for fee_setting in ['-minrelaytxfee=0.1', '-paytxfee=0.1']: self.log.info('Check maxtxfee in combination with {}'.format(fee_setting)) self.restart_node(0, extra_args=[fee_setting]) assert_raises_rpc_error( @@ -68,7 +68,7 @@ def test_tx_size_too_large(self): self.log.info('Check maxtxfee in combination with settxfee') self.restart_node(0) - self.nodes[0].settxfee(0.01) + self.nodes[0].settxfee(0.1) assert_raises_rpc_error( -6, "Fee exceeds maximum configured by user (e.g. -maxtxfee, maxfeerate)",