Skip to content

Commit

Permalink
Merge pull request #183 from JaredTate/develop
Browse files Browse the repository at this point in the history
Fix 1st 5 Functional Tests
  • Loading branch information
ycagel committed Mar 5, 2024
2 parents 879e6d8 + 1214cec commit e0ed879
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 38 deletions.
12 changes: 6 additions & 6 deletions test/functional/feature_assumevalid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand All @@ -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__':
Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_coinstatsindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from test_framework.blocktools import (
COINBASE_MATURITY,
COINBASE_MATURITY_ORIGINAL,
COINBASE_MATURITY_2,
create_block,
create_coinbase,
)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions test/functional/feature_loadblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/functional/feature_taproot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from test_framework.blocktools import (
COINBASE_MATURITY,
COINBASE_MATURITY_ORIGINAL,
COINBASE_MATURITY_2,
create_coinbase,
create_block,
add_witness_commitment,
Expand Down
4 changes: 2 additions & 2 deletions test/functional/mempool_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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']
Expand Down
4 changes: 2 additions & 2 deletions test/functional/rpc_createmultisig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions test/functional/rpc_dumptxoutset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions test/functional/rpc_fundrawtransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)

Expand All @@ -618,15 +618,15 @@ 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()

# Fund a tx with ~20 small inputs.
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'])
Expand Down Expand Up @@ -1057,4 +1057,4 @@ def test_feerate_rounding(self):


if __name__ == '__main__':
RawTransactionsTest().main()
RawTransactionsTest().main()
4 changes: 2 additions & 2 deletions test/functional/rpc_getblockstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/functional/test_framework/blocktools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions test/functional/wallet_address_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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 = {}

Expand Down
14 changes: 7 additions & 7 deletions test/functional/wallet_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()

Expand All @@ -165,9 +165,9 @@ 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)
# 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)

##
# Test restoring spender wallets from backups
Expand Down Expand Up @@ -231,4 +231,4 @@ def run_test(self):


if __name__ == '__main__':
WalletBackupTest().main()
WalletBackupTest().main()
4 changes: 2 additions & 2 deletions test/functional/wallet_hd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit e0ed879

Please sign in to comment.