This commit is contained in:
Oleksandr Kozlov 2023-05-12 21:44:21 +02:00 committed by Sasha
parent 2ac286638d
commit 392571e512
No known key found for this signature in database
1 changed files with 10 additions and 7 deletions

View File

@ -45,14 +45,17 @@ describe("js-noise: pairing object", () => {
};
const responder = {
toSubscriptionIterator(decoder: IDecoder<NoiseHandshakeMessage>) {
async function* iterator(): AsyncIterator<NoiseHandshakeMessage> {
const msg = await pEvent(msgEmitter, decoder.contentTopic);
const decodedMessage = await decoder.fromProtoObj(PUBSUB_TOPIC, msg);
yield decodedMessage!;
}
return {
iterator: iterator(),
iterator: {
async next() {
const msg = await pEvent(msgEmitter, decoder.contentTopic);
const decodedMessage = await decoder.fromProtoObj(PUBSUB_TOPIC, msg);
return {
value: decodedMessage,
done: false,
};
},
},
stop() {
// Do nothing. This is just a simulation
console.debug("stopping subscription to", decoder.contentTopic);