2020-05-06 16:31:47 +00:00
|
|
|
{.used.}
|
2019-12-07 16:36:39 +00:00
|
|
|
|
2021-05-21 16:27:01 +00:00
|
|
|
import options, bearssl
|
2020-02-11 17:53:39 +00:00
|
|
|
import chronos
|
2019-12-07 16:36:39 +00:00
|
|
|
import ../libp2p/crypto/crypto,
|
|
|
|
../libp2p/peerinfo,
|
2020-07-01 06:25:09 +00:00
|
|
|
../libp2p/peerid
|
2020-04-21 01:24:42 +00:00
|
|
|
|
2020-07-07 11:14:11 +00:00
|
|
|
import ./helpers
|
|
|
|
|
2019-12-07 16:36:39 +00:00
|
|
|
suite "PeerInfo":
|
|
|
|
test "Should init with private key":
|
2020-07-07 11:14:11 +00:00
|
|
|
let seckey = PrivateKey.random(ECDSA, rng[]).get()
|
2019-12-07 16:36:39 +00:00
|
|
|
var peerInfo = PeerInfo.init(seckey)
|
2020-07-01 06:25:09 +00:00
|
|
|
var peerId = PeerID.init(seckey).get()
|
2019-12-07 16:36:39 +00:00
|
|
|
|
|
|
|
check peerId == peerInfo.peerId
|
2021-09-08 09:07:46 +00:00
|
|
|
check seckey.getPublicKey().get() == peerInfo.publicKey
|