Skip to content

Commit b105ff4

Browse files
committed
feature_fedpeg.py: Run in various dynafed transition settings
1 parent feef196 commit b105ff4

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

src/rpc/mining.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ UniValue getnewblockhex(const JSONRPCRequest& request)
10071007
{
10081008
{"signblockscript", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Hex-encoded block signing script to propose"},
10091009
{"max_block_witness", RPCArg::Type::NUM, RPCArg::Optional::NO, "Total size in witness bytes that are allowed in the dynamic federations block witness for blocksigning"},
1010-
{"fedpegscript", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Hex-encoded fedpegscript for dynamic block proposal"},
1010+
{"fedpegscript", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Hex-encoded fedpegscript for dynamic block proposal. This is interpreted as a v0 segwit witnessScript, and fills out the fedpeg_program as such."},
10111011
{"extension_space", RPCArg::Type::ARR, RPCArg::Optional::NO, "Array of additional fields to embed in the dynamic blockheader. Has no consensus meaning aside from serialized size changes. This space is currently is only used for PAK enforcement.",
10121012
{
10131013
{"", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "Hex encoded string for extension entries."},

test/functional/feature_fedpeg.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ def add_options(self, parser):
5252
help="Use a different binary for launching nodes")
5353
parser.add_argument("--parent_bitcoin", dest="parent_bitcoin", default=False, action="store_true",
5454
help="Parent nodes are Bitcoin")
55+
parser.add_argument("--pre_transition", dest="pre_transition", default=False, action="store_true",
56+
help="Run test in dynafed activated chain, without a transition")
57+
parser.add_argument("--post_transition", dest="post_transition", default=False, action="store_true",
58+
help="Run test in dynafed activated chain, after transition and additional epoch to invalidate old fedpegscript")
5559

5660
def skip_test_if_missing_module(self):
5761
self.skip_if_no_wallet()
@@ -134,6 +138,10 @@ def setup_network(self, split=False):
134138
'-con_parent_pegged_asset=%s' % parent_pegged_asset,
135139
])
136140

141+
# Immediate activation of dynafed when requested versus "never" from conf
142+
if self.options.pre_transition or self.options.post_transition:
143+
extra_args.extend(["-con_dyna_deploy_start=-1"])
144+
137145
# Use rpcuser auth only for first parent.
138146
if n==0:
139147
# Extract username and password from cookie file and use directly.
@@ -182,6 +190,22 @@ def run_test(self):
182190
#parent2 = self.nodes[1]
183191
sidechain = self.nodes[2]
184192
sidechain2 = self.nodes[3]
193+
194+
# If we're testing post-transition, force a fedpegscript transition and
195+
# getting rid of old fedpegscript by making at least another epoch pass by
196+
WSH_OP_TRUE = self.nodes[0].decodescript("51")["segwit"]["hex"]
197+
# We just randomize the keys a bit to get another valid fedpegscript
198+
new_fedpegscript = sidechain.tweakfedpegscript("f00dbabe")["script"]
199+
if self.options.post_transition:
200+
print("Running test post-transition")
201+
for _ in range(30):
202+
block_hex = sidechain.getnewblockhex(0, {"signblockscript":WSH_OP_TRUE, "max_block_witness":10, "fedpegscript":new_fedpegscript, "extension_space":[]})
203+
sidechain.submitblock(block_hex)
204+
assert_equal(sidechain.getsidechaininfo()["current_fedpegscripts"], [new_fedpegscript]*2)
205+
206+
if self.options.pre_transition:
207+
print("Running test pre-transition, dynafed activated from first block")
208+
185209
for node in self.nodes:
186210
node.importprivkey(privkey=node.get_deterministic_priv_key().key, label="mining")
187211
util.node_fastmerkle = sidechain

test/functional/test_runner.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070
# Scripts that are run by the travis build process.
7171
# vv First elements tests vv
7272
'feature_fedpeg.py',
73+
'feature_fedpeg.py --pre_transition',
74+
'feature_fedpeg.py --post_transition',
7375
'feature_mandatory_coinbase.py',
7476
'feature_block_subsidy.py',
7577
'feature_connect_genesis_outputs.py',

0 commit comments

Comments
 (0)