Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial wallet_basic.py Fix & 5 other Functional Test Fixes #189

Merged
merged 5 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions test/functional/interface_digibyte_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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'
Expand Down Expand Up @@ -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])
Expand Down
8 changes: 4 additions & 4 deletions test/functional/mempool_unbroadcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/functional/mining_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions test/functional/rpc_signrawtransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"])
Expand All @@ -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
Expand Down
48 changes: 25 additions & 23 deletions test/functional/wallet_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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]))

Expand All @@ -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")
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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)

Expand Down Expand Up @@ -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)
Expand All @@ -617,16 +617,18 @@ 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)
assert_equal(len(txid_list), chainlimit * M)

# 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)
Expand All @@ -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)))
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions test/functional/wallet_importprunedfunds.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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)
Expand Down