diff --git a/packages/libp2p-interfaces-compliance-tests/src/peer-id/index.ts b/packages/libp2p-interfaces-compliance-tests/src/peer-id/index.ts index b9cbf736a..4f5c34d5a 100644 --- a/packages/libp2p-interfaces-compliance-tests/src/peer-id/index.ts +++ b/packages/libp2p-interfaces-compliance-tests/src/peer-id/index.ts @@ -58,14 +58,14 @@ export default (common: TestSetup) => { it('can be created for a Secp256k1 key', async () => { const id = await factory.create({ keyType: 'secp256k1', bits: 256 }) - const expB58 = base58btc.encode((await identity.digest(id.pubKey.bytes)).bytes).slice(1) + const expB58 = base58btc.encode((await identity.digest(id.pubKey!.bytes)).bytes).slice(1) expect(id.toB58String()).to.equal(expB58) }) it('can get the public key from a Secp256k1 key', async () => { const original = await factory.create({ keyType: 'secp256k1', bits: 256 }) const newId = factory.createFromB58String(original.toB58String()) - expect(original.pubKey.bytes).to.eql(newId.pubKey.bytes) + expect(original.pubKey!.bytes).to.eql(newId.pubKey!.bytes) }) it('isPeerId', async () => { @@ -194,7 +194,7 @@ export default (common: TestSetup) => { const key = '12D3KooWRm8J3iL796zPFi2EtGGtUJn58AG67gcqzMFHZnnsTzqD' const id = await factory.parse(key) expect(id.toB58String()).to.equal(key) - const expB58 = base58btc.encode((await identity.digest(id.pubKey.bytes)).bytes).slice(1) + const expB58 = base58btc.encode((await identity.digest(id.pubKey!.bytes)).bytes).slice(1) expect(id.toB58String()).to.equal(expB58) }) @@ -202,7 +202,7 @@ export default (common: TestSetup) => { const key = '16Uiu2HAm5qw8UyXP2RLxQUx5KvtSN8DsTKz8quRGqGNC3SYiaB8E' const id = await factory.parse(key) expect(id.toB58String()).to.equal(key) - const expB58 = base58btc.encode((await identity.digest(id.pubKey.bytes)).bytes).slice(1) + const expB58 = base58btc.encode((await identity.digest(id.pubKey!.bytes)).bytes).slice(1) expect(id.toB58String()).to.equal(expB58) }) @@ -215,20 +215,20 @@ export default (common: TestSetup) => { it('can be created from a Secp256k1 public key', async () => { const privKey = await crypto.keys.generateKeyPair('secp256k1', 256) const id = await factory.createFromPubKey(privKey.public.bytes) - const expB58 = base58btc.encode((await identity.digest(id.pubKey.bytes)).bytes).slice(1) + const expB58 = base58btc.encode((await identity.digest(id.pubKey!.bytes)).bytes).slice(1) expect(id.toB58String()).to.equal(expB58) }) it('can be created from a Secp256k1 private key', async () => { const privKey = await crypto.keys.generateKeyPair('secp256k1', 256) const id = await factory.createFromPrivKey(privKey.bytes) - const expB58 = base58btc.encode((await identity.digest(id.pubKey.bytes)).bytes).slice(1) + const expB58 = base58btc.encode((await identity.digest(id.pubKey!.bytes)).bytes).slice(1) expect(id.toB58String()).to.equal(expB58) }) it('Compare generated ID with one created from PubKey', async () => { const id1 = await factory.create(testOpts) - const id2 = await factory.createFromPubKey(id1.marshalPubKey()) + const id2 = await factory.createFromPubKey(id1.marshalPubKey()!) expect(id1.id).to.be.eql(id2.id) }) @@ -242,7 +242,7 @@ export default (common: TestSetup) => { this.timeout(1000 * 60) const shortId = await factory.create(testOpts) const longId = await factory.create({ bits: 1024 }) - expect(shortId.privKey.bytes.length).is.below(longId.privKey.bytes.length) + expect(shortId.privKey!.bytes.length).is.below(longId.privKey!.bytes.length) }) it('Pretty printing', async () => { @@ -292,8 +292,8 @@ export default (common: TestSetup) => { const id = await factory.create(testOpts) const other = await factory.createFromJSON(id.toJSON()) expect(id.toB58String()).to.equal(other.toB58String()) - expect(id.privKey.bytes).to.eql(other.privKey.bytes) - expect(id.pubKey.bytes).to.eql(other.pubKey.bytes) + expect(id.privKey!.bytes).to.eql(other.privKey!.bytes) + expect(id.pubKey!.bytes).to.eql(other.pubKey!.bytes) }) it('only id', async () => { @@ -308,7 +308,7 @@ export default (common: TestSetup) => { it('go interop', async () => { const id = await factory.createFromJSON(goId) - const digest = await id.privKey.public.hash() + const digest = await id.privKey!.public.hash() expect(base58btc.encode(digest).slice(1)).to.eql(goId.id) }) })