Skip to content

fix: Add peer id str to mismatch error #273

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

Merged
merged 2 commits into from
Feb 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export async function verifySignedPayload (
// Unmarshaling from PublicKey protobuf
const payloadPeerId = await peerIdFromKeys(payload.identityKey)
if (!payloadPeerId.equals(remotePeer)) {
throw new Error("Peer ID doesn't match libp2p public key.")
throw new Error(`Payload identity key ${payloadPeerId.toString()} does not match expected remote peer ${remotePeer.toString()}`)
}
const generatedPayload = getHandshakePayload(noiseStaticKey)

Expand Down
4 changes: 2 additions & 2 deletions test/xx-handshake.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe('XX Handshake', () => {
assert(false, 'Should throw exception')
} catch (e) {
const err = e as Error
expect(err.message).equals("Error occurred while verifying signed payload: Peer ID doesn't match libp2p public key.")
expect(err.message).equals(`Error occurred while verifying signed payload: Payload identity key ${peerB.toString()} does not match expected remote peer ${fakePeer.toString()}`)
}
})

Expand Down Expand Up @@ -120,7 +120,7 @@ describe('XX Handshake', () => {
assert(false, 'Should throw exception')
} catch (e) {
const err = e as Error
expect(err.message).equals("Error occurred while verifying signed payload: Peer ID doesn't match libp2p public key.")
expect(err.message).equals(`Error occurred while verifying signed payload: Payload identity key ${peerA.toString()} does not match expected remote peer ${fakePeer.toString()}`)
}
})
})