From 0d41360292e3142e05a3fc01eaa0737506dd928d Mon Sep 17 00:00:00 2001 From: Jared Tate <13957390+JaredTate@users.noreply.github.com> Date: Fri, 8 Mar 2024 08:52:58 -0700 Subject: [PATCH 1/4] Partial wallet_basic.py Fix --- test/functional/wallet_basic.py | 48 +++++++++++++++++---------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/test/functional/wallet_basic.py b/test/functional/wallet_basic.py index 836900f569..db4d93c120 100755 --- a/test/functional/wallet_basic.py +++ b/test/functional/wallet_basic.py @@ -8,7 +8,7 @@ from itertools import product from time import sleep -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_array_result, @@ -95,7 +95,7 @@ def run_test(self): 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])) + self.generate(self.nodes[1], COINBASE_MATURITY_2 + 1, sync_fun=lambda: self.sync_all(self.nodes[0:3])) utxo_count = 1 expected_balance = 72000 * utxo_count @@ -185,8 +185,8 @@ def run_test(self): self.nodes[1].sendrawtransaction(tx) assert_equal(len(self.nodes[1].listlockunspent()), 0) - # Have node1 generate 8 blocks (so node0 can recover the fee) - self.generate(self.nodes[1], COINBASE_MATURITY, sync_fun=lambda: self.sync_all(self.nodes[0:3])) + # Have node1 generate 101 blocks (so node0 can recover the fee) + self.generate(self.nodes[1], COINBASE_MATURITY_2 + 1, sync_fun=lambda: self.sync_all(self.nodes[0:3])) # node0 should end up with 100 btc in block rewards plus fees, but # minus the 21 plus fees sent to node2 @@ -227,7 +227,7 @@ def run_test(self): # Send 10 DGB normal address = self.nodes[0].getnewaddress("test") - fee_per_byte = Decimal('0.050') / 1000 + fee_per_byte = Decimal('0.10') / 1000 self.nodes[2].settxfee(fee_per_byte * 1000) txid = self.nodes[2].sendtoaddress(address, 10, "", "", False) expectedNode2Balance -= 10 @@ -262,7 +262,7 @@ def run_test(self): node_0_bal = self.check_fee_amount(self.nodes[0].getbalance(), node_0_bal + Decimal('10'), fee_per_byte, self.get_vsize(self.nodes[2].gettransaction(txid)['hex'])) self.log.info("Test sendmany with fee_rate param (explicit fee rate in sat/vB)") - fee_rate_sat_vb = 100 + fee_rate_sat_vb = 10000 fee_rate_btc_kvb = fee_rate_sat_vb * 1e3 / 1e8 explicit_fee_rate_btc_kvb = Decimal(fee_rate_btc_kvb) / 1000 @@ -277,7 +277,7 @@ def run_test(self): assert_equal(self.nodes[0].getbalance(), node_0_bal) # Test passing fee_rate as an integer - amount = Decimal("0.0001") + amount = Decimal("0.1") txid = self.nodes[2].sendmany(amounts={address: amount}, fee_rate=fee_rate_sat_vb) self.generate(self.nodes[2], 1, sync_fun=lambda: self.sync_all(self.nodes[0:3])) @@ -291,13 +291,14 @@ def run_test(self): assert_raises_rpc_error(-8, "Unknown named parameter key", self.nodes[2].sendtoaddress, address=address, amount=1, fee_rate=1, key=1) # Test setting explicit fee rate just below the minimum. - self.log.info("Test sendmany raises 'fee rate too low' if fee_rate of 1.500 sat/vB is passed") - assert_raises_rpc_error(-6, "Fee rate (1.500 sat/vB) is lower than the minimum fee rate setting (100.000 sat/vB)", - self.nodes[2].sendmany, amounts={address: 10}, fee_rate=1.5) + self.log.info("Test sendmany raises 'fee rate too low' if fee_rate of 100 sat/vB is passed") + assert_raises_rpc_error(-6, "Fee rate (100.000 sat/vB) is lower than the minimum fee rate setting (10000.000 sat/vB)", + self.nodes[2].sendmany, amounts={address: 10}, fee_rate=100) self.log.info("Test sendmany raises if fee_rate of 0 or -1 is passed") - assert_raises_rpc_error(-6, "Fee rate (0.000 sat/vB) is lower than the minimum fee rate setting (100.000 sat/vB)", + assert_raises_rpc_error(-6, "Fee rate (0.000 sat/vB) is lower than the minimum fee rate setting (10000.000 sat/vB)", self.nodes[2].sendmany, amounts={address: 10}, fee_rate=0) + assert_raises_rpc_error(-3, OUT_OF_RANGE, self.nodes[2].sendmany, amounts={address: 10}, fee_rate=-1) self.log.info("Test sendmany raises if an invalid conf_target or estimate_mode is passed") @@ -459,7 +460,7 @@ def run_test(self): assert prebalance > 2 address = self.nodes[1].getnewaddress() amount = 3 - fee_rate_sat_vb = 100 + fee_rate_sat_vb = 10000 fee_rate_btc_kvb = fee_rate_sat_vb * 1e3 / 1e8 # Test passing fee_rate as an integer txid = self.nodes[2].sendtoaddress(address=address, amount=amount, fee_rate=fee_rate_sat_vb) @@ -476,8 +477,8 @@ def run_test(self): assert_fee_amount(fee, tx_size, Decimal(fee_rate_btc_kvb)) prebalance = self.nodes[2].getbalance() - amount = Decimal("0.001") - fee_rate_sat_vb = 200 + amount = Decimal("0.1") + fee_rate_sat_vb = 10000 fee_rate_btc_kvb = fee_rate_sat_vb * 1e3 / 1e8 # Test passing fee_rate as a string @@ -501,11 +502,10 @@ def run_test(self): # Test setting explicit fee rate just below the minimum. self.log.info("Test sendtoaddress raises 'fee rate too low' if fee_rate of 99.999 is passed") - assert_raises_rpc_error(-6, "Fee rate (99.999 sat/vB) is lower than the minimum fee rate setting (100.000 sat/vB)", + assert_raises_rpc_error(-6, "Fee rate (99.999 sat/vB) is lower than the minimum fee rate setting (10000.000 sat/vB)", self.nodes[2].sendtoaddress, address=address, amount=1, fee_rate=99.999) - self.log.info("Test sendtoaddress raises if fee_rate of 0 or -1 is passed") - assert_raises_rpc_error(-6, "Fee rate (0.000 sat/vB) is lower than the minimum fee rate setting (100.000 sat/vB)", + assert_raises_rpc_error(-6, "Fee rate (0.000 sat/vB) is lower than the minimum fee rate setting (10000.000 sat/vB)", self.nodes[2].sendtoaddress, address=address, amount=10, fee_rate=0) assert_raises_rpc_error(-3, OUT_OF_RANGE, self.nodes[2].sendtoaddress, address=address, amount=1.0, fee_rate=-1) @@ -606,7 +606,7 @@ def run_test(self): self.generate(self.nodes[0], 1, sync_fun=self.no_op) node0_balance = self.nodes[0].getbalance() # Split into two chains - rawtx = self.nodes[0].createrawtransaction([{"txid": singletxid, "vout": 0}], {chain_addrs[0]: node0_balance / 2 - Decimal('0.01'), chain_addrs[1]: node0_balance / 2 - Decimal('0.01')}) + rawtx = self.nodes[0].createrawtransaction([{"txid": singletxid, "vout": 0}], {chain_addrs[0]: node0_balance / 2 - Decimal('0.1'), chain_addrs[1]: node0_balance / 2 - Decimal('0.1')}) signedtx = self.nodes[0].signrawtransactionwithwallet(rawtx) singletxid = self.nodes[0].sendrawtransaction(hexstring=signedtx["hex"], maxfeerate=0) self.generate(self.nodes[0], 1, sync_fun=self.no_op) @@ -617,8 +617,10 @@ def run_test(self): # So we should be able to generate exactly chainlimit txs for each original output sending_addr = self.nodes[1].getnewaddress() txid_list = [] + #Generate 93 more blocks to have sufficient funds to cover fees, (100 block maturation) + self.generate(self.nodes[0], 93, sync_fun=self.no_op) for _ in range(chainlimit * M): - tx_id = self.nodes[0].sendtoaddress(sending_addr, Decimal('0.0001')) + tx_id = self.nodes[0].sendtoaddress(sending_addr, Decimal('0.1')) txid_list.append(tx_id) assert_equal(self.nodes[0].getmempoolinfo()['size'], chainlimit * M) @@ -626,7 +628,7 @@ def run_test(self): # Without walletrejectlongchains, we will still generate a txid # The tx will be stored in the wallet but not accepted to the mempool - extra_txid = self.nodes[0].sendtoaddress(sending_addr, Decimal('0.0001')) + extra_txid = self.nodes[0].sendtoaddress(sending_addr, Decimal('0.1')) assert extra_txid not in self.nodes[0].getrawmempool() assert extra_txid in [tx["txid"] for tx in self.nodes[0].listtransactions()] self.nodes[0].abandontransaction(extra_txid) @@ -646,7 +648,7 @@ def run_test(self): node0_balance = self.nodes[0].getbalance() # With walletrejectlongchains we will not create the tx and store it in our wallet. - assert_raises_rpc_error(-6, "Transaction has too long of a mempool chain", self.nodes[0].sendtoaddress, sending_addr, node0_balance - Decimal('0.01')) + assert_raises_rpc_error(-6, "Transaction has too long of a mempool chain", self.nodes[0].sendtoaddress, sending_addr, node0_balance - Decimal('0.1')) # Verify nothing new in wallet assert_equal(total_txs, len(self.nodes[0].listtransactions("*", 99999))) @@ -710,9 +712,9 @@ def run_test(self): self.log.info("Test send* RPCs with verbose=True") address = self.nodes[0].getnewaddress("test") txid_feeReason_one = self.nodes[2].sendtoaddress(address=address, amount=5, verbose=True) - assert_equal(txid_feeReason_one["fee_reason"], "Fallback fee") + assert_equal(txid_feeReason_one["fee_reason"], "Minimum Required Fee") txid_feeReason_two = self.nodes[2].sendmany(dummy='', amounts={address: 5}, verbose=True) - assert_equal(txid_feeReason_two["fee_reason"], "Fallback fee") + assert_equal(txid_feeReason_two["fee_reason"], "Minimum Required Fee") self.log.info("Test send* RPCs with verbose=False") txid_feeReason_three = self.nodes[2].sendtoaddress(address=address, amount=5, verbose=False) assert_equal(self.nodes[2].gettransaction(txid_feeReason_three)['txid'], txid_feeReason_three) From 481c062daf00b8691d1f6f796728fb9245622f99 Mon Sep 17 00:00:00 2001 From: Jared Tate <13957390+JaredTate@users.noreply.github.com> Date: Fri, 8 Mar 2024 09:34:25 -0700 Subject: [PATCH 2/4] Fix 3 More Tests --- test/functional/interface_digibyte_cli.py | 8 ++++---- test/functional/mempool_unbroadcast.py | 8 ++++---- test/functional/mining_basic.py | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/test/functional/interface_digibyte_cli.py b/test/functional/interface_digibyte_cli.py index abafe09885..3d90973dad 100755 --- a/test/functional/interface_digibyte_cli.py +++ b/test/functional/interface_digibyte_cli.py @@ -8,7 +8,7 @@ from decimal import Decimal import re -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, @@ -22,8 +22,8 @@ # The block reward of coinbaseoutput.nValue (72000) DGB/block matures after # COINBASE_MATURITY (100) blocks. Therefore, after mining 8+1 blocks we expect # node 0 to have a balance of (BLOCKS - COINBASE_MATURITY) * 72000 DGB/block. -BLOCKS = COINBASE_MATURITY + 1 -BALANCE = (BLOCKS - COINBASE_MATURITY) * 72000 +BLOCKS = COINBASE_MATURITY_2 + 1 +BALANCE = (BLOCKS - COINBASE_MATURITY_2) * 72000 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' @@ -156,7 +156,7 @@ def run_test(self): # Setup to test -getinfo, -generate, and -rpcwallet= with multiple wallets. wallets = [self.default_wallet_name, 'Encrypted', 'secret'] - amounts = [BALANCE + Decimal('9.99964000'), Decimal(9), Decimal(71981)] + amounts = [BALANCE + Decimal('9.96400000'), Decimal(9), Decimal(71981)] self.nodes[0].createwallet(wallet_name=wallets[1]) self.nodes[0].createwallet(wallet_name=wallets[2]) w1 = self.nodes[0].get_wallet_rpc(wallets[0]) diff --git a/test/functional/mempool_unbroadcast.py b/test/functional/mempool_unbroadcast.py index 097a4aa1bd..38f55bc3c4 100755 --- a/test/functional/mempool_unbroadcast.py +++ b/test/functional/mempool_unbroadcast.py @@ -31,7 +31,7 @@ def test_broadcast(self): self.log.info("Test that mempool reattempts delivery of locally submitted transaction") node = self.nodes[0] - min_relay_fee = node.getnetworkinfo()["relayfee"] + min_relay_fee = 0.1 utxos = create_confirmed_utxos(self, min_relay_fee, node, 10) self.disconnect_nodes(0, 1) @@ -40,12 +40,12 @@ def test_broadcast(self): # generate a wallet txn addr = node.getnewaddress() - wallet_tx_hsh = node.sendtoaddress(addr, 0.001) + wallet_tx_hsh = node.sendtoaddress(addr, 0.1) # generate a txn using sendrawtransaction us0 = utxos.pop() inputs = [{"txid": us0["txid"], "vout": us0["vout"]}] - outputs = {addr: 0.001} + outputs = {addr: 0.1} tx = node.createrawtransaction(inputs, outputs) node.settxfee(min_relay_fee) txF = node.fundrawtransaction(tx) @@ -103,7 +103,7 @@ def test_txn_removal(self): # since the node doesn't have any connections, it will not receive # any GETDATAs & thus the transaction will remain in the unbroadcast set. addr = node.getnewaddress() - txhsh = node.sendtoaddress(addr, 0.0001) + txhsh = node.sendtoaddress(addr, 0.1) # check transaction was removed from unbroadcast set due to presence in # a block diff --git a/test/functional/mining_basic.py b/test/functional/mining_basic.py index 8b9ad0353b..0a5a38a459 100755 --- a/test/functional/mining_basic.py +++ b/test/functional/mining_basic.py @@ -94,7 +94,7 @@ def assert_submitblock(block, result_str_1, result_str_2=None): assert 'currentblocktx' not in mining_info assert 'currentblockweight' not in mining_info assert_equal(mining_info['difficulties']['scrypt'], Decimal('4.656542373906925E-10')) - assert_equal(mining_info['networkhashps'], Decimal('0.1333333333333333')) + assert_equal(mining_info['networkhashps'], Decimal('0.1344444444444444')) assert_equal(mining_info['pooledtx'], 0) self.log.info("getblocktemplate: Test default witness commitment") From 4290b0fae25a03e8672a9c8d6fa4cc6b64846aa8 Mon Sep 17 00:00:00 2001 From: Jared Tate <13957390+JaredTate@users.noreply.github.com> Date: Fri, 8 Mar 2024 10:06:23 -0700 Subject: [PATCH 3/4] Update rpc_signrawtransaction.py --- test/functional/rpc_signrawtransaction.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/functional/rpc_signrawtransaction.py b/test/functional/rpc_signrawtransaction.py index 8d70db1eae..087f4d8364 100755 --- a/test/functional/rpc_signrawtransaction.py +++ b/test/functional/rpc_signrawtransaction.py @@ -5,7 +5,7 @@ """Test transaction signing using the signrawtransaction* RPCs.""" from test_framework.blocktools import ( - COINBASE_MATURITY, + COINBASE_MATURITY_2, ) from test_framework.address import ( script_to_p2sh, @@ -181,7 +181,7 @@ def script_verification_error_test(self): def test_fully_signed_tx(self): self.log.info("Test signing a fully signed transaction does nothing") self.nodes[0].walletpassphrase("password", 9999) - self.generate(self.nodes[0], COINBASE_MATURITY + 1) + self.generate(self.nodes[0], COINBASE_MATURITY_2 + 1) rawtx = self.nodes[0].createrawtransaction([], [{self.nodes[0].getnewaddress(): 10}]) fundedtx = self.nodes[0].fundrawtransaction(rawtx) signedtx = self.nodes[0].signrawtransactionwithwallet(fundedtx["hex"]) @@ -200,7 +200,7 @@ def witness_script_test(self): embedded_pubkey = eckey.get_pubkey().get_bytes().hex() p2sh_p2wsh_address = self.nodes[1].createmultisig(1, [embedded_pubkey], "p2sh-segwit") # send transaction to P2SH-P2WSH 1-of-1 multisig address - self.generate(self.nodes[0], COINBASE_MATURITY + 1) + self.generate(self.nodes[0], COINBASE_MATURITY_2 + 1) self.nodes[0].sendtoaddress(p2sh_p2wsh_address["address"], 49.999) self.generate(self.nodes[0], 1) # Get the UTXO info from scantxoutset From 4547f23785c0ffffda42cd4fd0700016dee6b053 Mon Sep 17 00:00:00 2001 From: Jared Tate <13957390+JaredTate@users.noreply.github.com> Date: Fri, 8 Mar 2024 11:29:07 -0700 Subject: [PATCH 4/4] Update wallet_importprunedfunds.py --- test/functional/wallet_importprunedfunds.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/functional/wallet_importprunedfunds.py b/test/functional/wallet_importprunedfunds.py index 6eb9a79fb7..b0526ea620 100755 --- a/test/functional/wallet_importprunedfunds.py +++ b/test/functional/wallet_importprunedfunds.py @@ -5,7 +5,7 @@ """Test the importprunedfunds and removeprunedfunds RPCs.""" from decimal import Decimal -from test_framework.blocktools import COINBASE_MATURITY +from test_framework.blocktools import COINBASE_MATURITY_2 from test_framework.address import key_to_p2wpkh from test_framework.key import ECKey from test_framework.test_framework import DigiByteTestFramework @@ -25,7 +25,7 @@ def skip_test_if_missing_module(self): def run_test(self): self.log.info("Mining blocks...") - self.generate(self.nodes[0], COINBASE_MATURITY + 1) + self.generate(self.nodes[0], COINBASE_MATURITY_2 + 1) # address address1 = self.nodes[0].getnewaddress() @@ -45,7 +45,7 @@ def run_test(self): self.sync_all() # Node 1 sync test - assert_equal(self.nodes[1].getblockcount(), COINBASE_MATURITY + 1) + assert_equal(self.nodes[1].getblockcount(), COINBASE_MATURITY_2 + 1) # Address Test - before import address_info = self.nodes[1].getaddressinfo(address1)