Skip to content

Commit fa89bad

Browse files
author
MarcoFalke
committed
test: Require standard txs in regtest
1 parent fa9b419 commit fa89bad

17 files changed

+61
-11
lines changed

doc/release-notes.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,20 @@ Low-level Changes section below.
103103
Low-level changes
104104
=================
105105

106+
RPC
107+
---
108+
109+
110+
Tests
111+
-----
112+
113+
- The regression test chain, that can be enabled by the `-regtest` command line
114+
flag, now requires transactions to not violate standard policy by default.
115+
Making the default the same as for mainnet, makes it easier to test mainnet
116+
behavior on regtest. Be reminded that the testnet still allows non-standard
117+
txs by default and that the policy can be locally adjusted with the
118+
`-acceptnonstdtxn` command line flag for both test chains.
119+
106120
Configuration
107121
------------
108122

src/chainparams.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ class CMainParams : public CChainParams {
141141

142142
fDefaultConsistencyChecks = false;
143143
fRequireStandard = true;
144+
m_is_test_chain = false;
144145

145146
checkpointData = {
146147
{
@@ -246,6 +247,7 @@ class CTestNetParams : public CChainParams {
246247

247248
fDefaultConsistencyChecks = false;
248249
fRequireStandard = false;
250+
m_is_test_chain = true;
249251

250252

251253
checkpointData = {
@@ -322,7 +324,8 @@ class CRegTestParams : public CChainParams {
322324
vSeeds.clear(); //!< Regtest mode doesn't have any DNS seeds.
323325

324326
fDefaultConsistencyChecks = true;
325-
fRequireStandard = false;
327+
fRequireStandard = true;
328+
m_is_test_chain = true;
326329

327330
checkpointData = {
328331
{

src/chainparams.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ class CChainParams
6666
bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
6767
/** Policy: Filter transactions that do not match well-defined patterns */
6868
bool RequireStandard() const { return fRequireStandard; }
69+
/** If this is a test chain */
70+
bool IsTestChain() const { return m_is_test_chain; }
6971
uint64_t PruneAfterHeight() const { return nPruneAfterHeight; }
7072
/** Minimum free space (in GB) needed for data directory */
7173
uint64_t AssumedBlockchainSize() const { return m_assumed_blockchain_size; }
@@ -101,6 +103,7 @@ class CChainParams
101103
std::vector<SeedSpec6> vFixedSeeds;
102104
bool fDefaultConsistencyChecks;
103105
bool fRequireStandard;
106+
bool m_is_test_chain;
104107
CCheckpointData checkpointData;
105108
ChainTxData chainTxData;
106109
bool m_fallback_fee_enabled;

src/init.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,8 +1150,9 @@ bool AppInitParameterInteraction()
11501150
}
11511151

11521152
fRequireStandard = !gArgs.GetBoolArg("-acceptnonstdtxn", !chainparams.RequireStandard());
1153-
if (chainparams.RequireStandard() && !fRequireStandard)
1153+
if (!chainparams.IsTestChain() && !fRequireStandard) {
11541154
return InitError(strprintf("acceptnonstdtxn is not currently supported for %s chain", chainparams.NetworkIDString()));
1155+
}
11551156
nBytesPerSigOp = gArgs.GetArg("-bytespersigop", nBytesPerSigOp);
11561157

11571158
if (!g_wallet_init_interface.ParameterInteraction()) return false;

test/functional/feature_bip68_sequence.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
class BIP68Test(BitcoinTestFramework):
3030
def set_test_params(self):
3131
self.num_nodes = 2
32-
self.extra_args = [[], ["-acceptnonstdtxn=0"]]
32+
self.extra_args = [
33+
["-acceptnonstdtxn=1"],
34+
["-acceptnonstdtxn=0"],
35+
]
3336

3437
def skip_test_if_missing_module(self):
3538
self.skip_if_no_wallet()

test/functional/feature_block.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class FullBlockTest(BitcoinTestFramework):
7878
def set_test_params(self):
7979
self.num_nodes = 1
8080
self.setup_clean_chain = True
81-
self.extra_args = [[]]
81+
self.extra_args = [['-acceptnonstdtxn=1']] # This is a consensus block test, we don't care about tx policy
8282

8383
def run_test(self):
8484
node = self.nodes[0] # convenience reference to the node

test/functional/feature_cltv.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ def cltv_validate(node, tx, height):
5757
class BIP65Test(BitcoinTestFramework):
5858
def set_test_params(self):
5959
self.num_nodes = 1
60-
self.extra_args = [['-whitelist=127.0.0.1', '-par=1']] # Use only one script thread to get the exact reject reason for testing
60+
self.extra_args = [[
61+
'-whitelist=127.0.0.1',
62+
'-par=1', # Use only one script thread to get the exact reject reason for testing
63+
'-acceptnonstdtxn=1', # cltv_invalidate is nonstandard
64+
]]
6165
self.setup_clean_chain = True
6266
self.rpc_timeout = 120
6367

test/functional/feature_maxuploadtarget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class MaxUploadTest(BitcoinTestFramework):
3535
def set_test_params(self):
3636
self.setup_clean_chain = True
3737
self.num_nodes = 1
38-
self.extra_args = [["-maxuploadtarget=800"]]
38+
self.extra_args = [["-maxuploadtarget=800", "-acceptnonstdtxn=1"]]
3939

4040
# Cache for utxos, as the listunspent may take a long time later in the test
4141
self.utxo_cache = []

test/functional/feature_rbf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ def set_test_params(self):
6767
self.num_nodes = 1
6868
self.extra_args = [
6969
[
70+
"-acceptnonstdtxn=1",
7071
"-maxorphantx=1000",
71-
"-whitelist=127.0.0.1",
7272
"-limitancestorcount=50",
7373
"-limitancestorsize=101",
7474
"-limitdescendantcount=200",

test/functional/feature_segwit.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,20 @@ def set_test_params(self):
5353
# This test tests SegWit both pre and post-activation, so use the normal BIP9 activation.
5454
self.extra_args = [
5555
[
56+
"-acceptnonstdtxn=1",
5657
"-rpcserialversion=0",
5758
"-vbparams=segwit:0:999999999999",
5859
"-addresstype=legacy",
5960
],
6061
[
62+
"-acceptnonstdtxn=1",
6163
"-blockversion=4",
6264
"-rpcserialversion=1",
6365
"-vbparams=segwit:0:999999999999",
6466
"-addresstype=legacy",
6567
],
6668
[
69+
"-acceptnonstdtxn=1",
6770
"-blockversion=536870915",
6871
"-vbparams=segwit:0:999999999999",
6972
"-addresstype=legacy",

0 commit comments

Comments
 (0)