forked from Mozartted/ethr-did-resolver
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: require a configuration to be used when initializing the resolver
BREAKING CHANGE: this removes the fallback hardcoded RPC URLs and will fail early when a wrong configuration (or none) is provided to `getResolver()`
- Loading branch information
Showing
4 changed files
with
86 additions
and
50 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Resolver } from 'did-resolver' | ||
import { getResolver } from '../ethr-did-resolver' | ||
|
||
describe('getResolver', () => { | ||
let addr = '0xd0dbe9d3698738f899ccd8ee27ff2347a7faa4dd' | ||
|
||
it('throws when no configuration is provided', () => { | ||
expect(() => { getResolver() }) | ||
.toThrow("EthrDIDResolver requires a provider configuration for at least one network") | ||
}) | ||
|
||
it("throws when trying to resolve a non configured network", async () => { | ||
const did = 'did:ethr:nonconf:' + addr | ||
const ethr = getResolver({networks: [{name: "existent", rpcUrl: "http://localhost:7545"}]}) | ||
const resolver = new Resolver(ethr) | ||
return await expect(resolver.resolve(did)).rejects.toThrow("No conf for networkId: nonconf") | ||
}) | ||
|
||
it("throws when trying to resolve mainnet on a config with only private networks", async () => { | ||
const did = 'did:ethr:' + addr | ||
const ethr = getResolver({networks: [{name: "0x4", rpcUrl: "http://localhost:7545"}]}) | ||
const resolver = new Resolver(ethr) | ||
return await expect(resolver.resolve(did)).rejects.toThrow("No conf for networkId: mainnet") | ||
}) | ||
|
||
}) |
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.