From a3f6ce1f8f967d919cf2bcdd7b23e379757e6e06 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 8 Oct 2019 11:37:24 +1030 Subject: [PATCH] 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 --- tests/utils.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/utils.py b/tests/utils.py index 7afab8927..35f17734d 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -809,7 +809,7 @@ class LightningNode(object): 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 in hex""" query = subprocess.run(['devtools/mkquery', @@ -825,10 +825,18 @@ class LightningNode(object): check=True, timeout=TIMEOUT, stdout=subprocess.PIPE).stdout + def passes_filters(hmsg, filters): + for f in filters: + if hmsg.startswith(f): + return False + return True + msgs = [] while len(out): 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:] return msgs