@@ -2207,3 +2207,75 @@ def test_generate_gossip_store(node_factory):
2207
2207
expected = sorted (expected , key = lambda x : x ['source' ] + x ['destination' ])
2208
2208
2209
2209
assert lchans == expected
2210
+
2211
+
2212
+ def test_gossip_status (node_factory , chainparams ):
2213
+ # Since we respond if we have > 100 more than them, we need a big gossmap.
2214
+ l1 = node_factory .get_node (start = False )
2215
+ chans = [GenChannel (0 , i ) for i in range (1 , 102 )]
2216
+ gsfile , nodemap = generate_gossip_store (chans )
2217
+ shutil .copy (gsfile .name , os .path .join (l1 .daemon .lightning_dir , TEST_NETWORK , 'gossip_store' ))
2218
+
2219
+ l1 .daemon .opts ['experimental-gossip-status' ] = None
2220
+ l1 .start ()
2221
+
2222
+ assert len (l1 .rpc .listchannels ()['channels' ]) == 101 * 2
2223
+
2224
+ # If I say I have 1/102/1, you won't give me anything.
2225
+ out = subprocess .run (['devtools/gossipwith' ,
2226
+ '--no-gossip' ,
2227
+ '--hex' ,
2228
+ '--network={}' .format (TEST_NETWORK ),
2229
+ '--timeout-after={}' .format (int (math .sqrt (TIMEOUT ) + 1 )),
2230
+ '{}@localhost:{}' .format (l1 .info ['id' ], l1 .port ),
2231
+ # BOLT-gossip_status #7:
2232
+ # 1. type: 267 (`gossip_status`)
2233
+ # 2. data:
2234
+ # * [`chain_hash`:`chain_hash`]
2235
+ # * [`bigsize`:`num_channel_announcements`]
2236
+ # * [`bigsize`:`num_channel_updates`]
2237
+ # * [`bigsize`:`num_node_announcements`]
2238
+ '763B' + chainparams ['chain_hash' ] + '016601' ],
2239
+ check = True ,
2240
+ timeout = TIMEOUT , stdout = subprocess .PIPE ).stdout .split ()
2241
+
2242
+ # No channel_announcments, channel_updates or node_announcements
2243
+ assert [m for m in out if m .startswith (b'0100' ) or m .startswith (b'0101' ) or m .startswith (b'0102' )] == []
2244
+
2245
+ # If I say I have 0 channel_announcments, you spew gossip...
2246
+ out = subprocess .run (['devtools/gossipwith' ,
2247
+ '--no-gossip' ,
2248
+ '--hex' ,
2249
+ '--network={}' .format (TEST_NETWORK ),
2250
+ '--timeout-after={}' .format (int (math .sqrt (TIMEOUT ) + 1 )),
2251
+ '{}@localhost:{}' .format (l1 .info ['id' ], l1 .port ),
2252
+ # BOLT-gossip_status #7:
2253
+ # 1. type: 267 (`gossip_status`)
2254
+ # 2. data:
2255
+ # * [`chain_hash`:`chain_hash`]
2256
+ # * [`bigsize`:`num_channel_announcements`]
2257
+ # * [`bigsize`:`num_channel_updates`]
2258
+ # * [`bigsize`:`num_node_announcements`]
2259
+ '763B' + chainparams ['chain_hash' ] + '00CA01' ],
2260
+ check = True ,
2261
+ timeout = TIMEOUT , stdout = subprocess .PIPE ).stdout .split ()
2262
+ assert len ([m for m in out if m .startswith (b'0100' ) or m .startswith (b'0101' ) or m .startswith (b'0102' )]) == 303
2263
+
2264
+ # If I say I have 101 channel_updates, you spew gossip...
2265
+ out = subprocess .run (['devtools/gossipwith' ,
2266
+ '--no-gossip' ,
2267
+ '--hex' ,
2268
+ '--network={}' .format (TEST_NETWORK ),
2269
+ '--timeout-after={}' .format (int (math .sqrt (TIMEOUT ) + 1 )),
2270
+ '{}@localhost:{}' .format (l1 .info ['id' ], l1 .port ),
2271
+ # BOLT-gossip_status #7:
2272
+ # 1. type: 267 (`gossip_status`)
2273
+ # 2. data:
2274
+ # * [`chain_hash`:`chain_hash`]
2275
+ # * [`bigsize`:`num_channel_announcements`]
2276
+ # * [`bigsize`:`num_channel_updates`]
2277
+ # * [`bigsize`:`num_node_announcements`]
2278
+ '763B' + chainparams ['chain_hash' ] + '656501' ],
2279
+ check = True ,
2280
+ timeout = TIMEOUT , stdout = subprocess .PIPE ).stdout .split ()
2281
+ assert len ([m for m in out if m .startswith (b'0100' ) or m .startswith (b'0101' ) or m .startswith (b'0102' )]) == 303
0 commit comments