Skip to content

Commit

Permalink
test: fix tests broken by change to getpeginaddress
Browse files Browse the repository at this point in the history
Fixes 2 functional tests failing since PR ElementsProject#1327 changes getpeginaddress
to only be valid when IsInitialBlockDownload is false
  • Loading branch information
delta1 committed Apr 24, 2024
1 parent 5f1cc1a commit af52976
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
21 changes: 19 additions & 2 deletions test/functional/rpc_tweakfedpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,25 @@
class TweakFedpegTest(BitcoinTestFramework):

def set_test_params(self):
self.num_nodes = 3
self.num_nodes = 6
self.setup_clean_chain = True
self.extra_args = [[
"-fedpegscript="+OP_TRUE_SCRIPT
],
[
"-fedpegscript="+OP_CMS_SCRIPT
],
[
"-fedpegscript="+LIQUID_SCRIPT,
"-con_dyna_deploy_signal=1",
"-evbparams=dynafed:0:::", # test dynafed derivation
],
[
"-fedpegscript="+OP_TRUE_SCRIPT
],
[
"-fedpegscript="+OP_CMS_SCRIPT
],
[
"-fedpegscript="+LIQUID_SCRIPT,
"-con_dyna_deploy_signal=1",
Expand All @@ -31,19 +42,24 @@ def set_test_params(self):

def setup_network(self):
self.setup_nodes()
self.connect_nodes(0, 3)
self.connect_nodes(1, 4)
self.connect_nodes(2, 5)

def skip_test_if_missing_module(self):
self.skip_if_no_wallet()

def run_test(self):
# Test that OP_TRUE mainchain_addr/claim_script never changes
assert_equal(self.nodes[0].getsidechaininfo()["fedpegscript"], OP_TRUE_SCRIPT)
self.generate(self.nodes[0], 1, sync_fun=self.no_op) # just to get node out of ibd
pegin_addr = self.nodes[0].getpeginaddress()
for _ in range(5):
assert_equal(pegin_addr["mainchain_address"], self.nodes[0].getpeginaddress()["mainchain_address"])
assert_equal(self.nodes[0].tweakfedpegscript(pegin_addr["claim_script"])["script"], OP_TRUE_SCRIPT)

# Test that OP_CMS has all keys change and matches elements-0.14 example
self.generate(self.nodes[1], 1, sync_fun=self.no_op)
pegin_addr = self.nodes[1].getpeginaddress()
assert_equal(self.nodes[1].getsidechaininfo()["fedpegscript"], OP_CMS_SCRIPT)
nontweak_decoded = self.nodes[1].decodescript(OP_CMS_SCRIPT)["asm"]
Expand All @@ -61,6 +77,7 @@ def run_test(self):
"522102f5bc6bc407187d06854005c366b84b411534757f4503587cf335645a620f896a2102fd90164e4e7d53417e4eacfa3f86fd39fe40594791758739e8af31eeea4e79c552ae")

# Test Liquid-style fedpegscript with CSV emergency keys(which don't get tweaked!)
self.generate(self.nodes[2], 1, sync_fun=self.no_op)
pegin_addr = self.nodes[2].getpeginaddress()
assert_equal(self.nodes[2].getsidechaininfo()["fedpegscript"], LIQUID_SCRIPT)
nontweak_decoded = self.nodes[2].decodescript(LIQUID_SCRIPT)["asm"]
Expand All @@ -86,7 +103,7 @@ def run_test(self):
# Advance to dynamic federations activation, which has pubkeys
# after OP_ELSE get tweaked except the exact liquidv1 template to
# maintain compatibility
self.generate(self.nodes[2], 433, sync_fun=self.no_op)
self.generate(self.nodes[2], 432, sync_fun=self.no_op)
assert_equal(self.nodes[2].getdeploymentinfo()['deployments']['dynafed']['bip9']['status'], 'active')
assert_equal(self.nodes[2].tweakfedpegscript(claim_script)["script"], liquid_tweaked)

Expand Down
1 change: 1 addition & 0 deletions test/functional/wallet_elements_regression_1263.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def run_test(self):
self.log.info("Start in Bitcoin regtest mode")
self.nodes[0].createwallet("pegin")
rpc = self.nodes[0].get_wallet_rpc("pegin")
self.generatetoaddress(self.nodes[0], 1, rpc.getnewaddress())

self.log.info("Call getpeginaddress")
assert_raises_rpc_error(-32603, "No valid fedpegscripts. Not running in Elements mode, check your 'chain' param.", rpc.getpeginaddress)
Expand Down

0 comments on commit af52976

Please sign in to comment.