regtest: pass config options from regtest.py to script
This commit is contained in:
@@ -19,12 +19,12 @@ class TestLightning(unittest.TestCase):
|
||||
test_name = self.id().split('.')[-1]
|
||||
sys.stdout.write("***** %s ******\n" % test_name)
|
||||
# initialize and get funds
|
||||
for agent in self.agents:
|
||||
for agent, config_options in self.agents.items():
|
||||
self.run_shell(['init', agent])
|
||||
for k, v in config_options.items():
|
||||
self.run_shell(['setconfig', agent, k, v])
|
||||
# mine a block so that funds are confirmed
|
||||
self.run_shell(['new_block'])
|
||||
# extra configuration (optional)
|
||||
self.run_shell(['configure_' + test_name])
|
||||
# start daemons
|
||||
for agent in self.agents:
|
||||
self.run_shell(['start', agent])
|
||||
@@ -35,24 +35,24 @@ class TestLightning(unittest.TestCase):
|
||||
|
||||
|
||||
class TestUnixSockets(TestLightning):
|
||||
agents = []
|
||||
agents = {}
|
||||
|
||||
def test_unixsockets(self):
|
||||
self.run_shell(['unixsockets'])
|
||||
|
||||
|
||||
class TestLightningAB(TestLightning):
|
||||
agents = ['alice', 'bob']
|
||||
agents = {
|
||||
'alice': {
|
||||
},
|
||||
'bob': {
|
||||
'lightning_listen': 'localhost:9735',
|
||||
}
|
||||
}
|
||||
|
||||
def test_collaborative_close(self):
|
||||
self.run_shell(['collaborative_close'])
|
||||
|
||||
def test_swapserver_success(self):
|
||||
self.run_shell(['swapserver_success'])
|
||||
|
||||
def test_swapserver_refund(self):
|
||||
self.run_shell(['swapserver_refund'])
|
||||
|
||||
def test_backup(self):
|
||||
self.run_shell(['backup'])
|
||||
|
||||
@@ -75,8 +75,39 @@ class TestLightningAB(TestLightning):
|
||||
self.run_shell(['breach_with_spent_htlc'])
|
||||
|
||||
|
||||
class TestLightningABC(TestLightning):
|
||||
agents = ['alice', 'bob', 'carol']
|
||||
class TestLightningSwapserver(TestLightning):
|
||||
agents = {
|
||||
'alice': {
|
||||
},
|
||||
'bob': {
|
||||
'lightning_listen': 'localhost:9735',
|
||||
'use_swapserver': 'true',
|
||||
}
|
||||
}
|
||||
|
||||
def test_swapserver_success(self):
|
||||
self.run_shell(['swapserver_success'])
|
||||
|
||||
def test_swapserver_refund(self):
|
||||
self.run_shell(['swapserver_refund'])
|
||||
|
||||
|
||||
|
||||
class TestLightningWatchtower(TestLightning):
|
||||
agents = {
|
||||
'alice':{
|
||||
},
|
||||
'bob':{
|
||||
'lightning_listen': 'localhost:9735',
|
||||
'watchtower_url': 'http://wtuser:wtpassword@127.0.0.1:12345',
|
||||
},
|
||||
'carol':{
|
||||
'run_watchtower': 'true',
|
||||
'watchtower_user': 'wtuser',
|
||||
'watchtower_password': 'wtpassword',
|
||||
'watchtower_port': '12345',
|
||||
}
|
||||
}
|
||||
|
||||
def test_watchtower(self):
|
||||
self.run_shell(['watchtower'])
|
||||
|
||||
@@ -94,16 +94,16 @@ if [[ $1 == "init" ]]; then
|
||||
$agent setconfig --offline server 127.0.0.1:51001:t
|
||||
$agent setconfig --offline lightning_to_self_delay 144
|
||||
$agent setconfig --offline test_force_disable_mpp True
|
||||
# alice is funded, bob is listening
|
||||
if [[ $2 == "bob" ]]; then
|
||||
$bob setconfig --offline lightning_listen localhost:9735
|
||||
$bob setconfig --offline use_swapserver true
|
||||
fi
|
||||
echo "funding $2"
|
||||
# note: changing the funding amount affects all tests, as they rely on "wait_for_balance"
|
||||
$bitcoin_cli sendtoaddress $($agent getunusedaddress -o) 1
|
||||
fi
|
||||
|
||||
if [[ $1 == "setconfig" ]]; then
|
||||
# use this to set config vars that need to be set before the daemon is started
|
||||
agent="./run_electrum --regtest -D /tmp/$2"
|
||||
$agent setconfig --offline $3 $4
|
||||
fi
|
||||
|
||||
# start daemons. Bob is started first because he is listening
|
||||
if [[ $1 == "start" ]]; then
|
||||
@@ -408,16 +408,6 @@ if [[ $1 == "breach_with_spent_htlc" ]]; then
|
||||
$bob getbalance
|
||||
fi
|
||||
|
||||
|
||||
if [[ $1 == "configure_test_watchtower" ]]; then
|
||||
# carol is the watchtower of bob
|
||||
$carol setconfig -o run_watchtower true
|
||||
$carol setconfig -o watchtower_user wtuser
|
||||
$carol setconfig -o watchtower_password wtpassword
|
||||
$carol setconfig -o watchtower_port 12345
|
||||
$bob setconfig -o watchtower_url http://wtuser:wtpassword@127.0.0.1:12345
|
||||
fi
|
||||
|
||||
if [[ $1 == "watchtower" ]]; then
|
||||
wait_for_balance alice 1
|
||||
echo "alice opens channel"
|
||||
|
||||
Reference in New Issue
Block a user