From a06d52804c3f0984354ccf4b8083a5e18ea64d12 Mon Sep 17 00:00:00 2001 From: Jared Tate <13957390+JaredTate@users.noreply.github.com> Date: Tue, 5 Mar 2024 12:00:11 -0700 Subject: [PATCH 1/3] Fix 1st 5 Functional Tests --- test/functional/feature_assumevalid.py | 12 ++++++------ test/functional/feature_coinstatsindex.py | 4 ++-- test/functional/feature_loadblock.py | 4 ++-- test/functional/feature_taproot.py | 2 +- test/functional/mempool_packages.py | 4 ++-- test/functional/rpc_createmultisig.py | 4 ++-- test/functional/rpc_dumptxoutset.py | 4 ++-- test/functional/rpc_fundrawtransaction.py | 12 ++++++------ test/functional/rpc_getblockstats.py | 4 ++-- test/functional/test_framework/blocktools.py | 2 +- test/functional/wallet_address_types.py | 6 +++--- test/functional/wallet_backup.py | 11 +++++------ test/functional/wallet_hd.py | 4 ++-- 13 files changed, 36 insertions(+), 37 deletions(-) diff --git a/test/functional/feature_assumevalid.py b/test/functional/feature_assumevalid.py index 8fbc480c57..4526531756 100755 --- a/test/functional/feature_assumevalid.py +++ b/test/functional/feature_assumevalid.py @@ -53,7 +53,7 @@ from time import sleep -COINBASE_MATURITY_ORIGINAL = 100 +COINBASE_MATURITY_2 = 100 class BaseNode(P2PInterface): def send_header_for_blocks(self, new_blocks): @@ -112,7 +112,7 @@ def run_test(self): height += 1 # Bury the block 100 deep so the coinbase output is spendable - for _ in range(COINBASE_MATURITY_ORIGINAL): + for _ in range(COINBASE_MATURITY_2): block = create_block(self.tip, create_coinbase(height), self.block_time) block.solve() self.blocks.append(block) @@ -162,8 +162,8 @@ def run_test(self): # Send blocks to node0. Block 102 will be rejected. self.send_blocks_until_disconnected(p2p0) - self.wait_until(lambda: self.nodes[0].getblockcount() >= COINBASE_MATURITY_ORIGINAL + 1) - assert_equal(self.nodes[0].getblockcount(), COINBASE_MATURITY_ORIGINAL + 1) + self.wait_until(lambda: self.nodes[0].getblockcount() >= COINBASE_MATURITY_2 + 1) + assert_equal(self.nodes[0].getblockcount(), COINBASE_MATURITY_2 + 1) # Send all blocks to node1. All blocks will be accepted. for i in range(2202): @@ -177,8 +177,8 @@ def run_test(self): # in start_node(2, ...) so why should it reject block 102. # Commented out the parameters. self.send_blocks_until_disconnected(p2p2) - self.wait_until(lambda: self.nodes[2].getblockcount() >= COINBASE_MATURITY_ORIGINAL + 1) - assert_equal(self.nodes[2].getblockcount(), COINBASE_MATURITY_ORIGINAL + 1) + self.wait_until(lambda: self.nodes[2].getblockcount() >= COINBASE_MATURITY_2 + 1) + assert_equal(self.nodes[2].getblockcount(), COINBASE_MATURITY_2 + 1) if __name__ == '__main__': diff --git a/test/functional/feature_coinstatsindex.py b/test/functional/feature_coinstatsindex.py index bee21d0871..03c39cebbd 100755 --- a/test/functional/feature_coinstatsindex.py +++ b/test/functional/feature_coinstatsindex.py @@ -13,7 +13,7 @@ from test_framework.blocktools import ( COINBASE_MATURITY, - COINBASE_MATURITY_ORIGINAL, + COINBASE_MATURITY_2, create_block, create_coinbase, ) @@ -69,7 +69,7 @@ def _test_coin_stats_index(self): index_hash_options = ['none', 'muhash'] # Generate a normal transaction and mine it - self.generate(node, COINBASE_MATURITY_ORIGINAL + 1) + self.generate(node, COINBASE_MATURITY_2 + 1) address = self.nodes[0].get_deterministic_priv_key().address node.sendtoaddress(address=address, amount=10, subtractfeefromamount=True) self.generate(node, 1) diff --git a/test/functional/feature_loadblock.py b/test/functional/feature_loadblock.py index 6c06842a75..a53f341e27 100755 --- a/test/functional/feature_loadblock.py +++ b/test/functional/feature_loadblock.py @@ -16,7 +16,7 @@ import tempfile import urllib -from test_framework.blocktools import COINBASE_MATURITY_ORIGINAL +from test_framework.blocktools import COINBASE_MATURITY_2 from test_framework.test_framework import DigiByteTestFramework from test_framework.util import assert_equal @@ -29,7 +29,7 @@ def set_test_params(self): def run_test(self): self.nodes[1].setnetworkactive(state=False) - self.generate(self.nodes[0], COINBASE_MATURITY_ORIGINAL, sync_fun=self.no_op) + self.generate(self.nodes[0], COINBASE_MATURITY_2, sync_fun=self.no_op) # Parsing the url of our node to get settings for config file data_dir = self.nodes[0].datadir diff --git a/test/functional/feature_taproot.py b/test/functional/feature_taproot.py index 8b00a02e31..af25744ade 100755 --- a/test/functional/feature_taproot.py +++ b/test/functional/feature_taproot.py @@ -7,7 +7,7 @@ from test_framework.blocktools import ( COINBASE_MATURITY, - COINBASE_MATURITY_ORIGINAL, + COINBASE_MATURITY_2, create_coinbase, create_block, add_witness_commitment, diff --git a/test/functional/mempool_packages.py b/test/functional/mempool_packages.py index 0442b08b29..041bac65bd 100755 --- a/test/functional/mempool_packages.py +++ b/test/functional/mempool_packages.py @@ -7,7 +7,7 @@ from decimal import Decimal -from test_framework.blocktools import COINBASE_MATURITY, COINBASE_MATURITY_ORIGINAL +from test_framework.blocktools import COINBASE_MATURITY, COINBASE_MATURITY_2 from test_framework.messages import COIN from test_framework.p2p import P2PTxInvStore from test_framework.test_framework import DigiByteTestFramework @@ -47,7 +47,7 @@ def skip_test_if_missing_module(self): def run_test(self): # Mine some blocks and have them mature. peer_inv_store = self.nodes[0].add_p2p_connection(P2PTxInvStore()) # keep track of invs - self.generate(self.nodes[0], COINBASE_MATURITY_ORIGINAL + 1) + self.generate(self.nodes[0], COINBASE_MATURITY_2 + 1) utxo = self.nodes[0].listunspent(10) txid = utxo[0]['txid'] vout = utxo[0]['vout'] diff --git a/test/functional/rpc_createmultisig.py b/test/functional/rpc_createmultisig.py index 4c2259325b..7b8d2f552c 100755 --- a/test/functional/rpc_createmultisig.py +++ b/test/functional/rpc_createmultisig.py @@ -11,7 +11,7 @@ from test_framework.blocktools import ( COINBASE_MATURITY, - COINBASE_MATURITY_ORIGINAL, + COINBASE_MATURITY_2, ) from test_framework.authproxy import JSONRPCException from test_framework.descriptors import descsum_create, drop_origins @@ -120,7 +120,7 @@ def check_addmultisigaddress_errors(self): def checkbalances(self): node0, node1, node2 = self.nodes - self.generate(node0, COINBASE_MATURITY_ORIGINAL) + self.generate(node0, COINBASE_MATURITY_2) bal0 = node0.getbalance() bal1 = node1.getbalance() diff --git a/test/functional/rpc_dumptxoutset.py b/test/functional/rpc_dumptxoutset.py index 643bab0db2..6184a10771 100755 --- a/test/functional/rpc_dumptxoutset.py +++ b/test/functional/rpc_dumptxoutset.py @@ -7,7 +7,7 @@ from test_framework.blocktools import ( COINBASE_MATURITY, - COINBASE_MATURITY_ORIGINAL, + COINBASE_MATURITY_2, ) from test_framework.test_framework import DigiByteTestFramework from test_framework.util import assert_equal, assert_raises_rpc_error @@ -26,7 +26,7 @@ def run_test(self): node = self.nodes[0] mocktime = node.getblockheader(node.getblockhash(0))['time'] + 1 node.setmocktime(mocktime) - self.generate(node, COINBASE_MATURITY_ORIGINAL) + self.generate(node, COINBASE_MATURITY_2) FILENAME = 'txoutset.dat' out = node.dumptxoutset(FILENAME) diff --git a/test/functional/rpc_fundrawtransaction.py b/test/functional/rpc_fundrawtransaction.py index 4db83ee4f4..ba04f4940d 100755 --- a/test/functional/rpc_fundrawtransaction.py +++ b/test/functional/rpc_fundrawtransaction.py @@ -62,7 +62,7 @@ def run_test(self): # than a minimum sized signature. # = 2 bytes * minRelayTxFeePerByte - self.fee_tolerance = 2 * self.min_relay_tx_fee / 1000 + self.fee_tolerance = 2 * self.min_relay_tx_fee / 100000 self.generate(self.nodes[2], 1) self.sync_all() @@ -590,13 +590,13 @@ def test_many_inputs_fee(self): self.sync_all() for _ in range(20): - self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01) + self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.1) self.generate(self.nodes[0], 1) self.sync_all() # Fund a tx with ~20 small inputs. inputs = [] - outputs = {self.nodes[0].getnewaddress():0.15,self.nodes[0].getnewaddress():0.04} + outputs = {self.nodes[0].getnewaddress():0.15,self.nodes[0].getnewaddress():0.4} rawtx = self.nodes[1].createrawtransaction(inputs, outputs) fundedTx = self.nodes[1].fundrawtransaction(rawtx) @@ -618,7 +618,7 @@ def test_many_inputs_send(self): self.sync_all() for _ in range(20): - self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01) + self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.1) self.generate(self.nodes[0], 1) self.sync_all() @@ -626,14 +626,14 @@ def test_many_inputs_send(self): oldBalance = self.nodes[0].getbalance() inputs = [] - outputs = {self.nodes[0].getnewaddress():0.15,self.nodes[0].getnewaddress():0.04} + outputs = {self.nodes[0].getnewaddress():0.15,self.nodes[0].getnewaddress():0.4} rawtx = self.nodes[1].createrawtransaction(inputs, outputs) fundedTx = self.nodes[1].fundrawtransaction(rawtx) fundedAndSignedTx = self.nodes[1].signrawtransactionwithwallet(fundedTx['hex']) self.nodes[1].sendrawtransaction(fundedAndSignedTx['hex']) self.generate(self.nodes[1], 1) self.sync_all() - assert_equal(oldBalance+Decimal('72000.19109500'), self.nodes[0].getbalance()) #0.191095+block reward + assert_equal(oldBalance+Decimal('6335901.85210000'), self.nodes[0].getbalance()) # def test_op_return(self): self.log.info("Test fundrawtxn with OP_RETURN and no vin") diff --git a/test/functional/rpc_getblockstats.py b/test/functional/rpc_getblockstats.py index 1728c6f05c..0d095989a3 100755 --- a/test/functional/rpc_getblockstats.py +++ b/test/functional/rpc_getblockstats.py @@ -10,7 +10,7 @@ from test_framework.blocktools import ( COINBASE_MATURITY, - COINBASE_MATURITY_ORIGINAL, + COINBASE_MATURITY_2, ) from test_framework.test_framework import DigiByteTestFramework from test_framework.util import ( @@ -51,7 +51,7 @@ def generate_test_data(self, filename): address = self.nodes[0].get_wallet_rpc('w1').getnewaddress() - self.generatetoaddress(self.nodes[0], COINBASE_MATURITY_ORIGINAL + 1, address) + self.generatetoaddress(self.nodes[0], COINBASE_MATURITY_2 + 1, address) self.nodes[0].sendtoaddress(address=address, amount=10, subtractfeefromamount=True) self.generate(self.nodes[0], 1) diff --git a/test/functional/test_framework/blocktools.py b/test/functional/test_framework/blocktools.py index c73c5331dc..1b53e7a07b 100644 --- a/test/functional/test_framework/blocktools.py +++ b/test/functional/test_framework/blocktools.py @@ -60,7 +60,7 @@ # Coinbase transaction outputs can only be spent after this number of new blocks (network rule) COINBASE_MATURITY = 8 -COINBASE_MATURITY_ORIGINAL = 100 +COINBASE_MATURITY_2 = 100 # From BIP141 WITNESS_COMMITMENT_HEADER = b"\xaa\x21\xa9\xed" diff --git a/test/functional/wallet_address_types.py b/test/functional/wallet_address_types.py index e1b30853f0..0e69860ef8 100755 --- a/test/functional/wallet_address_types.py +++ b/test/functional/wallet_address_types.py @@ -54,7 +54,7 @@ import itertools from test_framework.blocktools import COINBASE_MATURITY -from test_framework.blocktools import COINBASE_MATURITY_ORIGINAL +from test_framework.blocktools import COINBASE_MATURITY_2 from test_framework.test_framework import DigiByteTestFramework from test_framework.descriptors import ( @@ -228,7 +228,7 @@ def test_change_output_type(self, node_sender, destinations, expected_type): def run_test(self): # Mine 101 blocks on node5 to bring nodes out of IBD and make sure that # no coinbases are maturing for the nodes-under-test during the test - self.generate(self.nodes[5], COINBASE_MATURITY_ORIGINAL + 1) + self.generate(self.nodes[5], COINBASE_MATURITY_2 + 1) uncompressed_1 = "0496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858ee" uncompressed_2 = "047211a824f55b505228e4c3d5194c1fcfaa15a456abdf37f9b9d97a4040afc073dee6c89064984f03385237d92167c13e236446b417ab79a0fcae412ae3316b77" @@ -264,7 +264,7 @@ def run_test(self): address_type = 'legacy' self.log.info("Sending from node {} ({}) with{} multisig using {}".format(from_node, self.extra_args[from_node], "" if multisig else "out", "default" if address_type is None else address_type)) old_balances = self.get_balances() - to_send = (old_balances[from_node] / (COINBASE_MATURITY_ORIGINAL + 1)).quantize(Decimal("0.00000001")) + to_send = (old_balances[from_node] / (COINBASE_MATURITY_2 + 1)).quantize(Decimal("0.00000001")) sends = {} addresses = {} diff --git a/test/functional/wallet_backup.py b/test/functional/wallet_backup.py index 130c6daef6..09f906b88e 100755 --- a/test/functional/wallet_backup.py +++ b/test/functional/wallet_backup.py @@ -36,7 +36,7 @@ from random import randint import shutil -from test_framework.blocktools import COINBASE_MATURITY +from test_framework.blocktools import COINBASE_MATURITY_2 from test_framework.test_framework import DigiByteTestFramework from test_framework.util import ( assert_equal, @@ -126,7 +126,7 @@ def run_test(self): self.sync_blocks() self.generate(self.nodes[2], 1) self.sync_blocks() - self.generate(self.nodes[3], COINBASE_MATURITY) + self.generate(self.nodes[3], COINBASE_MATURITY_2) self.sync_blocks() assert_equal(self.nodes[0].getbalance(), 72000) @@ -155,7 +155,7 @@ def run_test(self): self.do_one_round() # Generate 101 more blocks, so any fees paid mature - self.generate(self.nodes[3], COINBASE_MATURITY + 1) + self.generate(self.nodes[3], COINBASE_MATURITY_2 + 1) self.sync_all() @@ -165,9 +165,8 @@ def run_test(self): balance3 = self.nodes[3].getbalance() total = balance0 + balance1 + balance2 + balance3 - # At this point, there are 214 blocks (8+3 for setup, then 10 rounds, then 8+1.) - # 22 are mature, so the sum of all wallets should be 22 * 72000 = 1,584,000 DGB - assert_equal(total, 1584000) + # Sum = 82,080,000 DGB + assert_equal(total, 8208000.00000000) ## # Test restoring spender wallets from backups diff --git a/test/functional/wallet_hd.py b/test/functional/wallet_hd.py index cf890e3bd8..6aba1ca241 100755 --- a/test/functional/wallet_hd.py +++ b/test/functional/wallet_hd.py @@ -7,7 +7,7 @@ import os import shutil -from test_framework.blocktools import COINBASE_MATURITY +from test_framework.blocktools import COINBASE_MATURITY_2 from test_framework.test_framework import DigiByteTestFramework from test_framework.util import ( assert_equal, @@ -49,7 +49,7 @@ def run_test(self): # Derive some HD addresses and remember the last # Also send funds to each add - self.generate(self.nodes[0], COINBASE_MATURITY + 1) + self.generate(self.nodes[0], COINBASE_MATURITY_2 + 1) hd_add = None NUM_HD_ADDS = 10 for i in range(1, NUM_HD_ADDS + 1): From 615bf8eb3ff79a6951c293e6be0ef610a80778bf Mon Sep 17 00:00:00 2001 From: Jared Tate <13957390+JaredTate@users.noreply.github.com> Date: Tue, 5 Mar 2024 14:29:38 -0700 Subject: [PATCH 2/3] Update wallet_backup.py --- test/functional/wallet_backup.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/functional/wallet_backup.py b/test/functional/wallet_backup.py index 09f906b88e..68f26fd173 100755 --- a/test/functional/wallet_backup.py +++ b/test/functional/wallet_backup.py @@ -165,7 +165,8 @@ def run_test(self): balance3 = self.nodes[3].getbalance() total = balance0 + balance1 + balance2 + balance3 - # Sum = 82,080,000 DGB + # At this point, there are 214 blocks (103 for setup, then 10 rounds, then 101.) + # 114 are mature, so the sum of all wallets should be 114 * 72000 = 82,080,000. assert_equal(total, 8208000.00000000) ## @@ -230,4 +231,4 @@ def run_test(self): if __name__ == '__main__': - WalletBackupTest().main() \ No newline at end of file + WalletBackupTest().main() From 1214cece70a14f44c2796ec37aa1aa794409d0ef Mon Sep 17 00:00:00 2001 From: Jared Tate <13957390+JaredTate@users.noreply.github.com> Date: Tue, 5 Mar 2024 14:31:54 -0700 Subject: [PATCH 3/3] Update rpc_fundrawtransaction.py --- test/functional/rpc_fundrawtransaction.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/functional/rpc_fundrawtransaction.py b/test/functional/rpc_fundrawtransaction.py index ba04f4940d..ad6de61f4e 100755 --- a/test/functional/rpc_fundrawtransaction.py +++ b/test/functional/rpc_fundrawtransaction.py @@ -633,7 +633,7 @@ def test_many_inputs_send(self): self.nodes[1].sendrawtransaction(fundedAndSignedTx['hex']) self.generate(self.nodes[1], 1) self.sync_all() - assert_equal(oldBalance+Decimal('6335901.85210000'), self.nodes[0].getbalance()) # + assert_equal(oldBalance+Decimal('72000.19109500'), self.nodes[0].getbalance()) #0.191095+block reward def test_op_return(self): self.log.info("Test fundrawtxn with OP_RETURN and no vin") @@ -1057,4 +1057,4 @@ def test_feerate_rounding(self): if __name__ == '__main__': - RawTransactionsTest().main() \ No newline at end of file + RawTransactionsTest().main()