Skip to content

Commit

Permalink
WIP feature_fedpeg with bitcoind
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenroose committed Sep 24, 2018
1 parent 1920d84 commit 66b0299
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 10 deletions.
50 changes: 41 additions & 9 deletions qa/rpc-tests/feature_fedpeg.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python3

from decimal import Decimal
import os
import json
import time

Expand All @@ -10,6 +11,7 @@
connect_nodes_bi,
rpc_auth_pair,
rpc_port,
p2p_port,
start_node,
start_nodes,
stop_node,
Expand Down Expand Up @@ -47,21 +49,51 @@ def __init__(self):
self.setup_clean_chain = True
self.num_nodes = 4

def add_options(self, parser):
parser.add_option("--parent_binpath", dest="parent_binpath", default="",
help="Use a different binary for launching nodes")
parser.add_option("--parent_bitcoin", dest="parent_bitcoin", default=False, action="store_true",
help="Parent nodes are Bitcoin")

def setup_network(self, split=False):

# Parent chain args
self.extra_args = [[
# '-printtoconsole',
'-validatepegin=0',
'-anyonecanspendaremine',
'-initialfreecoins=2100000000000000',
]] * 2

self.nodes = start_nodes(2, self.options.tmpdir, self.extra_args[:2], chain='parent')
chain = None
if self.options.parent_bitcoin:
if self.options.parent_binpath == "":
raise "Can't run with --parent_bitcoin without specifying --parent_binpath"
chain = "regtest"
self.extra_args = [[
"-regtest=1",
"-port="+str(p2p_port(n)),
"-rpcuser="+rpc_auth_pair(n)[0],
"-rpcpassword="+rpc_auth_pair(n)[1],
"-rpcport="+str(rpc_port(n)),
"-testnet=0",
"-txindex=1",
"-addresstype=legacy", # To make sure bitcoind gives back p2pkh no matter version
"-connect=localhost:"+str(p2p_port((n+1)%2)),
"-listen=1",
#"-debug"
] for n in range(2)]
else:
chain = "parent"
self.extra_args = [[
# '-printtoconsole',
'-validatepegin=0',
'-anyonecanspendaremine',
'-initialfreecoins=2100000000000000',
]] * 2
parent_pegged_asset = self.nodes[0].getsidechaininfo()['pegged_asset']

binary = None
if self.options.parent_binpath != "":
binary = self.options.parent_binpath
self.nodes = start_nodes(2, self.options.tmpdir, self.extra_args[:2], binary=binary, chain=chain)
connect_nodes_bi(self.nodes, 0, 1)
self.parentgenesisblockhash = self.nodes[0].getblockhash(0)
print('parentgenesisblockhash', self.parentgenesisblockhash)
parent_pegged_asset = self.nodes[0].getsidechaininfo()['pegged_asset']
#parent_pegged_asset = self.nodes[0].getsidechaininfo()['pegged_asset']

# Sidechain args
parent_chain_signblockscript = '51'
Expand Down
4 changes: 3 additions & 1 deletion qa/rpc-tests/test_framework/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,9 @@ def start_node(i, dirname, extra_args=None, rpchost=None, timewait=None, binary=
datadir = os.path.join(dirname, "node"+str(i))
if binary is None:
binary = os.getenv("ELEMENTSD", "elementsd")
args = [ binary, '-chain='+chain, "-datadir="+datadir, "-server", "-keypool=1", "-discover=0", "-rest", "-mocktime="+str(get_mocktime()) ]
args = [ binary, "-datadir="+datadir, "-server", "-keypool=1", "-discover=0", "-rest", "-mocktime="+str(get_mocktime()) ]
if chain != "regtest": #TODO(stevenroose) remove if unnecessary or when bitcoind has -chain
args.append("-chain="+chain)
if extra_args is not None: args.extend(extra_args)
bitcoind_processes[i] = subprocess.Popen(args)
if os.getenv("PYTHON_DEBUG", ""):
Expand Down

0 comments on commit 66b0299

Please sign in to comment.