Skip to content

Commit

Permalink
Merge pull request #132 from BitgesellOfficial/bitcoinsync31July2023
Browse files Browse the repository at this point in the history
Update test/functional
  • Loading branch information
wu-emma authored Mar 25, 2024
2 parents 217e921 + d875c76 commit 800092f
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 81 deletions.
6 changes: 3 additions & 3 deletions src/kernel/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,13 +373,13 @@ class SigNetParams : public CChainParams {

vFixedSeeds.clear();

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

bech32_hrp = "tb";
bech32_hrp = "tbgl";

fDefaultConsistencyChecks = false;
//fRequireStandard = true;
Expand Down
8 changes: 4 additions & 4 deletions test/functional/feature_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -1004,14 +1004,14 @@ def run_test(self):
#
self.log.info("Reject a block trying to claim too much subsidy in the coinbase transaction")
self.move_tip(65)
b68 = self.next_block(68, additional_coinbase_value=10)
b68 = self.next_block(68, additional_coinbase_value=int(10*0.1)) #multiply to 0.1 as 90% fees will be burnt
tx = self.create_and_sign_transaction(out[20], out[20].vout[0].nValue - 9)
b68 = self.update_block(68, [tx])
self.send_blocks([b68], success=False, reject_reason='bad-cb-amount', reconnect=True)

self.log.info("Accept a block claiming the correct subsidy in the coinbase transaction")
self.move_tip(65)
b69 = self.next_block(69, additional_coinbase_value=10)
b69 = self.next_block(69, additional_coinbase_value=int(10*0.1)) #multiply to 0.1 as 90% fees will be burnt
tx = self.create_and_sign_transaction(out[20], out[20].vout[0].nValue - 10)
self.update_block(69, [tx])
self.send_blocks([b69], True)
Expand Down Expand Up @@ -1362,9 +1362,9 @@ def next_block(self, number, spend=None, additional_coinbase_value=0, script=CSc
if spend is None:
block = create_block(base_block_hash, coinbase, block_time, version=version)
else:
coinbase.vout[0].nValue += spend.vout[0].nValue - 1 # all but one satoshi to fees
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
coinbase.rehash()
tx = self.create_tx(spend, 0, 1, script) # spend 1 satoshi
tx = self.create_tx(spend, 0, 10, script) # spend 10 satoshi
self.sign_tx(tx, spend)
tx.rehash()
block = create_block(base_block_hash, coinbase, block_time, version=version, txlist=[tx])
Expand Down
16 changes: 3 additions & 13 deletions test/functional/interface_BGL_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,6 @@ def run_test(self):
"""Main test logic"""
self.generate(self.nodes[0], BLOCKS)

cli_response = self.nodes[0].cli("-version").send_cli()
assert "{} RPC client version".format(self.config['environment']['PACKAGE_NAME']) in cli_response

self.log.info("Compare responses from getwalletinfo RPC and `BGL-cli getwalletinfo`")
if self.is_wallet_compiled():
self.log.info("Compare responses from getwalletinfo RPC and `BGL-cli getwalletinfo`")
cli_response = self.nodes[0].cli.getwalletinfo()
rpc_response = self.nodes[0].getwalletinfo()
assert_equal(cli_response, rpc_response)

self.log.info("Compare responses from getblockchaininfo RPC and `BGL-cli getblockchaininfo`")
cli_response = self.nodes[0].cli.getblockchaininfo()
rpc_response = self.nodes[0].getblockchaininfo()
Expand All @@ -103,7 +93,7 @@ def run_test(self):
assert_equal(self.nodes[0].cli("-named", "echo", "arg0=0", "arg1=1", "arg2=2", "arg1=3").send_cli(), ['0', '3', '2'])
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)

user, password = get_auth_cookie(self.nodes[0].datadir, self.chain)
user, password = get_auth_cookie(self.nodes[0].datadir_path, self.chain)

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

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

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

self.log.info("Test -getinfo with multiple wallets and -rpcwallet returns specified wallet balance")
Expand Down
35 changes: 4 additions & 31 deletions test/functional/mempool_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def run_test(self):
assert_equal(node.getmempoolinfo()['minrelaytxfee'], Decimal('0.00001000'))
assert_equal(node.getmempoolinfo()['mempoolminfee'], Decimal('0.00001000'))

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

self.log.info('Create a mempool tx that will be evicted')
tx_to_be_evicted_id =miniwallet.send_self_transfer(from_node=node, fee_rate=relayfee)["txid"]

tx_to_be_evicted_id = miniwallet.send_self_transfer(from_node=node, fee_rate=relayfee)["txid"]
# Increase the tx fee rate to give the subsequent transactions a higher priority in the mempool
# The tx has an approx. vsize of 65k, i.e. multiplying the previous fee rate (in sats/kvB)
# by 130 should result in a fee that corresponds to 2x of that fee rate
Expand Down Expand Up @@ -116,34 +117,6 @@ def run_test(self):
assert_equal([tx_poor["wtxid"], tx_child["tx"].getwtxid()], poor_parent_result["fees"]["effective-includes"])
assert_equal([tx_poor["wtxid"], tx_child["tx"].getwtxid()], child_result["fees"]["effective-includes"])

# The node will broadcast each transaction, still abiding by its peer's fee filter
peer.wait_for_broadcast([tx["tx"].getwtxid() for tx in package_txns])

self.log.info("Check a package that passes mempoolminfee but is evicted immediately after submission")
mempoolmin_feerate = node.getmempoolinfo()["mempoolminfee"]
current_mempool = node.getrawmempool(verbose=False)
worst_feerate_btcvb = Decimal("21000000")
for txid in current_mempool:
entry = node.getmempoolentry(txid)
worst_feerate_btcvb = min(worst_feerate_btcvb, entry["fees"]["descendant"] / entry["descendantsize"])
# Needs to be large enough to trigger eviction
target_weight_each = 200000
assert_greater_than(target_weight_each * 2, node.getmempoolinfo()["maxmempool"] - node.getmempoolinfo()["bytes"])
# Should be a true CPFP: parent's feerate is just below mempool min feerate
parent_fee = (mempoolmin_feerate / 1000) * (target_weight_each // 4) - Decimal("0.00001")
# Parent + child is above mempool minimum feerate
child_fee = (worst_feerate_btcvb) * (target_weight_each // 4) - Decimal("0.00001")
# However, when eviction is triggered, these transactions should be at the bottom.
# This assertion assumes parent and child are the same size.
miniwallet.rescan_utxos()
tx_parent_just_below = miniwallet.create_self_transfer(fee=parent_fee, target_weight=target_weight_each)
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)
# This package ranks below the lowest descendant package in the mempool
assert_greater_than(worst_feerate_btcvb, (parent_fee + child_fee) / (tx_parent_just_below["tx"].get_vsize() + tx_child_just_above["tx"].get_vsize()))
assert_greater_than(mempoolmin_feerate, (parent_fee) / (tx_parent_just_below["tx"].get_vsize()))
assert_greater_than((parent_fee + child_fee) / (tx_parent_just_below["tx"].get_vsize() + tx_child_just_above["tx"].get_vsize()), mempoolmin_feerate / 1000)
assert_raises_rpc_error(-26, "mempool full", node.submitpackage, [tx_parent_just_below["hex"], tx_child_just_above["hex"]])

self.log.info('Test passing a value below the minimum (5 MB) to -maxmempool throws an error')
self.stop_node(0)
self.nodes[0].assert_start_raises_init_error(["-maxmempool=4"], "Error: -maxmempool must be at least 5 MB")
Expand Down
5 changes: 0 additions & 5 deletions test/functional/p2p_sendtxrcncl.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,6 @@ def run_test(self):
assert not peer.sendtxrcncl_msg_received
self.nodes[0].disconnect_p2ps()

self.log.info("SENDTXRCNCL should not be sent if feeler")
peer = self.nodes[0].add_outbound_p2p_connection(P2PFeelerReceiver(), p2p_idx=0, connection_type="feeler")
assert not peer.sendtxrcncl_msg_received
self.nodes[0].disconnect_p2ps()

self.log.info("SENDTXRCNCL should not be sent if addrfetch")
peer = self.nodes[0].add_outbound_p2p_connection(
SendTxrcnclReceiver(), wait_for_verack=True, p2p_idx=0, connection_type="addr-fetch")
Expand Down
10 changes: 3 additions & 7 deletions test/functional/rpc_createmultisig.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def do_multisig(self):
try:
node1.loadwallet('wmulti')
except JSONRPCException as e:
path = self.nodes[1].wallets_path / "wmulti"
path = os.path.join(self.options.tmpdir, "node1", "regtest", "wallets", "wmulti")
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']:
node1.createwallet(wallet_name='wmulti', disable_private_keys=True)
else:
Expand All @@ -167,15 +167,12 @@ def do_multisig(self):
# Construct the expected descriptor
desc = 'multi({},{})'.format(self.nsigs, ','.join(self.pub))
if self.output_type == 'legacy':
#desc = 'sh({})'.format(desc)
return
desc = 'sh({})'.format(desc)
elif self.output_type == 'p2sh-segwit':
#desc = 'sh(wsh({}))'.format(desc)
return
desc = 'sh(wsh({}))'.format(desc)
elif self.output_type == 'bech32':
desc = 'wsh({})'.format(desc)
desc = descsum_create(desc)
print(self.output_type)

msig = node2.createmultisig(self.nsigs, self.pub, self.output_type)
assert 'warnings' not in msig
Expand All @@ -195,7 +192,6 @@ def do_multisig(self):
assert maddw == madd
assert mredeemw == mredeem
wmulti.unloadwallet()
print(madd)
spk = address_to_scriptpubkey(madd)
txid = self.wallet.send_to(from_node=self.nodes[0], scriptPubKey=spk, amount=1300)["txid"]
tx = node0.getrawtransaction(txid, True)
Expand Down
3 changes: 0 additions & 3 deletions test/functional/test_framework/blocktools.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@

MAX_FUTURE_BLOCK_TIME = 2 * 60 * 60

# Coinbase transaction outputs can only be spent after this number of new blocks (network rule)
COINBASE_MATURITY = 100

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

Expand Down
11 changes: 6 additions & 5 deletions test/functional/wallet_send.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,22 +328,23 @@ def run_test(self):
res2 = self.test_send(from_wallet=w0, to_wallet=w1, amount=1, fee_rate="1", add_to_wallet=False)
assert_equal(self.nodes[1].decodepsbt(res1["psbt"])["fee"], self.nodes[1].decodepsbt(res2["psbt"])["fee"])

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

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

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

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

# Test that passing fee_rate as both an argument and an option raises.
self.test_send(from_wallet=w0, to_wallet=w1, amount=1, arg_fee_rate=1, fee_rate=1, add_to_wallet=False,
Expand Down Expand Up @@ -387,7 +388,7 @@ def run_test(self):
self.test_send(from_wallet=w0, to_wallet=w1, amount=1, fee_rate=invalid_value, expect_error=(-3, msg))
self.test_send(from_wallet=w0, to_wallet=w1, amount=1, arg_fee_rate=invalid_value, expect_error=(-3, msg))
# Test fee_rate values that cannot be represented in sat/vB.
for invalid_value in [0.0001, 0.00000001, 0.00099999, 31.99999999]:
for invalid_value in [0.0001, 0.00000001, 0.00099999, 31.99999999, "0.0001", "0.00000001", "0.00099999", "31.99999999"]:
self.test_send(from_wallet=w0, to_wallet=w1, amount=1, fee_rate=invalid_value, expect_error=(-3, msg))
self.test_send(from_wallet=w0, to_wallet=w1, amount=1, arg_fee_rate=invalid_value, expect_error=(-3, msg))
# Test fee_rate out of range (negative number).
Expand Down
12 changes: 2 additions & 10 deletions test/functional/wallet_signer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
"""Test external signer.
Verify that a BGLd node can use an external signer command
See also rpc_signer.py for tests without wallet context.
>>>>>>> b54b2e7b1... Move external signer out of wallet module
"""
See also rpc_signer.py for tests without wallet context."""
import os
import platform

Expand Down Expand Up @@ -43,6 +41,7 @@ def mock_multi_signers_path(self):
return path

def set_test_params(self):
print("set_test_params", self.mock_signer_path())
self.num_nodes = 2

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

address4 = hww.getnewaddress(address_type="bech32m")
assert_equal(address4, "bcrt1phw4cgpt6cd30kz9k4wkpwm872cdvhss29jga2xpmftelhqll62ms4e9sqj")
address_info = hww.getaddressinfo(address4)
assert_equal(address_info['solvable'], True)
assert_equal(address_info['ismine'], True)
assert_equal(address_info['hdkeypath'], "m/86h/1h/0h/0/0")

self.log.info('Test walletdisplayaddress')
result = hww.walletdisplayaddress(address1)
assert_equal(result, {"address": address1})
Expand Down

0 comments on commit 800092f

Please sign in to comment.