42 lines
855 B
Go
42 lines
855 B
Go
|
package test
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"testing"
|
||
|
"time"
|
||
|
|
||
|
"github.com/filecoin-project/go-address"
|
||
|
"github.com/filecoin-project/lotus/api/test"
|
||
|
test2 "github.com/filecoin-project/lotus/node/test"
|
||
|
)
|
||
|
|
||
|
func StartOneNodeOneMiner(ctx context.Context, t *testing.T, blocktime time.Duration) (test.TestNode, address.Address) {
|
||
|
n, sn := test2.RPCMockSbBuilder(t, test.OneFull, test.OneMiner)
|
||
|
|
||
|
full := n[0]
|
||
|
miner := sn[0]
|
||
|
|
||
|
// Get everyone connected
|
||
|
addrs, err := full.NetAddrsListen(ctx)
|
||
|
if err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
|
|
||
|
if err := miner.NetConnect(ctx, addrs); err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
|
|
||
|
// Start mining blocks
|
||
|
bm := test.NewBlockMiner(ctx, t, miner, blocktime)
|
||
|
bm.MineBlocks()
|
||
|
|
||
|
// Get the full node's wallet address
|
||
|
fullAddr, err := full.WalletDefaultAddress(ctx)
|
||
|
if err != nil {
|
||
|
t.Fatal(err)
|
||
|
}
|
||
|
|
||
|
// Create mock CLI
|
||
|
return full, fullAddr
|
||
|
}
|