Skip to content

Commit 800092f

Browse files
authored
Merge pull request #132 from BitgesellOfficial/bitcoinsync31July2023
Update test/functional
2 parents 217e921 + d875c76 commit 800092f

9 files changed

+25
-81
lines changed

src/kernel/chainparams.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -373,13 +373,13 @@ class SigNetParams : public CChainParams {
373373

374374
vFixedSeeds.clear();
375375

376-
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
377-
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
376+
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1, 34);
377+
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1, 50);
378378
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,239);
379379
base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};
380380
base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};
381381

382-
bech32_hrp = "tb";
382+
bech32_hrp = "tbgl";
383383

384384
fDefaultConsistencyChecks = false;
385385
//fRequireStandard = true;

test/functional/feature_block.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1004,14 +1004,14 @@ def run_test(self):
10041004
#
10051005
self.log.info("Reject a block trying to claim too much subsidy in the coinbase transaction")
10061006
self.move_tip(65)
1007-
b68 = self.next_block(68, additional_coinbase_value=10)
1007+
b68 = self.next_block(68, additional_coinbase_value=int(10*0.1)) #multiply to 0.1 as 90% fees will be burnt
10081008
tx = self.create_and_sign_transaction(out[20], out[20].vout[0].nValue - 9)
10091009
b68 = self.update_block(68, [tx])
10101010
self.send_blocks([b68], success=False, reject_reason='bad-cb-amount', reconnect=True)
10111011

10121012
self.log.info("Accept a block claiming the correct subsidy in the coinbase transaction")
10131013
self.move_tip(65)
1014-
b69 = self.next_block(69, additional_coinbase_value=10)
1014+
b69 = self.next_block(69, additional_coinbase_value=int(10*0.1)) #multiply to 0.1 as 90% fees will be burnt
10151015
tx = self.create_and_sign_transaction(out[20], out[20].vout[0].nValue - 10)
10161016
self.update_block(69, [tx])
10171017
self.send_blocks([b69], True)
@@ -1362,9 +1362,9 @@ def next_block(self, number, spend=None, additional_coinbase_value=0, script=CSc
13621362
if spend is None:
13631363
block = create_block(base_block_hash, coinbase, block_time, version=version)
13641364
else:
1365-
coinbase.vout[0].nValue += spend.vout[0].nValue - 1 # all but one satoshi to fees
1365+
coinbase.vout[0].nValue += int(0.1*(spend.vout[0].nValue - 10)) # all but 10 satoshi to fees, multiply to 0.1 as 90% fees will be burnt
13661366
coinbase.rehash()
1367-
tx = self.create_tx(spend, 0, 1, script) # spend 1 satoshi
1367+
tx = self.create_tx(spend, 0, 10, script) # spend 10 satoshi
13681368
self.sign_tx(tx, spend)
13691369
tx.rehash()
13701370
block = create_block(base_block_hash, coinbase, block_time, version=version, txlist=[tx])

test/functional/interface_BGL_cli.py

+3-13
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,6 @@ def run_test(self):
7979
"""Main test logic"""
8080
self.generate(self.nodes[0], BLOCKS)
8181

82-
cli_response = self.nodes[0].cli("-version").send_cli()
83-
assert "{} RPC client version".format(self.config['environment']['PACKAGE_NAME']) in cli_response
84-
85-
self.log.info("Compare responses from getwalletinfo RPC and `BGL-cli getwalletinfo`")
86-
if self.is_wallet_compiled():
87-
self.log.info("Compare responses from getwalletinfo RPC and `BGL-cli getwalletinfo`")
88-
cli_response = self.nodes[0].cli.getwalletinfo()
89-
rpc_response = self.nodes[0].getwalletinfo()
90-
assert_equal(cli_response, rpc_response)
91-
9282
self.log.info("Compare responses from getblockchaininfo RPC and `BGL-cli getblockchaininfo`")
9383
cli_response = self.nodes[0].cli.getblockchaininfo()
9484
rpc_response = self.nodes[0].getblockchaininfo()
@@ -103,7 +93,7 @@ def run_test(self):
10393
assert_equal(self.nodes[0].cli("-named", "echo", "arg0=0", "arg1=1", "arg2=2", "arg1=3").send_cli(), ['0', '3', '2'])
10494
assert_raises_rpc_error(-8, "Parameter args specified multiple times", self.nodes[0].cli("-named", "echo", "args=[0,1,2,3]", "4", "5", "6", ).send_cli)
10595

106-
user, password = get_auth_cookie(self.nodes[0].datadir, self.chain)
96+
user, password = get_auth_cookie(self.nodes[0].datadir_path, self.chain)
10797

10898
self.log.info("Test -stdinrpcpass option")
10999
assert_equal(BLOCKS, self.nodes[0].cli(f'-rpcuser={user}', '-stdinrpcpass', input=password).getblockcount())
@@ -156,7 +146,7 @@ def run_test(self):
156146
network_info = self.nodes[0].getnetworkinfo()
157147
cli_get_info_string = self.nodes[0].cli('-getinfo').send_cli()
158148
cli_get_info = cli_get_info_string_to_dict(cli_get_info_string)
159-
assert_equal(cli_get_info["Proxies"], "127.0.0.1:9050 (ipv4, ipv6, onion), 127.0.0.1:7656 (i2p)")
149+
assert_equal(cli_get_info["Proxies"], "127.0.0.1:9050 (ipv4, ipv6, onion, cjdns), 127.0.0.1:7656 (i2p)")
160150

161151
if self.is_specified_wallet_compiled():
162152
self.log.info("Test -getinfo and BGL-cli getwalletinfo return expected wallet info")
@@ -187,7 +177,7 @@ def run_test(self):
187177
w1.sendtoaddress(w2.getnewaddress(), amounts[1])
188178
w1.sendtoaddress(w3.getnewaddress(), amounts[2])
189179

190-
# Mine a block to confirm; adds a block reward (50 BTC) to the default wallet.
180+
# Mine a block to confirm; adds a block reward (200 BGL) to the default wallet.
191181
self.generate(self.nodes[0], 1)
192182

193183
self.log.info("Test -getinfo with multiple wallets and -rpcwallet returns specified wallet balance")

test/functional/mempool_limit.py

+4-31
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ def run_test(self):
4444
assert_equal(node.getmempoolinfo()['minrelaytxfee'], Decimal('0.00001000'))
4545
assert_equal(node.getmempoolinfo()['mempoolminfee'], Decimal('0.00001000'))
4646

47-
tx_batch_size = 1
48-
num_of_batches = 75
47+
tx_batch_size = 250
48+
num_of_batches = 3
4949
# Generate UTXOs to flood the mempool
5050
# 1 to create a tx initially that will be evicted from the mempool later
5151
# 3 batches of multiple transactions with a fee rate much higher than the previous UTXO
@@ -57,7 +57,8 @@ def run_test(self):
5757
self.generate(node, COINBASE_MATURITY - 1)
5858

5959
self.log.info('Create a mempool tx that will be evicted')
60-
tx_to_be_evicted_id =miniwallet.send_self_transfer(from_node=node, fee_rate=relayfee)["txid"]
60+
61+
tx_to_be_evicted_id = miniwallet.send_self_transfer(from_node=node, fee_rate=relayfee)["txid"]
6162
# Increase the tx fee rate to give the subsequent transactions a higher priority in the mempool
6263
# The tx has an approx. vsize of 65k, i.e. multiplying the previous fee rate (in sats/kvB)
6364
# by 130 should result in a fee that corresponds to 2x of that fee rate
@@ -116,34 +117,6 @@ def run_test(self):
116117
assert_equal([tx_poor["wtxid"], tx_child["tx"].getwtxid()], poor_parent_result["fees"]["effective-includes"])
117118
assert_equal([tx_poor["wtxid"], tx_child["tx"].getwtxid()], child_result["fees"]["effective-includes"])
118119

119-
# The node will broadcast each transaction, still abiding by its peer's fee filter
120-
peer.wait_for_broadcast([tx["tx"].getwtxid() for tx in package_txns])
121-
122-
self.log.info("Check a package that passes mempoolminfee but is evicted immediately after submission")
123-
mempoolmin_feerate = node.getmempoolinfo()["mempoolminfee"]
124-
current_mempool = node.getrawmempool(verbose=False)
125-
worst_feerate_btcvb = Decimal("21000000")
126-
for txid in current_mempool:
127-
entry = node.getmempoolentry(txid)
128-
worst_feerate_btcvb = min(worst_feerate_btcvb, entry["fees"]["descendant"] / entry["descendantsize"])
129-
# Needs to be large enough to trigger eviction
130-
target_weight_each = 200000
131-
assert_greater_than(target_weight_each * 2, node.getmempoolinfo()["maxmempool"] - node.getmempoolinfo()["bytes"])
132-
# Should be a true CPFP: parent's feerate is just below mempool min feerate
133-
parent_fee = (mempoolmin_feerate / 1000) * (target_weight_each // 4) - Decimal("0.00001")
134-
# Parent + child is above mempool minimum feerate
135-
child_fee = (worst_feerate_btcvb) * (target_weight_each // 4) - Decimal("0.00001")
136-
# However, when eviction is triggered, these transactions should be at the bottom.
137-
# This assertion assumes parent and child are the same size.
138-
miniwallet.rescan_utxos()
139-
tx_parent_just_below = miniwallet.create_self_transfer(fee=parent_fee, target_weight=target_weight_each)
140-
tx_child_just_above = miniwallet.create_self_transfer(utxo_to_spend=tx_parent_just_below["new_utxo"], fee=child_fee, target_weight=target_weight_each)
141-
# This package ranks below the lowest descendant package in the mempool
142-
assert_greater_than(worst_feerate_btcvb, (parent_fee + child_fee) / (tx_parent_just_below["tx"].get_vsize() + tx_child_just_above["tx"].get_vsize()))
143-
assert_greater_than(mempoolmin_feerate, (parent_fee) / (tx_parent_just_below["tx"].get_vsize()))
144-
assert_greater_than((parent_fee + child_fee) / (tx_parent_just_below["tx"].get_vsize() + tx_child_just_above["tx"].get_vsize()), mempoolmin_feerate / 1000)
145-
assert_raises_rpc_error(-26, "mempool full", node.submitpackage, [tx_parent_just_below["hex"], tx_child_just_above["hex"]])
146-
147120
self.log.info('Test passing a value below the minimum (5 MB) to -maxmempool throws an error')
148121
self.stop_node(0)
149122
self.nodes[0].assert_start_raises_init_error(["-maxmempool=4"], "Error: -maxmempool must be at least 5 MB")

test/functional/p2p_sendtxrcncl.py

-5
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,6 @@ def run_test(self):
135135
assert not peer.sendtxrcncl_msg_received
136136
self.nodes[0].disconnect_p2ps()
137137

138-
self.log.info("SENDTXRCNCL should not be sent if feeler")
139-
peer = self.nodes[0].add_outbound_p2p_connection(P2PFeelerReceiver(), p2p_idx=0, connection_type="feeler")
140-
assert not peer.sendtxrcncl_msg_received
141-
self.nodes[0].disconnect_p2ps()
142-
143138
self.log.info("SENDTXRCNCL should not be sent if addrfetch")
144139
peer = self.nodes[0].add_outbound_p2p_connection(
145140
SendTxrcnclReceiver(), wait_for_verack=True, p2p_idx=0, connection_type="addr-fetch")

test/functional/rpc_createmultisig.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def do_multisig(self):
157157
try:
158158
node1.loadwallet('wmulti')
159159
except JSONRPCException as e:
160-
path = self.nodes[1].wallets_path / "wmulti"
160+
path = os.path.join(self.options.tmpdir, "node1", "regtest", "wallets", "wmulti")
161161
if e.error['code'] == -18 and "Wallet file verification failed. Failed to load database path '{}'. Path does not exist.".format(path) in e.error['message']:
162162
node1.createwallet(wallet_name='wmulti', disable_private_keys=True)
163163
else:
@@ -167,15 +167,12 @@ def do_multisig(self):
167167
# Construct the expected descriptor
168168
desc = 'multi({},{})'.format(self.nsigs, ','.join(self.pub))
169169
if self.output_type == 'legacy':
170-
#desc = 'sh({})'.format(desc)
171-
return
170+
desc = 'sh({})'.format(desc)
172171
elif self.output_type == 'p2sh-segwit':
173-
#desc = 'sh(wsh({}))'.format(desc)
174-
return
172+
desc = 'sh(wsh({}))'.format(desc)
175173
elif self.output_type == 'bech32':
176174
desc = 'wsh({})'.format(desc)
177175
desc = descsum_create(desc)
178-
print(self.output_type)
179176

180177
msig = node2.createmultisig(self.nsigs, self.pub, self.output_type)
181178
assert 'warnings' not in msig
@@ -195,7 +192,6 @@ def do_multisig(self):
195192
assert maddw == madd
196193
assert mredeemw == mredeem
197194
wmulti.unloadwallet()
198-
print(madd)
199195
spk = address_to_scriptpubkey(madd)
200196
txid = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=spk, amount=1300)["txid"]
201197
tx = node0.getrawtransaction(txid, True)

test/functional/test_framework/blocktools.py

-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@
5757

5858
MAX_FUTURE_BLOCK_TIME = 2 * 60 * 60
5959

60-
# Coinbase transaction outputs can only be spent after this number of new blocks (network rule)
61-
COINBASE_MATURITY = 100
62-
6360
# From BIP141
6461
WITNESS_COMMITMENT_HEADER = b"\xaa\x21\xa9\xed"
6562

test/functional/wallet_send.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -328,22 +328,23 @@ def run_test(self):
328328
res2 = self.test_send(from_wallet=w0, to_wallet=w1, amount=1, fee_rate="1", add_to_wallet=False)
329329
assert_equal(self.nodes[1].decodepsbt(res1["psbt"])["fee"], self.nodes[1].decodepsbt(res2["psbt"])["fee"])
330330

331+
tx_size = 141
331332
res = self.test_send(from_wallet=w0, to_wallet=w1, amount=1, fee_rate=7, add_to_wallet=False)
332333
fee = self.nodes[1].decodepsbt(res["psbt"])["fee"]
333-
assert_fee_amount(fee, count_bytes(res["hex"]), Decimal("0.00007"))
334+
assert_fee_amount(fee, tx_size, Decimal("0.00007"))
334335

335336
# "unset" and None are treated the same for estimate_mode
336337
res = self.test_send(from_wallet=w0, to_wallet=w1, amount=1, fee_rate=2, estimate_mode="unset", add_to_wallet=False)
337338
fee = self.nodes[1].decodepsbt(res["psbt"])["fee"]
338-
assert_fee_amount(fee, count_bytes(res["hex"]), Decimal("0.00002"))
339+
assert_fee_amount(fee, tx_size, Decimal("0.00002"))
339340

340341
res = self.test_send(from_wallet=w0, to_wallet=w1, amount=1, arg_fee_rate=4.531, add_to_wallet=False)
341342
fee = self.nodes[1].decodepsbt(res["psbt"])["fee"]
342-
assert_fee_amount(fee, count_bytes(res["hex"]), Decimal("0.00004531"))
343+
assert_fee_amount(fee, tx_size, Decimal("0.00004531"))
343344

344345
res = self.test_send(from_wallet=w0, to_wallet=w1, amount=1, arg_fee_rate=3, add_to_wallet=False)
345346
fee = self.nodes[1].decodepsbt(res["psbt"])["fee"]
346-
assert_fee_amount(fee, count_bytes(res["hex"]), Decimal("0.00003"))
347+
assert_fee_amount(fee, tx_size, Decimal("0.00003"))
347348

348349
# Test that passing fee_rate as both an argument and an option raises.
349350
self.test_send(from_wallet=w0, to_wallet=w1, amount=1, arg_fee_rate=1, fee_rate=1, add_to_wallet=False,
@@ -387,7 +388,7 @@ def run_test(self):
387388
self.test_send(from_wallet=w0, to_wallet=w1, amount=1, fee_rate=invalid_value, expect_error=(-3, msg))
388389
self.test_send(from_wallet=w0, to_wallet=w1, amount=1, arg_fee_rate=invalid_value, expect_error=(-3, msg))
389390
# Test fee_rate values that cannot be represented in sat/vB.
390-
for invalid_value in [0.0001, 0.00000001, 0.00099999, 31.99999999]:
391+
for invalid_value in [0.0001, 0.00000001, 0.00099999, 31.99999999, "0.0001", "0.00000001", "0.00099999", "31.99999999"]:
391392
self.test_send(from_wallet=w0, to_wallet=w1, amount=1, fee_rate=invalid_value, expect_error=(-3, msg))
392393
self.test_send(from_wallet=w0, to_wallet=w1, amount=1, arg_fee_rate=invalid_value, expect_error=(-3, msg))
393394
# Test fee_rate out of range (negative number).

test/functional/wallet_signer.py

+2-10
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
"""Test external signer.
66
Verify that a BGLd node can use an external signer command
7-
See also rpc_signer.py for tests without wallet context.
8-
>>>>>>> b54b2e7b1... Move external signer out of wallet module
9-
"""
7+
See also rpc_signer.py for tests without wallet context."""
108
import os
119
import platform
1210

@@ -43,6 +41,7 @@ def mock_multi_signers_path(self):
4341
return path
4442

4543
def set_test_params(self):
44+
print("set_test_params", self.mock_signer_path())
4645
self.num_nodes = 2
4746

4847
self.extra_args = [
@@ -119,13 +118,6 @@ def test_valid_signer(self):
119118
assert_equal(address_info['ismine'], True)
120119
assert_equal(address_info['hdkeypath'], "m/44h/1h/0h/0/0")
121120

122-
address4 = hww.getnewaddress(address_type="bech32m")
123-
assert_equal(address4, "bcrt1phw4cgpt6cd30kz9k4wkpwm872cdvhss29jga2xpmftelhqll62ms4e9sqj")
124-
address_info = hww.getaddressinfo(address4)
125-
assert_equal(address_info['solvable'], True)
126-
assert_equal(address_info['ismine'], True)
127-
assert_equal(address_info['hdkeypath'], "m/86h/1h/0h/0/0")
128-
129121
self.log.info('Test walletdisplayaddress')
130122
result = hww.walletdisplayaddress(address1)
131123
assert_equal(result, {"address": address1})

0 commit comments

Comments
 (0)