Skip to content

Commit 0229f90

Browse files
committed
pytest: Implement the first splice test
Changelog-None
1 parent 876c1cb commit 0229f90

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

contrib/pyln-client/pyln/client/lightning.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,36 @@ def openchannel_abort(self, channel_id):
11251125
}
11261126
return self.call("openchannel_abort", payload)
11271127

1128+
def splice_init(self, peer_id):
1129+
""" Initiate a splice """
1130+
payload = {
1131+
"id": peer_id
1132+
}
1133+
return self.call("splice_init", payload)
1134+
1135+
def splice_update(self, peer_id, psbt):
1136+
""" Update a splice """
1137+
payload = {
1138+
"id": peer_id,
1139+
"psbt": psbt
1140+
}
1141+
return self.call("splice_update", payload)
1142+
1143+
def splice_finalize(self, peer_id):
1144+
""" Finalize a splice """
1145+
payload = {
1146+
"id": peer_id
1147+
}
1148+
return self.call("splice_finalize", payload)
1149+
1150+
def splice_signed(self, peer_id, psbt):
1151+
""" Initiate a splice """
1152+
payload = {
1153+
"id": peer_id,
1154+
"psbt": psbt
1155+
}
1156+
return self.call("splice_signed", payload)
1157+
11281158
def paystatus(self, bolt11=None):
11291159
"""Detail status of attempts to pay {bolt11} or any."""
11301160
payload = {

tests/test_splicing.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
from fixtures import * # noqa: F401,F403
2+
from fixtures import TEST_NETWORK
3+
from pyln.client import RpcError, Millisatoshi
4+
from utils import (
5+
only_one, wait_for, sync_blockheight, first_channel_id, calc_lease_fee
6+
)
7+
8+
import pytest
9+
import re
10+
import unittest
11+
import time
12+
13+
@pytest.mark.openchannel('v2')
14+
def test_splice(node_factory, bitcoind):
15+
l1 = node_factory.get_node()
16+
l2 = node_factory.get_node()
17+
18+
l1.rpc.connect(l2.rpc.getinfo()['id'], 'localhost:%d' % l2.port)
19+
l1.openchannel(l2, 4000000)
20+
21+
result = l1.rpc.splice_init(l2.rpc.getinfo()['id'])
22+
23+
funds_result = l1.rpc.fundpsbt("100000sat", "slow", 166)
24+
25+
result = bitcoind.rpc.joinpsbts([result['psbt'], funds_result['psbt']])
26+
result = l1.rpc.splice_update(l2.rpc.getinfo()['id'], result)
27+
result = l1.rpc.splice_finalize(l2.rpc.getinfo()['id'])
28+
result = l1.rpc.signpsbt(result['psbt'])
29+
result = l1.rpc.splice_signed(l2.rpc.getinfo()['id'], result['signed_psbt'])
30+
31+
inv = l2.rpc.invoice(10**2, '1', 'no_1')
32+
l1.rpc.pay(inv['bolt11'])
33+
34+
bitcoind.generate_block(6, wait_for_mempool=1)
35+
36+
inv = l2.rpc.invoice(10**2, '2', 'no_2')
37+
l1.rpc.pay(inv['bolt11'])
38+
39+
l2.daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_NORMAL')
40+
l1.daemon.wait_for_log(r'CHANNELD_AWAITING_SPLICE to CHANNELD_NORMAL')
41+
42+
inv = l2.rpc.invoice(10**2, '3', 'no_3')
43+
l1.rpc.pay(inv['bolt11'])
44+
45+
result = True

0 commit comments

Comments
 (0)