mirror of https://github.com/status-im/js-waku.git
chore: add a test that uses ping to check filter subscription (#1656)
* add a test that uses ping to check filter subscription * remove comment
This commit is contained in:
parent
347cbfa08a
commit
d39d4507ef
|
@ -59,4 +59,40 @@ describe("Waku Filter V2: Ping", function () {
|
|||
// Ping imediately after unsubscribe
|
||||
await validatePingError(subscription);
|
||||
});
|
||||
|
||||
it("Reopen subscription with peer with lost subscription", async function () {
|
||||
const openSubscription = async (): Promise<void> => {
|
||||
await subscription.subscribe([TestDecoder], messageCollector.callback);
|
||||
};
|
||||
|
||||
const unsubscribe = async (): Promise<void> => {
|
||||
await subscription.unsubscribe([TestContentTopic]);
|
||||
};
|
||||
|
||||
const pingAndReinitiateSubscription = async (): Promise<void> => {
|
||||
try {
|
||||
await subscription.ping();
|
||||
} catch (error) {
|
||||
if (
|
||||
error instanceof Error &&
|
||||
error.message.includes("peer has no subscriptions")
|
||||
) {
|
||||
await openSubscription();
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// open subscription & ping -> should pass
|
||||
await openSubscription();
|
||||
await pingAndReinitiateSubscription();
|
||||
|
||||
// unsubscribe & ping -> should fail and reinitiate subscription
|
||||
await unsubscribe();
|
||||
await pingAndReinitiateSubscription();
|
||||
|
||||
// ping -> should pass as subscription is reinitiated
|
||||
await pingAndReinitiateSubscription();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue