Skip to content

Commit e0ed879

Browse files
authored
Merge pull request #183 from JaredTate/develop
Fix 1st 5 Functional Tests
2 parents 879e6d8 + 1214cec commit e0ed879

13 files changed

+38
-38
lines changed

test/functional/feature_assumevalid.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454
from time import sleep
5555

56-
COINBASE_MATURITY_ORIGINAL = 100
56+
COINBASE_MATURITY_2 = 100
5757

5858
class BaseNode(P2PInterface):
5959
def send_header_for_blocks(self, new_blocks):
@@ -112,7 +112,7 @@ def run_test(self):
112112
height += 1
113113

114114
# Bury the block 100 deep so the coinbase output is spendable
115-
for _ in range(COINBASE_MATURITY_ORIGINAL):
115+
for _ in range(COINBASE_MATURITY_2):
116116
block = create_block(self.tip, create_coinbase(height), self.block_time)
117117
block.solve()
118118
self.blocks.append(block)
@@ -162,8 +162,8 @@ def run_test(self):
162162

163163
# Send blocks to node0. Block 102 will be rejected.
164164
self.send_blocks_until_disconnected(p2p0)
165-
self.wait_until(lambda: self.nodes[0].getblockcount() >= COINBASE_MATURITY_ORIGINAL + 1)
166-
assert_equal(self.nodes[0].getblockcount(), COINBASE_MATURITY_ORIGINAL + 1)
165+
self.wait_until(lambda: self.nodes[0].getblockcount() >= COINBASE_MATURITY_2 + 1)
166+
assert_equal(self.nodes[0].getblockcount(), COINBASE_MATURITY_2 + 1)
167167

168168
# Send all blocks to node1. All blocks will be accepted.
169169
for i in range(2202):
@@ -177,8 +177,8 @@ def run_test(self):
177177
# in start_node(2, ...) so why should it reject block 102.
178178
# Commented out the parameters.
179179
self.send_blocks_until_disconnected(p2p2)
180-
self.wait_until(lambda: self.nodes[2].getblockcount() >= COINBASE_MATURITY_ORIGINAL + 1)
181-
assert_equal(self.nodes[2].getblockcount(), COINBASE_MATURITY_ORIGINAL + 1)
180+
self.wait_until(lambda: self.nodes[2].getblockcount() >= COINBASE_MATURITY_2 + 1)
181+
assert_equal(self.nodes[2].getblockcount(), COINBASE_MATURITY_2 + 1)
182182

183183

184184
if __name__ == '__main__':

test/functional/feature_coinstatsindex.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
from test_framework.blocktools import (
1515
COINBASE_MATURITY,
16-
COINBASE_MATURITY_ORIGINAL,
16+
COINBASE_MATURITY_2,
1717
create_block,
1818
create_coinbase,
1919
)
@@ -69,7 +69,7 @@ def _test_coin_stats_index(self):
6969
index_hash_options = ['none', 'muhash']
7070

7171
# Generate a normal transaction and mine it
72-
self.generate(node, COINBASE_MATURITY_ORIGINAL + 1)
72+
self.generate(node, COINBASE_MATURITY_2 + 1)
7373
address = self.nodes[0].get_deterministic_priv_key().address
7474
node.sendtoaddress(address=address, amount=10, subtractfeefromamount=True)
7575
self.generate(node, 1)

test/functional/feature_loadblock.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import tempfile
1717
import urllib
1818

19-
from test_framework.blocktools import COINBASE_MATURITY_ORIGINAL
19+
from test_framework.blocktools import COINBASE_MATURITY_2
2020
from test_framework.test_framework import DigiByteTestFramework
2121
from test_framework.util import assert_equal
2222

@@ -29,7 +29,7 @@ def set_test_params(self):
2929

3030
def run_test(self):
3131
self.nodes[1].setnetworkactive(state=False)
32-
self.generate(self.nodes[0], COINBASE_MATURITY_ORIGINAL, sync_fun=self.no_op)
32+
self.generate(self.nodes[0], COINBASE_MATURITY_2, sync_fun=self.no_op)
3333

3434
# Parsing the url of our node to get settings for config file
3535
data_dir = self.nodes[0].datadir

test/functional/feature_taproot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from test_framework.blocktools import (
99
COINBASE_MATURITY,
10-
COINBASE_MATURITY_ORIGINAL,
10+
COINBASE_MATURITY_2,
1111
create_coinbase,
1212
create_block,
1313
add_witness_commitment,

test/functional/mempool_packages.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from decimal import Decimal
99

10-
from test_framework.blocktools import COINBASE_MATURITY, COINBASE_MATURITY_ORIGINAL
10+
from test_framework.blocktools import COINBASE_MATURITY, COINBASE_MATURITY_2
1111
from test_framework.messages import COIN
1212
from test_framework.p2p import P2PTxInvStore
1313
from test_framework.test_framework import DigiByteTestFramework
@@ -47,7 +47,7 @@ def skip_test_if_missing_module(self):
4747
def run_test(self):
4848
# Mine some blocks and have them mature.
4949
peer_inv_store = self.nodes[0].add_p2p_connection(P2PTxInvStore()) # keep track of invs
50-
self.generate(self.nodes[0], COINBASE_MATURITY_ORIGINAL + 1)
50+
self.generate(self.nodes[0], COINBASE_MATURITY_2 + 1)
5151
utxo = self.nodes[0].listunspent(10)
5252
txid = utxo[0]['txid']
5353
vout = utxo[0]['vout']

test/functional/rpc_createmultisig.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from test_framework.blocktools import (
1313
COINBASE_MATURITY,
14-
COINBASE_MATURITY_ORIGINAL,
14+
COINBASE_MATURITY_2,
1515
)
1616
from test_framework.authproxy import JSONRPCException
1717
from test_framework.descriptors import descsum_create, drop_origins
@@ -120,7 +120,7 @@ def check_addmultisigaddress_errors(self):
120120

121121
def checkbalances(self):
122122
node0, node1, node2 = self.nodes
123-
self.generate(node0, COINBASE_MATURITY_ORIGINAL)
123+
self.generate(node0, COINBASE_MATURITY_2)
124124

125125
bal0 = node0.getbalance()
126126
bal1 = node1.getbalance()

test/functional/rpc_dumptxoutset.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
from test_framework.blocktools import (
99
COINBASE_MATURITY,
10-
COINBASE_MATURITY_ORIGINAL,
10+
COINBASE_MATURITY_2,
1111
)
1212
from test_framework.test_framework import DigiByteTestFramework
1313
from test_framework.util import assert_equal, assert_raises_rpc_error
@@ -26,7 +26,7 @@ def run_test(self):
2626
node = self.nodes[0]
2727
mocktime = node.getblockheader(node.getblockhash(0))['time'] + 1
2828
node.setmocktime(mocktime)
29-
self.generate(node, COINBASE_MATURITY_ORIGINAL)
29+
self.generate(node, COINBASE_MATURITY_2)
3030

3131
FILENAME = 'txoutset.dat'
3232
out = node.dumptxoutset(FILENAME)

test/functional/rpc_fundrawtransaction.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def run_test(self):
6262
# than a minimum sized signature.
6363

6464
# = 2 bytes * minRelayTxFeePerByte
65-
self.fee_tolerance = 2 * self.min_relay_tx_fee / 1000
65+
self.fee_tolerance = 2 * self.min_relay_tx_fee / 100000
6666

6767
self.generate(self.nodes[2], 1)
6868
self.sync_all()
@@ -590,13 +590,13 @@ def test_many_inputs_fee(self):
590590
self.sync_all()
591591

592592
for _ in range(20):
593-
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01)
593+
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.1)
594594
self.generate(self.nodes[0], 1)
595595
self.sync_all()
596596

597597
# Fund a tx with ~20 small inputs.
598598
inputs = []
599-
outputs = {self.nodes[0].getnewaddress():0.15,self.nodes[0].getnewaddress():0.04}
599+
outputs = {self.nodes[0].getnewaddress():0.15,self.nodes[0].getnewaddress():0.4}
600600
rawtx = self.nodes[1].createrawtransaction(inputs, outputs)
601601
fundedTx = self.nodes[1].fundrawtransaction(rawtx)
602602

@@ -618,15 +618,15 @@ def test_many_inputs_send(self):
618618
self.sync_all()
619619

620620
for _ in range(20):
621-
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.01)
621+
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 0.1)
622622
self.generate(self.nodes[0], 1)
623623
self.sync_all()
624624

625625
# Fund a tx with ~20 small inputs.
626626
oldBalance = self.nodes[0].getbalance()
627627

628628
inputs = []
629-
outputs = {self.nodes[0].getnewaddress():0.15,self.nodes[0].getnewaddress():0.04}
629+
outputs = {self.nodes[0].getnewaddress():0.15,self.nodes[0].getnewaddress():0.4}
630630
rawtx = self.nodes[1].createrawtransaction(inputs, outputs)
631631
fundedTx = self.nodes[1].fundrawtransaction(rawtx)
632632
fundedAndSignedTx = self.nodes[1].signrawtransactionwithwallet(fundedTx['hex'])
@@ -1057,4 +1057,4 @@ def test_feerate_rounding(self):
10571057

10581058

10591059
if __name__ == '__main__':
1060-
RawTransactionsTest().main()
1060+
RawTransactionsTest().main()

test/functional/rpc_getblockstats.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
from test_framework.blocktools import (
1212
COINBASE_MATURITY,
13-
COINBASE_MATURITY_ORIGINAL,
13+
COINBASE_MATURITY_2,
1414
)
1515
from test_framework.test_framework import DigiByteTestFramework
1616
from test_framework.util import (
@@ -51,7 +51,7 @@ def generate_test_data(self, filename):
5151

5252
address = self.nodes[0].get_wallet_rpc('w1').getnewaddress()
5353

54-
self.generatetoaddress(self.nodes[0], COINBASE_MATURITY_ORIGINAL + 1, address)
54+
self.generatetoaddress(self.nodes[0], COINBASE_MATURITY_2 + 1, address)
5555

5656
self.nodes[0].sendtoaddress(address=address, amount=10, subtractfeefromamount=True)
5757
self.generate(self.nodes[0], 1)

test/functional/test_framework/blocktools.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060

6161
# Coinbase transaction outputs can only be spent after this number of new blocks (network rule)
6262
COINBASE_MATURITY = 8
63-
COINBASE_MATURITY_ORIGINAL = 100
63+
COINBASE_MATURITY_2 = 100
6464

6565
# From BIP141
6666
WITNESS_COMMITMENT_HEADER = b"\xaa\x21\xa9\xed"

test/functional/wallet_address_types.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
import itertools
5555

5656
from test_framework.blocktools import COINBASE_MATURITY
57-
from test_framework.blocktools import COINBASE_MATURITY_ORIGINAL
57+
from test_framework.blocktools import COINBASE_MATURITY_2
5858

5959
from test_framework.test_framework import DigiByteTestFramework
6060
from test_framework.descriptors import (
@@ -228,7 +228,7 @@ def test_change_output_type(self, node_sender, destinations, expected_type):
228228
def run_test(self):
229229
# Mine 101 blocks on node5 to bring nodes out of IBD and make sure that
230230
# no coinbases are maturing for the nodes-under-test during the test
231-
self.generate(self.nodes[5], COINBASE_MATURITY_ORIGINAL + 1)
231+
self.generate(self.nodes[5], COINBASE_MATURITY_2 + 1)
232232

233233
uncompressed_1 = "0496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858ee"
234234
uncompressed_2 = "047211a824f55b505228e4c3d5194c1fcfaa15a456abdf37f9b9d97a4040afc073dee6c89064984f03385237d92167c13e236446b417ab79a0fcae412ae3316b77"
@@ -264,7 +264,7 @@ def run_test(self):
264264
address_type = 'legacy'
265265
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))
266266
old_balances = self.get_balances()
267-
to_send = (old_balances[from_node] / (COINBASE_MATURITY_ORIGINAL + 1)).quantize(Decimal("0.00000001"))
267+
to_send = (old_balances[from_node] / (COINBASE_MATURITY_2 + 1)).quantize(Decimal("0.00000001"))
268268
sends = {}
269269
addresses = {}
270270

test/functional/wallet_backup.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
from random import randint
3737
import shutil
3838

39-
from test_framework.blocktools import COINBASE_MATURITY
39+
from test_framework.blocktools import COINBASE_MATURITY_2
4040
from test_framework.test_framework import DigiByteTestFramework
4141
from test_framework.util import (
4242
assert_equal,
@@ -126,7 +126,7 @@ def run_test(self):
126126
self.sync_blocks()
127127
self.generate(self.nodes[2], 1)
128128
self.sync_blocks()
129-
self.generate(self.nodes[3], COINBASE_MATURITY)
129+
self.generate(self.nodes[3], COINBASE_MATURITY_2)
130130
self.sync_blocks()
131131

132132
assert_equal(self.nodes[0].getbalance(), 72000)
@@ -155,7 +155,7 @@ def run_test(self):
155155
self.do_one_round()
156156

157157
# Generate 101 more blocks, so any fees paid mature
158-
self.generate(self.nodes[3], COINBASE_MATURITY + 1)
158+
self.generate(self.nodes[3], COINBASE_MATURITY_2 + 1)
159159

160160
self.sync_all()
161161

@@ -165,9 +165,9 @@ def run_test(self):
165165
balance3 = self.nodes[3].getbalance()
166166
total = balance0 + balance1 + balance2 + balance3
167167

168-
# At this point, there are 214 blocks (8+3 for setup, then 10 rounds, then 8+1.)
169-
# 22 are mature, so the sum of all wallets should be 22 * 72000 = 1,584,000 DGB
170-
assert_equal(total, 1584000)
168+
# At this point, there are 214 blocks (103 for setup, then 10 rounds, then 101.)
169+
# 114 are mature, so the sum of all wallets should be 114 * 72000 = 82,080,000.
170+
assert_equal(total, 8208000.00000000)
171171

172172
##
173173
# Test restoring spender wallets from backups
@@ -231,4 +231,4 @@ def run_test(self):
231231

232232

233233
if __name__ == '__main__':
234-
WalletBackupTest().main()
234+
WalletBackupTest().main()

test/functional/wallet_hd.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import os
88
import shutil
99

10-
from test_framework.blocktools import COINBASE_MATURITY
10+
from test_framework.blocktools import COINBASE_MATURITY_2
1111
from test_framework.test_framework import DigiByteTestFramework
1212
from test_framework.util import (
1313
assert_equal,
@@ -49,7 +49,7 @@ def run_test(self):
4949

5050
# Derive some HD addresses and remember the last
5151
# Also send funds to each add
52-
self.generate(self.nodes[0], COINBASE_MATURITY + 1)
52+
self.generate(self.nodes[0], COINBASE_MATURITY_2 + 1)
5353
hd_add = None
5454
NUM_HD_ADDS = 10
5555
for i in range(1, NUM_HD_ADDS + 1):

0 commit comments

Comments
 (0)