diff --git a/packages/utils/test/abstract-session.spec.ts b/packages/utils/test/abstract-session.spec.ts index 025ca29ac..14318352f 100644 --- a/packages/utils/test/abstract-session.spec.ts +++ b/packages/utils/test/abstract-session.spec.ts @@ -254,4 +254,25 @@ describe('abstract-session', () => { expect(session.findNewProviders).to.have.property('callCount', 2) expect(session.queryProvider).to.have.property('callCount', 1) }) + + it('should respect signals', async () => { + const signal = AbortSignal.timeout(10) + const session = new Session() + + const cid = CID.parse('bafybeifaymukvfkyw6xgh4th7tsctiifr4ea2btoznf46y6b2fnvikdczi') + + session.findNewProviders.callsFake(async function * () { + yield { + id: await createEd25519PeerId() + } + }) + session.queryProvider.callsFake(async () => { + throw new Error('Urk!') + }) + + await expect(session.retrieve(cid, { + signal + })).to.eventually.be.rejected() + .with.property('code', 'ABORT_ERR') + }) })