Skip to content

Commit

Permalink
pytest: tests fee_base and fee_ppm on listpeers
Browse files Browse the repository at this point in the history
  • Loading branch information
m-schmoock authored and cdecker committed Dec 7, 2020
1 parent c4b7f4d commit ce1a2f1
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/test_pay.py
Original file line number Diff line number Diff line change
Expand Up @@ -1832,7 +1832,9 @@ def test_setchannelfee_usage(node_factory, bitcoind):
# - check values in local nodes listchannels output
# - json throws exception on negative values
# - checks if peer id can be used instead of scid
# - checks fee_base_msat and fee_proportional_millionths in `listpeers` out
DEF_BASE = 10
DEF_BASE_MSAT = Millisatoshi(DEF_BASE)
DEF_PPM = 100

l1, l2, l3 = node_factory.get_nodes(3,
Expand All @@ -1852,6 +1854,10 @@ def channel_get_fees(scid):
db_fees = l1.db_query('SELECT feerate_base, feerate_ppm FROM channels;')
assert(db_fees[0]['feerate_base'] == DEF_BASE)
assert(db_fees[0]['feerate_ppm'] == DEF_PPM)
# this is also what listpeers should return
peers = l1.rpc.listpeers()['peers']
assert peers[0]['channels'][0]['fee_base_msat'] == DEF_BASE_MSAT
assert peers[0]['channels'][0]['fee_proportional_millionths'] == DEF_PPM

# custom setchannelfee scid <base> <ppm>
result = l1.rpc.setchannelfee(scid, 1337, 137)
Expand All @@ -1868,6 +1874,10 @@ def channel_get_fees(scid):
db_fees = channel_get_fees(scid)
assert(db_fees[0]['feerate_base'] == 1337)
assert(db_fees[0]['feerate_ppm'] == 137)
# also check for updated values in `listpeers`
peers = l1.rpc.listpeers()['peers']
assert peers[0]['channels'][0]['fee_base_msat'] == Millisatoshi(1337)
assert peers[0]['channels'][0]['fee_proportional_millionths'] == 137

# wait for gossip and check if l1 sees new fees in listchannels
wait_for(lambda: [c['base_fee_millisatoshi'] for c in l1.rpc.listchannels(scid)['channels']] == [DEF_BASE, 1337])
Expand Down Expand Up @@ -1899,6 +1909,10 @@ def channel_get_fees(scid):
db_fees = channel_get_fees(scid)
assert(db_fees[0]['feerate_base'] == 0)
assert(db_fees[0]['feerate_ppm'] == 0)
# also check for updated values in `listpeers`
peers = l1.rpc.listpeers()['peers']
assert peers[0]['channels'][0]['fee_base_msat'] == Millisatoshi(0)
assert peers[0]['channels'][0]['fee_proportional_millionths'] == 0

# disable and check for global values to be returned
result = l1.rpc.setchannelfee(scid)
Expand All @@ -1908,6 +1922,10 @@ def channel_get_fees(scid):
db_fees = channel_get_fees(scid)
assert(db_fees[0]['feerate_base'] == DEF_BASE)
assert(db_fees[0]['feerate_ppm'] == DEF_PPM)
# also check for updated values in `listpeers`
peers = l1.rpc.listpeers()['peers']
assert peers[0]['channels'][0]['fee_base_msat'] == DEF_BASE_MSAT
assert peers[0]['channels'][0]['fee_proportional_millionths'] == DEF_PPM

# check also peer id can be used
result = l1.rpc.setchannelfee(l2.info['id'], 42, 43)
Expand Down

0 comments on commit ce1a2f1

Please sign in to comment.