Files
purple-electrumwallet/electrum/tests/regtest.py
T

74 lines
2.0 KiB
Python
Raw Normal View History

2019-03-11 21:00:29 +01:00
import os
import sys
import unittest
import subprocess
class TestLightning(unittest.TestCase):
@staticmethod
def run_shell(args, timeout=30):
2021-09-13 16:20:54 +00:00
process = subprocess.Popen(['electrum/tests/regtest/regtest.sh'] + args, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, universal_newlines=True)
for line in iter(process.stdout.readline, ''):
sys.stdout.write(line)
sys.stdout.flush()
2019-03-11 21:00:29 +01:00
process.wait(timeout=timeout)
process.stdout.close()
assert process.returncode == 0
def setUp(self):
2020-02-02 14:50:08 +01:00
test_name = self.id().split('.')[-1]
sys.stdout.write("***** %s ******\n" % test_name)
# initialize and get funds
for agent in self.agents:
self.run_shell(['init', agent])
# 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])
2019-03-11 21:00:29 +01:00
def tearDown(self):
2020-02-02 14:50:08 +01:00
for agent in self.agents:
self.run_shell(['stop', agent])
2019-03-11 21:00:29 +01:00
2020-02-03 15:15:29 +01:00
class TestUnixSockets(TestLightning):
agents = []
def test_unixsockets(self):
self.run_shell(['unixsockets'])
2020-02-03 15:15:29 +01:00
class TestLightningAB(TestLightning):
agents = ['alice', 'bob']
2021-11-26 09:45:06 +01:00
def test_collaborative_close(self):
self.run_shell(['collaborative_close'])
2021-03-12 16:10:02 +01:00
def test_backup(self):
self.run_shell(['backup'])
2019-03-11 21:00:29 +01:00
def test_breach(self):
self.run_shell(['breach'])
def test_extract_preimage(self):
self.run_shell(['extract_preimage'])
2019-03-11 21:00:29 +01:00
def test_redeem_htlcs(self):
self.run_shell(['redeem_htlcs'])
2019-05-29 17:34:12 +02:00
2019-06-24 11:13:18 +02:00
def test_breach_with_unspent_htlc(self):
self.run_shell(['breach_with_unspent_htlc'])
def test_breach_with_spent_htlc(self):
self.run_shell(['breach_with_spent_htlc'])
2019-07-05 14:42:09 +02:00
2020-02-03 15:15:29 +01:00
class TestLightningABC(TestLightning):
agents = ['alice', 'bob', 'carol']
2019-07-05 14:42:09 +02:00
def test_watchtower(self):
self.run_shell(['watchtower'])