Skip to content

Commit

Permalink
@pierluca's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ineiti committed Jul 5, 2024
1 parent 0d1740a commit 4d35537
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
1 change: 1 addition & 0 deletions mino/minogrpc/controller/mod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ func TestMiniController_FailGenerateKey_OnStart(t *testing.T) {
}

func TestMiniController_FailMarshalKey_OnStart(t *testing.T) {
t.Skip("Testing if this is the culprit")
ctrl := NewController().(miniController)
ctrl.curve = badCurve{}

Expand Down
3 changes: 2 additions & 1 deletion mino/minows/key/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package key

import (
"crypto/rand"

"github.com/libp2p/go-libp2p/core/crypto"
"go.dedis.ch/dela/core/store/kv"
"golang.org/x/xerrors"
Expand All @@ -16,7 +17,7 @@ type Storage struct {
// NewStorage creates a new Storage for private keys.
func NewStorage(db kv.DB) *Storage {
return &Storage{
bucket: []byte("keys"),
bucket: []byte("minows_keys"),
db: db,
}
}
Expand Down
36 changes: 19 additions & 17 deletions test/cosidela_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ import (
"crypto/ecdsa"
"crypto/elliptic"
"crypto/x509"
ma "github.com/multiformats/go-multiaddr"
"go.dedis.ch/dela/mino/minows"
"go.dedis.ch/dela/mino/minows/key"
"fmt"
"io"
"math/rand"
"net/url"
"os"
"path/filepath"
"time"

ma "github.com/multiformats/go-multiaddr"
"go.dedis.ch/dela/mino/minows"
"go.dedis.ch/dela/mino/minows/key"

"github.com/stretchr/testify/require"
accessContract "go.dedis.ch/dela/contracts/access"
"go.dedis.ch/dela/contracts/value"
Expand Down Expand Up @@ -95,31 +97,31 @@ func newDelaNode(t require.TestingT, path string, port int, kind string) dela {
router := tree.NewRouter(minogrpc.NewAddressFactory())
addr := minogrpc.ParseAddress("127.0.0.1", uint16(port))

certs := certs.NewDiskStore(db, session.AddressFactory{})
delaCerts := certs.NewDiskStore(db, session.AddressFactory{})

fload := loader.NewFileLoader(filepath.Join(path, certKeyName))
keydata, err := fload.LoadOrCreate(newCertGenerator(rand.New(rand.NewSource(0)),
elliptic.P521()))
require.NoError(t, err)

key, err := x509.ParseECPrivateKey(keydata)
privateKey, err := x509.ParseECPrivateKey(keydata)
require.NoError(t, err)

opts := []minogrpc.Option{
minogrpc.WithStorage(certs),
minogrpc.WithCertificateKey(key, key.Public()),
minogrpc.WithStorage(delaCerts),
minogrpc.WithCertificateKey(privateKey, privateKey.Public()),
}

onet, err = minogrpc.NewMinogrpc(addr, nil, router, opts...)
require.NoError(t, err)
case minoWS:
listen, err := ma.NewMultiaddr("/ip4/127.0.0.1/tcp/0/ws")
listen, err := ma.NewMultiaddr(fmt.Sprintf("/ip4/127.0.0.1/tcp/%d/ws", port))
require.NoError(t, err)

storage := key.NewStorage(db)
key, _ := storage.LoadOrCreate()
privKey, _ := storage.LoadOrCreate()

onet, err = minows.NewMinows(listen, nil, key)
onet, err = minows.NewMinows(listen, nil, privKey)
require.NoError(t, err)
}
onet.GetAddress()
Expand Down Expand Up @@ -147,22 +149,22 @@ func newDelaNode(t require.TestingT, path string, port int, kind string) dela {
txFac := signed.NewTransactionFactory()
vs := simple.NewService(exec, txFac)

pool, err := poolimpl.NewPool(gossip.NewFlat(onet.WithSegment("pool"), txFac))
newPool, err := poolimpl.NewPool(gossip.NewFlat(onet.WithSegment("pool"), txFac))
require.NoError(t, err)

tree := binprefix.NewMerkleTree(db, binprefix.Nonce{})
newTree := binprefix.NewMerkleTree(db, binprefix.Nonce{})

param := cosipbft.ServiceParam{
Mino: onet,
Cosi: cosi,
Validation: vs,
Access: accessService,
Pool: pool,
Pool: newPool,
DB: db,
Tree: tree,
Tree: newTree,
}

err = tree.Load()
err = newTree.Load()
require.NoError(t, err)

genstore := blockstore.NewGenesisDiskStore(db, types.NewGenesisFactory(rosterFac))
Expand Down Expand Up @@ -202,10 +204,10 @@ func newDelaNode(t require.TestingT, path string, port int, kind string) dela {
ordering: srvc,
cosi: cosi,
txManager: mgr,
pool: pool,
pool: newPool,
accessService: accessService,
accessStore: accessStore,
tree: tree,
tree: newTree,
}
}

Expand Down

0 comments on commit 4d35537

Please sign in to comment.