Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nitro-neal committed Apr 9, 2024
1 parent 08974e1 commit 0770ff1
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
27 changes: 26 additions & 1 deletion packages/dids/tests/methods/did-dht.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1152,11 +1152,36 @@ describe('DidDhtDocument', () => {
});

describe('Web5TestVectorsDidDht', () => {
let fetchStub: sinon.SinonStub;

beforeEach(() => {
// Setup stub so that a mocked response is returned rather than calling over the network.
fetchStub = sinon.stub(globalThis as any, 'fetch');

// By default, return a 200 OK response when fetch is called by publish().
fetchStub.resolves(fetchOkResponse());
});

afterEach(() => {
fetchStub.restore();
});

it('resolve', async () => {
for (const vector of DidDhtResolveTestVector.vectors as any[]) {

if(vector.input.mockResponse) {
fetchStub.resolves({
ok : vector.input.mockResponse.ok,
status : vector.input.mockResponse.status,
statusText : vector.input.mockResponse.statusText,
json : () => Promise.resolve(vector.input.mockResponse.body),
text : () => Promise.resolve(JSON.stringify(vector.input.mockResponse.body)),
});
}

const didResolutionResult = await DidDht.resolve(vector.input.didUri);
expect(didResolutionResult.didResolutionMetadata.error).to.equal(vector.output.didResolutionMetadata.error);
}
}).timeout(300000); // Set timeout to 300 seconds for this test for did:dht resolution timeout test
});
});
});
2 changes: 1 addition & 1 deletion web5-spec

0 comments on commit 0770ff1

Please sign in to comment.