fix: custom dns-resolvers test passes#55
Closed
SgtPooki wants to merge 7 commits into
Closed
Conversation
Adds a configurable session cache that creates sessions based on the base URL of the requested resource. E.g. `https://Qmfoo.ipfs.gateway.com/foo.txt` and`https://Qmfoo.ipfs.gateway.com/bar.txt` will be loaded from the same session. Defaults to 100 sessions maximum with a TTL of one minute. These are arbitrary numbers that will require some tweaking.
9b87ff1 to
4b05147
Compare
Member
|
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', { |
Member
Author
|
this was resolved in #50 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Title
fix: custom dns-resolvers test passes
Description
temporary fix for failing tests with dns-resolvers when using sessions: #50 (comment)
This should not be occurring and we should ensure this works with sessions.
Notes & open questions
Change checklist