mirror of
https://github.com/libp2p/go-libp2p-core.git
synced 2025-03-14 11:10:05 +08:00
test that PeerRecords can't be signed by wrong key
This commit is contained in:
parent
2e8cabcc87
commit
59348dea5a
@ -34,6 +34,15 @@ func TestSignedPeerRecordFromEnvelope(t *testing.T) {
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("signing fails if signing key does not match peer id in record", func(t *testing.T) {
|
||||
id = "some-other-peer-id"
|
||||
rec := NewPeerRecord(id, addrs)
|
||||
_, err := rec.Sign(priv)
|
||||
if err != ErrPeerIdMismatch {
|
||||
t.Error("expected signing with mismatched private key to fail")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("unwrapping from signed envelope fails if envelope has wrong domain string", func(t *testing.T) {
|
||||
payload := []byte("ignored")
|
||||
test.AssertNilError(t, err)
|
||||
|
Loading…
Reference in New Issue
Block a user