Skip to content

Commit

Permalink
tests/test_misc: added tests for the RPC
Browse files Browse the repository at this point in the history
  • Loading branch information
adi2011 committed Jun 17, 2022
1 parent 2f8fadb commit 5d2897e
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2235,6 +2235,67 @@ def test_getsharedsecret(node_factory):
== l2.rpc.getsharedsecret(l1.info["id"])["shared_secret"])


@pytest.mark.developer("needs --dev-force-privkey")
def test_makesecret(node_factory):
"""
Test makesecret command.
"""

l1 = node_factory.get_node(options={"dev-force-privkey": "1212121212121212121212121212121212121212121212121212121212121212"})
secret = l1.rpc.makesecret("The Economic times 15/june/2022 WPI inflation hits 15.88%")["secret"]

assert (secret == "2db2826c47249b9b484d1278aa6aee48c64c45e73d7fd0f4af1f159f72981816")


def test_staticbackup(node_factory):
"""
Test staticbackup
"""
l1, l2 = node_factory.get_nodes(2, opts=[{}, {}])
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
c12, _ = l1.fundchannel(l2, 10**5)

# Comparing the channelID, scb_chan has the channel ID starting from the 8th byte
# and it's own length is 32 byte, hence 16 + 64.
assert (len(l1.rpc.staticbackup()["scb"]) == 1
and l1.rpc.staticbackup()["scb"][0][16: 16 + 64] == _["channel_id"])


def test_recoverchannel(node_factory):
"""
Test recoverchannel
"""
l1 = node_factory.get_node(options={})
stubs = l1.rpc.recoverchannel(["0000000000000001c3a7b9d74a174497122bc52d74d6d69836acadc77e0429c6d8b68b48d5c9139a022d223620a359a47ff7f7ac447c85c46c923da53389221a0054c11c1e3ca31d5904017f0000019f0bc3a7b9d74a174497122bc52d74d6d69836acadc77e0429c6d8b68b48d5c9139a0000000000000000000186a000021000"])["stubs"]

assert (len(stubs) == 1
and stubs[0] == "c3a7b9d74a174497122bc52d74d6d69836acadc77e0429c6d8b68b48d5c9139a")


def test_emergencybackup(node_factory, bitcoind):
"""
Test emergencybackup
"""
l1, l2 = node_factory.get_nodes(2, opts=[{}, {}])
l1.rpc.connect(l2.info['id'], 'localhost', l2.port)
c12, _ = l1.fundchannel(l2, 10**5)

l1.stop()
l2.stop()

os.unlink(os.path.join(l1.daemon.lightning_dir, TEST_NETWORK, "lightningd.sqlite3"))

l2.start()
l1.start()

stubs = l1.rpc.emergencyrecover()["stubs"]

mine_funding_to_announce(bitcoind, [l1, l2])

assert (len(stubs) == 1
and stubs[0] == _["channel_id"])


def test_commitfee_option(node_factory):
"""Sanity check for the --commit-fee startup option."""
l1, l2 = node_factory.get_nodes(2, opts=[{"commit-fee": "200"}, {}])
Expand Down

0 comments on commit 5d2897e

Please sign in to comment.