Generate single genesis in tests
This commit is contained in:
+16
-1
@@ -1,19 +1,23 @@
|
||||
package node_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/filecoin-project/go-lotus/node"
|
||||
"github.com/filecoin-project/go-lotus/node/modules"
|
||||
modtest "github.com/filecoin-project/go-lotus/node/modules/testing"
|
||||
|
||||
"github.com/filecoin-project/go-lotus/api"
|
||||
"github.com/filecoin-project/go-lotus/api/client"
|
||||
"github.com/filecoin-project/go-lotus/api/test"
|
||||
"github.com/filecoin-project/go-lotus/lib/jsonrpc"
|
||||
|
||||
"github.com/filecoin-project/go-lotus/node/repo"
|
||||
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
|
||||
|
||||
"github.com/filecoin-project/go-lotus/node/repo"
|
||||
)
|
||||
|
||||
func builder(t *testing.T, n int) []api.FullNode {
|
||||
@@ -22,13 +26,24 @@ func builder(t *testing.T, n int) []api.FullNode {
|
||||
|
||||
out := make([]api.FullNode, n)
|
||||
|
||||
var genbuf bytes.Buffer
|
||||
|
||||
for i := 0; i < n; i++ {
|
||||
var genesis node.Option
|
||||
if i == 0 {
|
||||
genesis = node.Override(new(modules.Genesis), modtest.MakeGenesisMem(&genbuf))
|
||||
} else {
|
||||
genesis = node.Override(new(modules.Genesis), modules.LoadGenesis(genbuf.Bytes()))
|
||||
}
|
||||
|
||||
var err error
|
||||
err = node.New(ctx,
|
||||
node.FullAPI(&out[i]),
|
||||
node.Online(),
|
||||
node.Repo(repo.NewMemory(nil)),
|
||||
MockHost(mn),
|
||||
|
||||
genesis,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user