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