Skip to content

Commit

Permalink
pytest: test for setchannel's new ignorefeelimits.
Browse files Browse the repository at this point in the history
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed Jul 18, 2023
1 parent b07abc2 commit 5462a4b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
5 changes: 4 additions & 1 deletion contrib/pyln-client/pyln/client/lightning.py
Expand Up @@ -1321,7 +1321,7 @@ def sendonion(
}
return self.call("sendonion", payload)

def setchannel(self, id, feebase=None, feeppm=None, htlcmin=None, htlcmax=None, enforcedelay=None):
def setchannel(self, id, feebase=None, feeppm=None, htlcmin=None, htlcmax=None, enforcedelay=None, ignorefeelimits=None):
"""Set configuration a channel/peer {id} (or 'all').
{feebase} is a value in millisatoshi that is added as base fee
Expand All @@ -1339,6 +1339,8 @@ def setchannel(self, id, feebase=None, feeppm=None, htlcmin=None, htlcmax=None,
{enforcedelay} is the number of seconds before enforcing this
change.
{ignorefeelimits} is a flag to indicate peer can set any feerate (dangerous!)
"""
payload = {
"id": id,
Expand All @@ -1347,6 +1349,7 @@ def setchannel(self, id, feebase=None, feeppm=None, htlcmin=None, htlcmax=None,
"htlcmin": htlcmin,
"htlcmax": htlcmax,
"enforcedelay": enforcedelay,
"ignorefeelimits": ignorefeelimits,
}
return self.call("setchannel", payload)

Expand Down
12 changes: 9 additions & 3 deletions tests/test_connection.py
Expand Up @@ -2500,6 +2500,8 @@ def test_fee_limits(node_factory, bitcoind):

# Kick off fee adjustment using HTLC.
l1.pay(l2, 1000)
assert 'ignore_fee_limits' not in only_one(l2.rpc.listpeerchannels()['channels'])
assert 'ignore_fee_limits' not in only_one(l1.rpc.listpeerchannels()['channels'])

# L1 asks for stupid low fee (will actually hit the floor of 253)
l1.stop()
Expand All @@ -2512,10 +2514,14 @@ def test_fee_limits(node_factory, bitcoind):
assert 'update_fee 253 outside range 1875-75000' in only_one(l1.rpc.listpeerchannels(l2.info['id'])['channels'])['status'][0]
assert 'update_fee 253 outside range 1875-75000' in only_one(l2.rpc.listpeerchannels(l1.info['id'])['channels'])['status'][0]

assert only_one(l2.rpc.listpeerchannels()['channels'])['feerate']['perkw'] != 253
# Make l2 accept those fees, and it should recover.
l2.stop()
l2.set_feerates((15, 15, 15, 15), False)
l2.start()
assert only_one(l2.rpc.setchannel(l1.get_channel_scid(l2), ignorefeelimits=True)['channels'])['ignore_fee_limits'] is True
assert only_one(l2.rpc.listpeerchannels()['channels'])['ignore_fee_limits'] is True

# Now we stay happy (and connected!)
wait_for(lambda: only_one(l2.rpc.listpeerchannels()['channels'])['feerate']['perkw'] == 253)
assert only_one(l2.rpc.listpeerchannels()['channels'])['peer_connected'] is True

l1.rpc.close(l2.info['id'])

Expand Down
1 change: 1 addition & 0 deletions tests/test_pay.py
Expand Up @@ -1994,6 +1994,7 @@ def channel_get_config(scid):
assert(result['channels'][0]['fee_proportional_millionths'] == 137)
assert(result['channels'][0]['minimum_htlc_out_msat'] == 17)
assert(result['channels'][0]['maximum_htlc_out_msat'] == 133337)
assert(result['channels'][0]['ignore_fee_limits'] is False)

# check if custom values made it into the database
db_fees = channel_get_config(scid)
Expand Down

0 comments on commit 5462a4b

Please sign in to comment.