Commit 2e7d25b0 authored by Janoš Guljaš's avatar Janoš Guljaš Committed by GitHub

set Secp256k1 private key in libp2p test services instead temp RSA (#268)

parent ce03088d
...@@ -26,12 +26,12 @@ import ( ...@@ -26,12 +26,12 @@ import (
func newService(t *testing.T, networkID uint64, o libp2p.Options) (s *libp2p.Service, overlay swarm.Address) { func newService(t *testing.T, networkID uint64, o libp2p.Options) (s *libp2p.Service, overlay swarm.Address) {
t.Helper() t.Helper()
privateKey, err := crypto.GenerateSecp256k1Key() swarmKey, err := crypto.GenerateSecp256k1Key()
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
overlay = crypto.NewOverlayAddress(privateKey.PublicKey, networkID) overlay = crypto.NewOverlayAddress(swarmKey.PublicKey, networkID)
addr := ":0" addr := ":0"
...@@ -44,8 +44,17 @@ func newService(t *testing.T, networkID uint64, o libp2p.Options) (s *libp2p.Ser ...@@ -44,8 +44,17 @@ func newService(t *testing.T, networkID uint64, o libp2p.Options) (s *libp2p.Ser
o.Addressbook = addressbook.New(statestore) o.Addressbook = addressbook.New(statestore)
} }
if o.PrivateKey == nil {
libp2pKey, err := crypto.GenerateSecp256k1Key()
if err != nil {
t.Fatal(err)
}
o.PrivateKey = libp2pKey
}
ctx, cancel := context.WithCancel(context.Background()) ctx, cancel := context.WithCancel(context.Background())
s, err = libp2p.New(ctx, crypto.NewDefaultSigner(privateKey), networkID, overlay, addr, o) s, err = libp2p.New(ctx, crypto.NewDefaultSigner(swarmKey), networkID, overlay, addr, o)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment