mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
2wp: QA: Introduce second bitcoin to test -mainchainrpccookiefile
This commit is contained in:
parent
74ca34896b
commit
6a174d4504
1 changed files with 36 additions and 10 deletions
|
|
@ -50,28 +50,44 @@ sidechain_datadir = get_temp_dir('sidechain')
|
|||
sidechain_pass = get_pseudorandom_str()
|
||||
sidechain2_datadir = get_temp_dir('sidechain2')
|
||||
sidechain2_pass = get_pseudorandom_str()
|
||||
bitcoin2_datadir = get_temp_dir('bitcoin2')
|
||||
bitcoin2_rpccookiefile = bitcoin2_datadir + '/regtest/.cookie'
|
||||
|
||||
bitcoin_port = 8000 + os.getpid()%999
|
||||
sidechain_port = bitcoin_port + 1
|
||||
sidechain2_port = bitcoin_port + 2
|
||||
sidechain1_p2p_port = bitcoin_port + 3
|
||||
sidechain2_p2p_port = bitcoin_port + 4
|
||||
bitcoin2_port = bitcoin_port + 5
|
||||
bitcoin2_p2p_port = bitcoin_port + 6
|
||||
bitcoin_p2p_port = bitcoin_port + 7
|
||||
|
||||
os.makedirs(bitcoin_datadir)
|
||||
os.makedirs(sidechain_datadir)
|
||||
os.makedirs(sidechain2_datadir)
|
||||
os.makedirs(bitcoin2_datadir)
|
||||
|
||||
with open(os.path.join(bitcoin_datadir, "bitcoin.conf"), 'w') as f:
|
||||
def write_bitcoin_conf(datadir, rpcport, rpcpass=None, p2p_port=None, connect_port=None):
|
||||
with open(os.path.join(datadir, "bitcoin.conf"), 'w') as f:
|
||||
f.write("regtest=1\n")
|
||||
f.write("rpcuser=bitcoinrpc\n")
|
||||
f.write("rpcpassword="+bitcoin_pass+"\n")
|
||||
f.write("rpcport="+str(bitcoin_port)+"\n")
|
||||
if p2p_port:
|
||||
f.write("port="+str(p2p_port)+"\n")
|
||||
if rpcpass:
|
||||
f.write("rpcuser=bitcoinrpc\n")
|
||||
f.write("rpcpassword="+rpcpass+"\n")
|
||||
f.write("rpcport="+str(rpcport)+"\n")
|
||||
f.write("discover=0\n")
|
||||
f.write("listen=0\n")
|
||||
f.write("testnet=0\n")
|
||||
f.write("txindex=1\n")
|
||||
f.write("daemon=1\n")
|
||||
f.write("listen=0\n")
|
||||
if connect_port:
|
||||
f.write("connect=localhost:"+str(connect_port)+"\n")
|
||||
f.write("listen=1\n")
|
||||
else:
|
||||
f.write("listen=0\n")
|
||||
|
||||
write_bitcoin_conf(bitcoin_datadir, bitcoin_port, bitcoin_pass, p2p_port=bitcoin_p2p_port, connect_port=bitcoin2_p2p_port)
|
||||
write_bitcoin_conf(bitcoin2_datadir, bitcoin2_port, rpcpass=None, p2p_port=bitcoin2_p2p_port, connect_port=bitcoin_p2p_port)
|
||||
|
||||
with open(os.path.join(sidechain_datadir, "elements.conf"), 'w') as f:
|
||||
f.write("regtest=1\n")
|
||||
|
|
@ -104,9 +120,8 @@ with open(os.path.join(sidechain2_datadir, "elements.conf"), 'w') as f:
|
|||
f.write("fedpegscript="+fedpeg_pubkey+"\n")
|
||||
f.write("daemon=1\n")
|
||||
f.write("mainchainrpchost=127.0.0.1\n")
|
||||
f.write("mainchainrpcport="+str(bitcoin_port)+"\n")
|
||||
f.write("mainchainrpcuser=bitcoinrpc\n")
|
||||
f.write("mainchainrpcpassword="+bitcoin_pass+"\n")
|
||||
f.write("mainchainrpcport="+str(bitcoin2_port)+"\n")
|
||||
f.write("mainchainrpccookiefile=%s\n" % bitcoin2_rpccookiefile)
|
||||
f.write("validatepegin=1\n")
|
||||
f.write("validatepegout=0\n")
|
||||
f.write("port="+str(sidechain2_p2p_port)+"\n")
|
||||
|
|
@ -120,10 +135,13 @@ try:
|
|||
sidechain_args = " -peginconfirmationdepth=10 "
|
||||
|
||||
# Start daemons
|
||||
print("Starting daemons at "+bitcoin_datadir+", "+sidechain_datadir+" and "+sidechain2_datadir)
|
||||
print("Starting daemons at "+bitcoin_datadir+", "+bitcoin2_datadir+", "+sidechain_datadir+" and "+sidechain2_datadir)
|
||||
bitcoindstart = bitcoin_bin_path+"/bitcoind -datadir="+bitcoin_datadir
|
||||
subprocess.Popen(bitcoindstart.split(), stdout=subprocess.PIPE)
|
||||
|
||||
bitcoind2start = bitcoin_bin_path+"/bitcoind -datadir="+bitcoin2_datadir
|
||||
subprocess.Popen(bitcoind2start.split(), stdout=subprocess.PIPE)
|
||||
|
||||
sidechainstart = sidechain_bin_path+"/elementsd -datadir="+sidechain_datadir + sidechain_args
|
||||
subprocess.Popen(sidechainstart.split(), stdout=subprocess.PIPE)
|
||||
|
||||
|
|
@ -133,7 +151,11 @@ try:
|
|||
print("Daemons started")
|
||||
time.sleep(3)
|
||||
|
||||
with open(bitcoin2_rpccookiefile, 'r') as f:
|
||||
bitcoin2_rpccookie = f.readline()
|
||||
|
||||
bitcoin = AuthServiceProxy("http://bitcoinrpc:"+bitcoin_pass+"@127.0.0.1:"+str(bitcoin_port))
|
||||
bitcoin2 = AuthServiceProxy("http://"+ bitcoin2_rpccookie +"@127.0.0.1:"+str(bitcoin2_port))
|
||||
sidechain = AuthServiceProxy("http://sidechainrpc:"+sidechain_pass+"@127.0.0.1:"+str(sidechain_port))
|
||||
sidechain2 = AuthServiceProxy("http://sidechainrpc2:"+sidechain2_pass+"@127.0.0.1:"+str(sidechain2_port))
|
||||
print("Daemons started, making blocks to get funds")
|
||||
|
|
@ -173,6 +195,7 @@ try:
|
|||
pegtxid1 = sidechain.claimpegin(raw, proof)
|
||||
|
||||
# Will invalidate the block that confirms this transaction later
|
||||
sync_all(bitcoin, bitcoin2)
|
||||
blockhash = sync_all(sidechain, sidechain2)
|
||||
sidechain.generate(5)
|
||||
|
||||
|
|
@ -215,6 +238,7 @@ try:
|
|||
raw = bitcoin.getrawtransaction(txid)
|
||||
pegtxs += [sidechain.claimpegin(raw, proof)]
|
||||
|
||||
sync_all(bitcoin, bitcoin2)
|
||||
sync_all(sidechain, sidechain2)
|
||||
|
||||
sidechain2.generate(1)
|
||||
|
|
@ -234,11 +258,13 @@ except Exception as e:
|
|||
|
||||
print("Stopping daemons and cleaning up")
|
||||
bitcoin.stop()
|
||||
bitcoin2.stop()
|
||||
sidechain.stop()
|
||||
sidechain2.stop()
|
||||
|
||||
time.sleep(5)
|
||||
|
||||
shutil.rmtree(bitcoin2_datadir)
|
||||
shutil.rmtree(sidechain2_datadir)
|
||||
shutil.rmtree(sidechain_datadir)
|
||||
shutil.rmtree(bitcoin_datadir)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue