mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-01 14:28:02 +08:00
* Update golog in go-ipfs License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch> * Update go-libp2p for go-log License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch> * Update go-libp2p-secio for go-log License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch> * Update go-libp2p-crypto for go-log License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch> * Update go-libp2p-peer for go-log License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch> * Import peersore, it wasn't imported License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch> * Update peerstore License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch> * Update peer License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch> * Update secio License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch> * Update go-libp2p License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
56 lines
1.1 KiB
Go
56 lines
1.1 KiB
Go
package testutil
|
|
|
|
import (
|
|
"testing"
|
|
|
|
peer "gx/ipfs/QmRBqJF7hb8ZSpRcMwUt8hNhydWcxGEhtk81HKq6oUwKvs/go-libp2p-peer"
|
|
ci "gx/ipfs/QmUWER4r4qMvaCnX5zREcfyiWN7cXN9g3a7fkRqNz8qWPP/go-libp2p-crypto"
|
|
ma "gx/ipfs/QmYzDkkgAEmrcNzFCiYo6L1dTX4EAG1gZkbtdbd9trL4vd/go-multiaddr"
|
|
)
|
|
|
|
type Identity interface {
|
|
Address() ma.Multiaddr
|
|
ID() peer.ID
|
|
PrivateKey() ci.PrivKey
|
|
PublicKey() ci.PubKey
|
|
}
|
|
|
|
// TODO add a cheaper way to generate identities
|
|
|
|
func RandIdentity() (Identity, error) {
|
|
p, err := RandPeerNetParams()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &identity{*p}, nil
|
|
}
|
|
|
|
func RandIdentityOrFatal(t *testing.T) Identity {
|
|
p, err := RandPeerNetParams()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
return &identity{*p}
|
|
}
|
|
|
|
// identity is a temporary shim to delay binding of PeerNetParams.
|
|
type identity struct {
|
|
PeerNetParams
|
|
}
|
|
|
|
func (p *identity) ID() peer.ID {
|
|
return p.PeerNetParams.ID
|
|
}
|
|
|
|
func (p *identity) Address() ma.Multiaddr {
|
|
return p.Addr
|
|
}
|
|
|
|
func (p *identity) PrivateKey() ci.PrivKey {
|
|
return p.PrivKey
|
|
}
|
|
|
|
func (p *identity) PublicKey() ci.PubKey {
|
|
return p.PubKey
|
|
}
|