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

chainparams, tests: Fix Taproot activation and wallet_taproot.py functional test #257

Merged
merged 2 commits into from
Dec 18, 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
4 changes: 3 additions & 1 deletion digibyte.code-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
],
"settings": {
"files.associations": {
"*.tfvars": "terraform",
"chrono": "cpp",
"initializer_list": "cpp",
"cctype": "cpp",
Expand All @@ -31,7 +32,8 @@
"thread": "cpp",
"cinttypes": "cpp",
"typeindex": "cpp",
"ios": "cpp"
"ios": "cpp",
"*.ipp": "cpp"
},
"github.copilot.advanced": {
"projectDirectories": [
Expand Down
6 changes: 3 additions & 3 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,10 +684,10 @@ class CRegTestParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].min_activation_height = 0; // No activation delay

// Deployment of Taproot (BIPs 340-342)
// Activation of Taproot (BIPs 340-342)
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].bit = 2;
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nStartTime = 4070908800; // January 1st, 2099
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = 4099766400; // December 1st, 2099
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
consensus.vDeployments[Consensus::DEPLOYMENT_TAPROOT].min_activation_height = 0; // No activation delay

consensus.nMinimumChainWork = uint256{};
Expand Down
30 changes: 25 additions & 5 deletions test/functional/wallet_taproot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import random
from test_framework.blocktools import (
COINBASE_MATURITY,
COINBASE_MATURITY_2,
)
from decimal import Decimal
from test_framework.test_framework import DigiByteTestFramework
Expand Down Expand Up @@ -274,11 +274,11 @@ def do_test_sendtoaddress(self, comment, pattern, privmap, treefn, keys_pay, key
assert_equal(addr_g, addr_r)
boring_balance = int(self.boring.getbalance() * 100000000)
to_amnt = random.randrange(1000000, boring_balance)
self.boring.sendtoaddress(address=addr_g, amount=Decimal(to_amnt) / 100000000, subtractfeefromamount=True, fee_rate=110)
self.boring.sendtoaddress(address=addr_g, amount=Decimal(to_amnt) / 100000000, subtractfeefromamount=True, fee_rate=11000)
self.generatetoaddress(self.nodes[0], 1, self.boring.getnewaddress(), sync_fun=self.no_op)
test_balance = int(self.rpc_online.getbalance() * 100000000)
ret_amnt = random.randrange(100000, test_balance)
res = self.rpc_online.sendtoaddress(address=self.boring.getnewaddress(), amount=Decimal(ret_amnt) / 100000000, subtractfeefromamount=True, fee_rate=300)
res = self.rpc_online.sendtoaddress(address=self.boring.getnewaddress(), amount=Decimal(ret_amnt) / 100000000, subtractfeefromamount=True, fee_rate=30000)
self.generatetoaddress(self.nodes[0], 1, self.boring.getnewaddress(), sync_fun=self.no_op)
assert(self.rpc_online.gettransaction(res)["confirmations"] > 0)

Expand Down Expand Up @@ -309,7 +309,7 @@ def do_test_psbt(self, comment, pattern, privmap, treefn, keys_pay, keys_change)
self.generatetoaddress(self.nodes[0], 1, self.boring.getnewaddress(), sync_fun=self.no_op)
test_balance = int(self.psbt_online.getbalance() * 100000000)
ret_amnt = random.randrange(100000, test_balance)
psbt = self.psbt_online.walletcreatefundedpsbt([], [{self.boring.getnewaddress(): Decimal(ret_amnt) / 100000000}], None, {"subtractFeeFromOutputs":[0], "fee_rate": 300})['psbt']
psbt = self.psbt_online.walletcreatefundedpsbt([], [{self.boring.getnewaddress(): Decimal(ret_amnt) / 100000000}], None, {"subtractFeeFromOutputs":[0], "fee_rate": 30000})['psbt']
res = self.psbt_offline.walletprocesspsbt(psbt)
assert(res['complete'])
rawtx = self.nodes[0].finalizepsbt(res['psbt'])['hex']
Expand Down Expand Up @@ -344,9 +344,29 @@ def run_test(self):
self.psbt_online = self.nodes[0].get_wallet_rpc("psbt_online")
self.psbt_offline = self.nodes[1].get_wallet_rpc("psbt_offline")

self.log.info("Connecting nodes...")
self.connect_nodes(0, 1)
self.connect_nodes(1, 2)
self.connect_nodes(0, 2)

# Wait for connections to be fully established
self.wait_until(lambda: all(len(node.getpeerinfo()) >= 2 for node in self.nodes[0:3]))

self.log.info("Mining blocks...")
gen_addr = self.boring.getnewaddress()
self.generatetoaddress(self.nodes[0], COINBASE_MATURITY + 1, gen_addr, sync_fun=self.no_op)
self.generatetoaddress(self.nodes[0], COINBASE_MATURITY_2 + 1, gen_addr)
self.sync_all()

# Ensure sufficient balance before proceeding
balance = self.boring.getbalance()
if balance == 0:
self.log.info("Initial balance zero, generating more blocks...")
self.generatetoaddress(self.nodes[0], 101, gen_addr)
self.sync_all()
balance = self.boring.getbalance()

if balance == 0:
raise RuntimeError("Insufficient funds in boring wallet after block generation")

self.do_test(
"tr(XPRV)",
Expand Down