mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-03 18:57:06 +01:00
pytest: add filters arg to query_gossip()
Code changes mean we're going to get gossip_timestamp_filter messages from peers. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
9d336763ff
commit
a3f6ce1f8f
1 changed files with 10 additions and 2 deletions
|
@ -809,7 +809,7 @@ class LightningNode(object):
|
||||||
|
|
||||||
wait_for(lambda: txid in self.bitcoin.rpc.getrawmempool())
|
wait_for(lambda: txid in self.bitcoin.rpc.getrawmempool())
|
||||||
|
|
||||||
def query_gossip(self, querytype, *args):
|
def query_gossip(self, querytype, *args, filters=[]):
|
||||||
"""Generate a gossip query, feed it into this node and get responses
|
"""Generate a gossip query, feed it into this node and get responses
|
||||||
in hex"""
|
in hex"""
|
||||||
query = subprocess.run(['devtools/mkquery',
|
query = subprocess.run(['devtools/mkquery',
|
||||||
|
@ -825,10 +825,18 @@ class LightningNode(object):
|
||||||
check=True,
|
check=True,
|
||||||
timeout=TIMEOUT, stdout=subprocess.PIPE).stdout
|
timeout=TIMEOUT, stdout=subprocess.PIPE).stdout
|
||||||
|
|
||||||
|
def passes_filters(hmsg, filters):
|
||||||
|
for f in filters:
|
||||||
|
if hmsg.startswith(f):
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
msgs = []
|
msgs = []
|
||||||
while len(out):
|
while len(out):
|
||||||
length = struct.unpack('>H', out[0:2])[0]
|
length = struct.unpack('>H', out[0:2])[0]
|
||||||
msgs.append(out[2:2 + length].hex())
|
hmsg = out[2:2 + length].hex()
|
||||||
|
if passes_filters(hmsg, filters):
|
||||||
|
msgs.append(out[2:2 + length].hex())
|
||||||
out = out[2 + length:]
|
out = out[2 + length:]
|
||||||
return msgs
|
return msgs
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue