Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Commit

Permalink
fix: export selector/validators with the same name as their prefix (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
achingbrain authored Mar 24, 2022
1 parent b05f9e2 commit 4913d1f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@
"uint8arrays": "^3.0.0"
},
"devDependencies": {
"@libp2p/crypto": "^0.22.7",
"@libp2p/interfaces": "^1.3.3",
"@libp2p/crypto": "^0.22.9",
"@libp2p/interfaces": "^1.3.18",
"aegir": "^36.1.3"
}
}
2 changes: 1 addition & 1 deletion src/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ function publickKey (k: Uint8Array, records: Uint8Array[]) {
}

export const selectors = {
publickKey
pk: publickKey
}
2 changes: 1 addition & 1 deletion src/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ const publicKey = {
}

export const validators = {
publicKey
pk: publicKey
}
4 changes: 2 additions & 2 deletions test/selection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ describe('selection', () => {
describe('selectors', () => {
it('public key', () => {
expect(
selection.selectors.publickKey(uint8ArrayFromString('/hello/world'), records)
selection.selectors.pk(uint8ArrayFromString('/hello/world'), records)
).to.equal(
0
)
})

it('returns the first record when there is only one to select', () => {
expect(
selection.selectors.publickKey(uint8ArrayFromString('/hello/world'), [records[0]])
selection.selectors.pk(uint8ArrayFromString('/hello/world'), [records[0]])
).to.equal(
0
)
Expand Down
10 changes: 5 additions & 5 deletions test/validator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,28 +99,28 @@ describe('validator', () => {

describe('validators', () => {
it('exports pk', () => {
expect(validator.validators).to.have.keys(['publicKey'])
expect(validator.validators).to.have.keys(['pk'])
})

describe('public key', () => {
it('exports func and sign', () => {
const pk = validator.validators.publicKey
const pk = validator.validators.pk

expect(pk).to.have.property('func')
expect(pk).to.have.property('sign', false)
})

it('does not error on valid record', async () => {
return await Promise.all(cases.valid.publicKey.map(async (k) => {
return await validator.validators.publicKey.func(k, key.public.bytes)
return await validator.validators.pk.func(k, key.public.bytes)
}))
})

it('throws on invalid records', async () => {
return await Promise.all(cases.invalid.publicKey.map(async ({ data, code }) => {
try {
//
await validator.validators.publicKey.func(data, key.public.bytes)
await validator.validators.pk.func(data, key.public.bytes)
} catch (err: any) {
expect(err.code).to.eql(code)
return
Expand All @@ -137,7 +137,7 @@ describe('validator', () => {

const hash = await pubKey.hash()
const k = Uint8Array.of(...uint8ArrayFromString('/pk/'), ...hash)
return await validator.validators.publicKey.func(k, pubKey.bytes)
return await validator.validators.pk.func(k, pubKey.bytes)
})
})
})

0 comments on commit 4913d1f

Please sign in to comment.