Closed SgtPooki closed 1 month ago
Just a thought but as implemented the tests fail because we expect configured gateways to fail to find the block, but now the session will try to find it in the routing.
In this test we could ensure that the routing is not consulted by resolving the DNSLink record to an identity CID instead?
This will likely make the test less fragile going forwards.
diff --git a/packages/verified-fetch/test/custom-dns-resolvers.spec.ts b/packages/verified-fetch/test/custom-dns-resolvers.spec.ts
index 9d330f8..f8ff641 100644
--- a/packages/verified-fetch/test/custom-dns-resolvers.spec.ts
+++ b/packages/verified-fetch/test/custom-dns-resolvers.spec.ts
@@ -21,7 +21,7 @@ describe('custom dns-resolvers', () => {
it('is used when passed to createVerifiedFetch', async () => {
const customDnsResolver = Sinon.stub().withArgs('_dnslink.some-non-cached-domain.com').resolves({
Answer: [{
- data: 'dnslink=/ipfs/QmVP2ip92jQuMDezVSzQBWDqWFbp9nyCHNQSiciRauPLDg'
+ data: 'dnslink=/ipfs/bafkqac3imvwgy3zao5xxe3de'
}]
})
@@ -30,8 +30,9 @@ describe('custom dns-resolvers', () => {
dnsResolvers: [customDnsResolver]
})
const response = await fetch('ipns://some-non-cached-domain.com')
- expect(response.status).to.equal(502)
- expect(response.statusText).to.equal('Bad Gateway')
+ expect(response.status).to.equal(200)
+ expect(response.statusText).to.equal('OK')
+ await expect(response.text()).to.eventually.equal('hello world')
expect(customDnsResolver.callCount).to.equal(1)
expect(customDnsResolver.getCall(0).args).to.deep.equal(['_dnslink.some-non-cached-domain.com', {
@@ -44,7 +45,7 @@ describe('custom dns-resolvers', () => {
it('is used when passed to VerifiedFetch', async () => {
const customDnsResolver = Sinon.stub().withArgs('_dnslink.some-non-cached-domain2.com').resolves({
Answer: [{
- data: 'dnslink=/ipfs/QmVP2ip92jQuMDezVSzQBWDqWFbp9nyCHNQSiciRauPLDg'
+ data: 'dnslink=/ipfs/bafkqac3imvwgy3zao5xxe3de'
}]
})
@@ -62,8 +63,9 @@ describe('custom dns-resolvers', () => {
})
const response = await verifiedFetch.fetch('ipns://some-non-cached-domain2.com')
- expect(response.status).to.equal(502)
- expect(response.statusText).to.equal('Bad Gateway')
+ expect(response.status).to.equal(200)
+ expect(response.statusText).to.equal('OK')
+ await expect(response.text()).to.eventually.equal('hello world')
expect(customDnsResolver.callCount).to.equal(1)
expect(customDnsResolver.getCall(0).args).to.deep.equal(['_dnslink.some-non-cached-domain2.com', {
this was resolved in #50
Title
fix: custom dns-resolvers test passes
Description
temporary fix for failing tests with dns-resolvers when using sessions: https://github.com/ipfs/helia-verified-fetch/pull/50#issuecomment-2062047400
This should not be occurring and we should ensure this works with sessions.
Notes & open questions
Change checklist