(node_factory)
| 2257 | |
| 2258 | |
| 2259 | def test_generate_gossip_store(node_factory): |
| 2260 | l1 = node_factory.get_node(start=False) |
| 2261 | chans = [GenChannel(0, 1), |
| 2262 | GenChannel(0, 2, capacity_sats=5000), |
| 2263 | GenChannel(0, 3, |
| 2264 | forward=GenChannel.Half(enabled=False, |
| 2265 | htlc_min=10, |
| 2266 | htlc_max=5000000 - 10, |
| 2267 | basefee=10, |
| 2268 | propfee=10), |
| 2269 | reverse=GenChannel.Half(htlc_min=11, |
| 2270 | htlc_max=5000000 - 11, |
| 2271 | basefee=11, |
| 2272 | propfee=11)), |
| 2273 | GenChannel(0, 4)] |
| 2274 | gsfile, nodemap = generate_gossip_store(chans) |
| 2275 | |
| 2276 | # Set up l1 with this as the gossip_store |
| 2277 | shutil.copy(gsfile.name, os.path.join(l1.daemon.lightning_dir, TEST_NETWORK, 'gossip_store')) |
| 2278 | l1.start() |
| 2279 | |
| 2280 | nodes = [nodemap[i] for i in range(0, 5)] |
| 2281 | expected = [] |
| 2282 | chancount = 0 |
| 2283 | for c in chans: |
| 2284 | for d in (0, 1): |
| 2285 | # listchannels direction 0 always lesser -> greater. |
| 2286 | if nodes[c.node1] < nodes[c.node2]: |
| 2287 | expected_dir = d |
| 2288 | else: |
| 2289 | expected_dir = d ^ 1 |
| 2290 | channel_flags = expected_dir |
| 2291 | if not c.half[d].enabled: |
| 2292 | active = False |
| 2293 | channel_flags |= 2 |
| 2294 | else: |
| 2295 | active = True |
| 2296 | if d == 0: |
| 2297 | n1 = nodes[c.node1] |
| 2298 | n2 = nodes[c.node2] |
| 2299 | else: |
| 2300 | n1 = nodes[c.node2] |
| 2301 | n2 = nodes[c.node1] |
| 2302 | |
| 2303 | expected.append({'source': n1, |
| 2304 | 'destination': n2, |
| 2305 | 'short_channel_id': '{}x{}x{}'.format(c.node1 + chancount, c.node2, chancount), |
| 2306 | 'direction': expected_dir, |
| 2307 | 'public': True, |
| 2308 | 'amount_msat': c.capacity_sats * 1000, |
| 2309 | 'message_flags': 1, |
| 2310 | 'channel_flags': channel_flags, |
| 2311 | 'active': active, |
| 2312 | 'last_update': 0, |
| 2313 | 'base_fee_millisatoshi': c.half[d].basefee, |
| 2314 | 'fee_per_millionth': c.half[d].propfee, |
| 2315 | 'delay': c.half[d].delay, |
| 2316 | 'htlc_minimum_msat': c.half[d].htlc_min, |
nothing calls this directly
no test coverage detected