Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: peer record interop with go #739

Merged
merged 4 commits into from
Aug 27, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: fix linting
  • Loading branch information
jacobheun committed Aug 26, 2020
commit 12bca389bcdef681f8ecb9acebd95d6168426063
5 changes: 2 additions & 3 deletions test/record/peer-record.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const { expect } = chai
const tests = require('libp2p-interfaces/src/record/tests')
const multiaddr = require('multiaddr')
const PeerId = require('peer-id')
const uint8arrayEquals = require('uint8arrays/equals')

const Envelope = require('../../src/record/envelope')
const PeerRecord = require('../../src/record/peer-record')
Expand All @@ -35,8 +34,8 @@ describe('PeerRecord', () => {
})

it('de/serializes the same as a go record', async () => {
const privKey = Uint8Array.from([8,1,18,64,133,251,231,43,96,100,40,144,4,165,49,249,103,137,141,245,49,158,224,41,146,253,216,64,33,250,80,82,67,75,246,238,17,187,163,237,23,33,148,140,239,180,229,11,10,11,181,202,216,166,181,45,199,177,164,15,79,102,82,16,92,145,226,196])
const rawEnvelope = Uint8Array.from([10,36,8,1,18,32,17,187,163,237,23,33,148,140,239,180,229,11,10,11,181,202,216,166,181,45,199,177,164,15,79,102,82,16,92,145,226,196,18,2,3,1,26,170,1,10,38,0,36,8,1,18,32,17,187,163,237,23,33,148,140,239,180,229,11,10,11,181,202,216,166,181,45,199,177,164,15,79,102,82,16,92,145,226,196,16,216,184,224,191,147,145,182,151,22,26,10,10,8,4,1,2,3,4,6,0,0,26,10,10,8,4,1,2,3,4,6,0,1,26,10,10,8,4,1,2,3,4,6,0,2,26,10,10,8,4,1,2,3,4,6,0,3,26,10,10,8,4,1,2,3,4,6,0,4,26,10,10,8,4,1,2,3,4,6,0,5,26,10,10,8,4,1,2,3,4,6,0,6,26,10,10,8,4,1,2,3,4,6,0,7,26,10,10,8,4,1,2,3,4,6,0,8,26,10,10,8,4,1,2,3,4,6,0,9,42,64,177,151,247,107,159,40,138,242,180,103,254,102,111,119,68,118,40,112,73,180,36,183,57,117,200,134,14,251,2,55,45,2,106,121,149,132,84,26,215,47,38,84,52,100,133,188,163,236,227,100,98,183,209,177,57,28,141,39,109,196,171,139,202,11])
const privKey = Uint8Array.from([8, 1, 18, 64, 133, 251, 231, 43, 96, 100, 40, 144, 4, 165, 49, 249, 103, 137, 141, 245, 49, 158, 224, 41, 146, 253, 216, 64, 33, 250, 80, 82, 67, 75, 246, 238, 17, 187, 163, 237, 23, 33, 148, 140, 239, 180, 229, 11, 10, 11, 181, 202, 216, 166, 181, 45, 199, 177, 164, 15, 79, 102, 82, 16, 92, 145, 226, 196])
const rawEnvelope = Uint8Array.from([10, 36, 8, 1, 18, 32, 17, 187, 163, 237, 23, 33, 148, 140, 239, 180, 229, 11, 10, 11, 181, 202, 216, 166, 181, 45, 199, 177, 164, 15, 79, 102, 82, 16, 92, 145, 226, 196, 18, 2, 3, 1, 26, 170, 1, 10, 38, 0, 36, 8, 1, 18, 32, 17, 187, 163, 237, 23, 33, 148, 140, 239, 180, 229, 11, 10, 11, 181, 202, 216, 166, 181, 45, 199, 177, 164, 15, 79, 102, 82, 16, 92, 145, 226, 196, 16, 216, 184, 224, 191, 147, 145, 182, 151, 22, 26, 10, 10, 8, 4, 1, 2, 3, 4, 6, 0, 0, 26, 10, 10, 8, 4, 1, 2, 3, 4, 6, 0, 1, 26, 10, 10, 8, 4, 1, 2, 3, 4, 6, 0, 2, 26, 10, 10, 8, 4, 1, 2, 3, 4, 6, 0, 3, 26, 10, 10, 8, 4, 1, 2, 3, 4, 6, 0, 4, 26, 10, 10, 8, 4, 1, 2, 3, 4, 6, 0, 5, 26, 10, 10, 8, 4, 1, 2, 3, 4, 6, 0, 6, 26, 10, 10, 8, 4, 1, 2, 3, 4, 6, 0, 7, 26, 10, 10, 8, 4, 1, 2, 3, 4, 6, 0, 8, 26, 10, 10, 8, 4, 1, 2, 3, 4, 6, 0, 9, 42, 64, 177, 151, 247, 107, 159, 40, 138, 242, 180, 103, 254, 102, 111, 119, 68, 118, 40, 112, 73, 180, 36, 183, 57, 117, 200, 134, 14, 251, 2, 55, 45, 2, 106, 121, 149, 132, 84, 26, 215, 47, 38, 84, 52, 100, 133, 188, 163, 236, 227, 100, 98, 183, 209, 177, 57, 28, 141, 39, 109, 196, 171, 139, 202, 11])
const peerId = await PeerId.createFromPrivKey(privKey)

const env = await Envelope.openAndCertify(rawEnvelope, PeerRecord.DOMAIN)
Expand Down