Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pytest: make GenChannel arguments explicit.
Browse files Browse the repository at this point in the history
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
rustyrussell committed Aug 1, 2024
1 parent bd6a4a8 commit b0075af
Showing 2 changed files with 22 additions and 15 deletions.
21 changes: 10 additions & 11 deletions tests/test_gossip.py
Original file line number Diff line number Diff line change
@@ -2144,18 +2144,17 @@ def test_generate_gossip_store(node_factory):
l1 = node_factory.get_node(start=False)
chans = [GenChannel(0, 1),
GenChannel(0, 2, capacity_sats=5000),
GenChannel(0, 3),
GenChannel(0, 3,
forward=GenChannel.Half(enabled=False,
htlc_min=10,
htlc_max=5000000 - 10,
basefee=10,
propfee=10),
reverse=GenChannel.Half(htlc_min=11,
htlc_max=5000000 - 11,
basefee=11,
propfee=11)),
GenChannel(0, 4)]
chans[2].half[0] = GenChannel.Half(enabled=False,
htlc_min=10,
htlc_max=5000000 - 10,
basefee=10,
propfee=10)

chans[2].half[1] = GenChannel.Half(htlc_min=11,
htlc_max=5000000 - 11,
basefee=11,
propfee=11)
gsfile, nodemap = generate_gossip_store(chans)

# Set up l1 with this as the gossip_store
16 changes: 12 additions & 4 deletions tests/utils.py
Original file line number Diff line number Diff line change
@@ -436,20 +436,28 @@ def scriptpubkey_addr(scriptpubkey):

class GenChannel(object):
class Half(object):
def __init__(self, htlc_max, enabled=True, htlc_min=0, basefee=0, propfee=1, delay=6):
def __init__(self, enabled=True, htlc_min=0, htlc_max=None, basefee=0, propfee=1, delay=6):
self.enabled = enabled
self.htlc_min = htlc_min
self.htlc_max = htlc_max
self.basefee = basefee
self.propfee = propfee
self.delay = delay

def __init__(self, node1, node2, capacity_sats=1000000):
def __init__(self, node1, node2, capacity_sats=1000000, forward=None, reverse=None):
"""We fill in htlc_max on half to == capacity, if not set"""
self.node1 = node1
self.node2 = node2
if forward is None:
forward = GenChannel.Half()
if reverse is None:
reverse = GenChannel.Half()
if forward.htlc_max is None:
forward.htlc_max = capacity_sats * 1000
if reverse.htlc_max is None:
reverse.htlc_max = capacity_sats * 1000
self.capacity_sats = capacity_sats
self.half = [GenChannel.Half(htlc_max=capacity_sats * 1000),
GenChannel.Half(htlc_max=capacity_sats * 1000)]
self.half = [forward, reverse]


def generate_gossip_store(channels):

0 comments on commit b0075af

Please sign in to comment.