wip
This commit is contained in:
parent
625b18771d
commit
c46d4ae529
@ -1,22 +0,0 @@
|
|||||||
package cli
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"os"
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
clitest "github.com/filecoin-project/lotus/cli/test"
|
|
||||||
)
|
|
||||||
|
|
||||||
// TestClient does a basic test to exercise the client CLI
|
|
||||||
// commands
|
|
||||||
func TestClient(t *testing.T) {
|
|
||||||
_ = os.Setenv("BELLMAN_NO_GPU", "1")
|
|
||||||
clitest.QuietMiningLogs()
|
|
||||||
|
|
||||||
blocktime := 5 * time.Millisecond
|
|
||||||
ctx := context.Background()
|
|
||||||
clientNode, _ := clitest.StartOneNodeOneMiner(ctx, t, blocktime)
|
|
||||||
clitest.RunClientTest(t, Commands, clientNode)
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
package test
|
package itests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/miner"
|
"github.com/filecoin-project/lotus/miner"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// BlockMiner is a utility that makes a test miner mine blocks on a timer.
|
||||||
type BlockMiner struct {
|
type BlockMiner struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
t *testing.T
|
t *testing.T
|
@ -1,4 +1,4 @@
|
|||||||
package test
|
package itests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -24,12 +24,12 @@ func TestCCUpgrade(t *testing.T, b APIBuilder, blocktime time.Duration) {
|
|||||||
} {
|
} {
|
||||||
height := height // make linters happy by copying
|
height := height // make linters happy by copying
|
||||||
t.Run(fmt.Sprintf("upgrade-%d", height), func(t *testing.T) {
|
t.Run(fmt.Sprintf("upgrade-%d", height), func(t *testing.T) {
|
||||||
testCCUpgrade(t, b, blocktime, height)
|
runTestCCUpgrade(t, b, blocktime, height)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func testCCUpgrade(t *testing.T, b APIBuilder, blocktime time.Duration, upgradeHeight abi.ChainEpoch) {
|
func runTestCCUpgrade(t *testing.T, b APIBuilder, blocktime time.Duration, upgradeHeight abi.ChainEpoch) {
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
n, sn := b(t, []FullNodeOpts{FullNodeWithLatestActorsAt(upgradeHeight)}, OneMiner)
|
n, sn := b(t, []FullNodeOpts{FullNodeWithLatestActorsAt(upgradeHeight)}, OneMiner)
|
||||||
client := n[0].FullNode.(*impl.FullNodeAPI)
|
client := n[0].FullNode.(*impl.FullNodeAPI)
|
21
itests/cliclient_test.go
Normal file
21
itests/cliclient_test.go
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package itests
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/cli"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TestClient does a basic test to exercise the client CLI commands.
|
||||||
|
func TestClient(t *testing.T) {
|
||||||
|
_ = os.Setenv("BELLMAN_NO_GPU", "1")
|
||||||
|
QuietMiningLogs()
|
||||||
|
|
||||||
|
blocktime := 5 * time.Millisecond
|
||||||
|
ctx := context.Background()
|
||||||
|
clientNode, _ := StartOneNodeOneMiner(ctx, t, blocktime)
|
||||||
|
RunClientTest(t, cli.Commands, clientNode)
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package test
|
package itests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -13,7 +13,6 @@ import (
|
|||||||
|
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api/test"
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
"github.com/filecoin-project/specs-actors/v2/actors/builtin"
|
||||||
@ -22,7 +21,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// RunClientTest exercises some of the client CLI commands
|
// RunClientTest exercises some of the client CLI commands
|
||||||
func RunClientTest(t *testing.T, cmds []*lcli.Command, clientNode test.TestNode) {
|
func RunClientTest(t *testing.T, cmds []*lcli.Command, clientNode TestNode) {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
@ -44,7 +43,7 @@ func RunClientTest(t *testing.T, cmds []*lcli.Command, clientNode test.TestNode)
|
|||||||
|
|
||||||
// Create a deal (non-interactive)
|
// Create a deal (non-interactive)
|
||||||
// client deal --start-epoch=<start epoch> <cid> <miner addr> 1000000attofil <duration>
|
// client deal --start-epoch=<start epoch> <cid> <miner addr> 1000000attofil <duration>
|
||||||
res, _, err := test.CreateClientFile(ctx, clientNode, 1)
|
res, _, err := CreateClientFile(ctx, clientNode, 1)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
startEpoch := fmt.Sprintf("--start-epoch=%d", 2<<12)
|
startEpoch := fmt.Sprintf("--start-epoch=%d", 2<<12)
|
||||||
dataCid := res.Root
|
dataCid := res.Root
|
||||||
@ -60,7 +59,7 @@ func RunClientTest(t *testing.T, cmds []*lcli.Command, clientNode test.TestNode)
|
|||||||
// <miner addr>
|
// <miner addr>
|
||||||
// "no" (verified client)
|
// "no" (verified client)
|
||||||
// "yes" (confirm deal)
|
// "yes" (confirm deal)
|
||||||
res, _, err = test.CreateClientFile(ctx, clientNode, 2)
|
res, _, err = CreateClientFile(ctx, clientNode, 2)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
dataCid2 := res.Root
|
dataCid2 := res.Root
|
||||||
duration = fmt.Sprintf("%d", build.MinDealDuration/builtin.EpochsInDay)
|
duration = fmt.Sprintf("%d", build.MinDealDuration/builtin.EpochsInDay)
|
@ -1,4 +1,4 @@
|
|||||||
package test
|
package itests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
@ -1,4 +1,4 @@
|
|||||||
package test
|
package itests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
@ -1,4 +1,4 @@
|
|||||||
package test
|
package itests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
@ -1,4 +1,4 @@
|
|||||||
package test
|
package itests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
@ -1,4 +1,4 @@
|
|||||||
package test
|
package itests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -1,4 +1,4 @@
|
|||||||
package cli
|
package itests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -6,17 +6,17 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
clitest "github.com/filecoin-project/lotus/cli/test"
|
"github.com/filecoin-project/lotus/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TestMultisig does a basic test to exercise the multisig CLI
|
// TestMultisig does a basic test to exercise the multisig CLI
|
||||||
// commands
|
// commands
|
||||||
func TestMultisig(t *testing.T) {
|
func TestMultisig(t *testing.T) {
|
||||||
_ = os.Setenv("BELLMAN_NO_GPU", "1")
|
_ = os.Setenv("BELLMAN_NO_GPU", "1")
|
||||||
clitest.QuietMiningLogs()
|
QuietMiningLogs()
|
||||||
|
|
||||||
blocktime := 5 * time.Millisecond
|
blocktime := 5 * time.Millisecond
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
clientNode, _ := clitest.StartOneNodeOneMiner(ctx, t, blocktime)
|
clientNode, _ := StartOneNodeOneMiner(ctx, t, blocktime)
|
||||||
clitest.RunMultisigTest(t, Commands, clientNode)
|
RunMultisigTest(t, cli.Commands, clientNode)
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package test
|
package itests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -13,8 +13,8 @@ import (
|
|||||||
test2 "github.com/filecoin-project/lotus/node/test"
|
test2 "github.com/filecoin-project/lotus/node/test"
|
||||||
)
|
)
|
||||||
|
|
||||||
func StartOneNodeOneMiner(ctx context.Context, t *testing.T, blocktime time.Duration) (test.TestNode, address.Address) {
|
func StartOneNodeOneMiner(ctx context.Context, t *testing.T, blocktime time.Duration) (TestNode, address.Address) {
|
||||||
n, sn := test2.RPCMockSbBuilder(t, test.OneFull, test.OneMiner)
|
n, sn := RPCMockSbBuilder(t, OneFull, OneMiner)
|
||||||
|
|
||||||
full := n[0]
|
full := n[0]
|
||||||
miner := sn[0]
|
miner := sn[0]
|
||||||
@ -30,7 +30,7 @@ func StartOneNodeOneMiner(ctx context.Context, t *testing.T, blocktime time.Dura
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start mining blocks
|
// Start mining blocks
|
||||||
bm := test.NewBlockMiner(ctx, t, miner, blocktime)
|
bm := NewBlockMiner(ctx, t, miner, blocktime)
|
||||||
bm.MineBlocks()
|
bm.MineBlocks()
|
||||||
t.Cleanup(bm.Stop)
|
t.Cleanup(bm.Stop)
|
||||||
|
|
||||||
@ -44,8 +44,8 @@ func StartOneNodeOneMiner(ctx context.Context, t *testing.T, blocktime time.Dura
|
|||||||
return full, fullAddr
|
return full, fullAddr
|
||||||
}
|
}
|
||||||
|
|
||||||
func StartTwoNodesOneMiner(ctx context.Context, t *testing.T, blocktime time.Duration) ([]test.TestNode, []address.Address) {
|
func StartTwoNodesOneMiner(ctx context.Context, t *testing.T, blocktime time.Duration) ([]TestNode, []address.Address) {
|
||||||
n, sn := test2.RPCMockSbBuilder(t, test.TwoFull, test.OneMiner)
|
n, sn := RPCMockSbBuilder(t, TwoFull, OneMiner)
|
||||||
|
|
||||||
fullNode1 := n[0]
|
fullNode1 := n[0]
|
||||||
fullNode2 := n[1]
|
fullNode2 := n[1]
|
@ -1,4 +1,4 @@
|
|||||||
package test
|
package itests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
@ -23,7 +23,6 @@ import (
|
|||||||
"github.com/filecoin-project/go-storedcounter"
|
"github.com/filecoin-project/go-storedcounter"
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/api/client"
|
"github.com/filecoin-project/lotus/api/client"
|
||||||
"github.com/filecoin-project/lotus/api/test"
|
|
||||||
"github.com/filecoin-project/lotus/api/v0api"
|
"github.com/filecoin-project/lotus/api/v0api"
|
||||||
"github.com/filecoin-project/lotus/api/v1api"
|
"github.com/filecoin-project/lotus/api/v1api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
@ -65,7 +64,7 @@ func init() {
|
|||||||
messagepool.HeadChangeCoalesceMergeInterval = 100 * time.Nanosecond
|
messagepool.HeadChangeCoalesceMergeInterval = 100 * time.Nanosecond
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateTestStorageNode(ctx context.Context, t *testing.T, waddr address.Address, act address.Address, pk crypto.PrivKey, tnd test.TestNode, mn mocknet.Mocknet, opts node.Option) test.TestStorageNode {
|
func CreateTestStorageNode(ctx context.Context, t *testing.T, waddr address.Address, act address.Address, pk crypto.PrivKey, tnd TestNode, mn mocknet.Mocknet, opts node.Option) TestStorageNode {
|
||||||
r := repo.NewMemory(nil)
|
r := repo.NewMemory(nil)
|
||||||
|
|
||||||
lr, err := r.Lock(repo.StorageMiner)
|
lr, err := r.Lock(repo.StorageMiner)
|
||||||
@ -89,7 +88,7 @@ func CreateTestStorageNode(ctx context.Context, t *testing.T, waddr address.Addr
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
nic := storedcounter.New(ds, datastore.NewKey(modules.StorageCounterDSPrefix))
|
nic := storedcounter.New(ds, datastore.NewKey(modules.StorageCounterDSPrefix))
|
||||||
for i := 0; i < test.GenesisPreseals; i++ {
|
for i := 0; i < GenesisPreseals; i++ {
|
||||||
_, err := nic.Next()
|
_, err := nic.Next()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
}
|
}
|
||||||
@ -154,11 +153,11 @@ func CreateTestStorageNode(ctx context.Context, t *testing.T, waddr address.Addr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return test.TestStorageNode{StorageMiner: minerapi, MineOne: mineOne, Stop: stop}
|
return TestStorageNode{StorageMiner: minerapi, MineOne: mineOne, Stop: stop}
|
||||||
}
|
}
|
||||||
|
|
||||||
func storageBuilder(parentNode test.TestNode, mn mocknet.Mocknet, opts node.Option) test.StorageBuilder {
|
func storageBuilder(parentNode TestNode, mn mocknet.Mocknet, opts node.Option) StorageBuilder {
|
||||||
return func(ctx context.Context, t *testing.T, spt abi.RegisteredSealProof, owner address.Address) test.TestStorageNode {
|
return func(ctx context.Context, t *testing.T, spt abi.RegisteredSealProof, owner address.Address) TestStorageNode {
|
||||||
pk, _, err := crypto.GenerateEd25519Key(rand.Reader)
|
pk, _, err := crypto.GenerateEd25519Key(rand.Reader)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
@ -200,30 +199,30 @@ func storageBuilder(parentNode test.TestNode, mn mocknet.Mocknet, opts node.Opti
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Builder(t *testing.T, fullOpts []test.FullNodeOpts, storage []test.StorageMiner) ([]test.TestNode, []test.TestStorageNode) {
|
func Builder(t *testing.T, fullOpts []FullNodeOpts, storage []StorageMiner) ([]TestNode, []TestStorageNode) {
|
||||||
return mockBuilderOpts(t, fullOpts, storage, false)
|
return mockBuilderOpts(t, fullOpts, storage, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func MockSbBuilder(t *testing.T, fullOpts []test.FullNodeOpts, storage []test.StorageMiner) ([]test.TestNode, []test.TestStorageNode) {
|
func MockSbBuilder(t *testing.T, fullOpts []FullNodeOpts, storage []StorageMiner) ([]TestNode, []TestStorageNode) {
|
||||||
return mockSbBuilderOpts(t, fullOpts, storage, false)
|
return mockSbBuilderOpts(t, fullOpts, storage, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RPCBuilder(t *testing.T, fullOpts []test.FullNodeOpts, storage []test.StorageMiner) ([]test.TestNode, []test.TestStorageNode) {
|
func RPCBuilder(t *testing.T, fullOpts []FullNodeOpts, storage []StorageMiner) ([]TestNode, []TestStorageNode) {
|
||||||
return mockBuilderOpts(t, fullOpts, storage, true)
|
return mockBuilderOpts(t, fullOpts, storage, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func RPCMockSbBuilder(t *testing.T, fullOpts []test.FullNodeOpts, storage []test.StorageMiner) ([]test.TestNode, []test.TestStorageNode) {
|
func RPCMockSbBuilder(t *testing.T, fullOpts []FullNodeOpts, storage []StorageMiner) ([]TestNode, []TestStorageNode) {
|
||||||
return mockSbBuilderOpts(t, fullOpts, storage, true)
|
return mockSbBuilderOpts(t, fullOpts, storage, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
func mockBuilderOpts(t *testing.T, fullOpts []test.FullNodeOpts, storage []test.StorageMiner, rpc bool) ([]test.TestNode, []test.TestStorageNode) {
|
func mockBuilderOpts(t *testing.T, fullOpts []FullNodeOpts, storage []StorageMiner, rpc bool) ([]TestNode, []TestStorageNode) {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
t.Cleanup(cancel)
|
t.Cleanup(cancel)
|
||||||
|
|
||||||
mn := mocknet.New(ctx)
|
mn := mocknet.New(ctx)
|
||||||
|
|
||||||
fulls := make([]test.TestNode, len(fullOpts))
|
fulls := make([]TestNode, len(fullOpts))
|
||||||
storers := make([]test.TestStorageNode, len(storage))
|
storers := make([]TestStorageNode, len(storage))
|
||||||
|
|
||||||
pk, _, err := crypto.GenerateEd25519Key(rand.Reader)
|
pk, _, err := crypto.GenerateEd25519Key(rand.Reader)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@ -254,7 +253,7 @@ func mockBuilderOpts(t *testing.T, fullOpts []test.FullNodeOpts, storage []test.
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
genm, k, err := seed.PreSeal(maddr, abi.RegisteredSealProof_StackedDrg2KiBV1, 0, test.GenesisPreseals, tdir, []byte("make genesis mem random"), nil, true)
|
genm, k, err := seed.PreSeal(maddr, abi.RegisteredSealProof_StackedDrg2KiBV1, 0, GenesisPreseals, tdir, []byte("make genesis mem random"), nil, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -366,12 +365,12 @@ func mockBuilderOpts(t *testing.T, fullOpts []test.FullNodeOpts, storage []test.
|
|||||||
var wait sync.Mutex
|
var wait sync.Mutex
|
||||||
wait.Lock()
|
wait.Lock()
|
||||||
|
|
||||||
test.MineUntilBlock(ctx, t, fulls[0], storers[0], func(epoch abi.ChainEpoch) {
|
MineUntilBlock(ctx, t, fulls[0], storers[0], func(epoch abi.ChainEpoch) {
|
||||||
wait.Unlock()
|
wait.Unlock()
|
||||||
})
|
})
|
||||||
|
|
||||||
wait.Lock()
|
wait.Lock()
|
||||||
test.MineUntilBlock(ctx, t, fulls[0], storers[0], func(epoch abi.ChainEpoch) {
|
MineUntilBlock(ctx, t, fulls[0], storers[0], func(epoch abi.ChainEpoch) {
|
||||||
wait.Unlock()
|
wait.Unlock()
|
||||||
})
|
})
|
||||||
wait.Lock()
|
wait.Lock()
|
||||||
@ -380,14 +379,14 @@ func mockBuilderOpts(t *testing.T, fullOpts []test.FullNodeOpts, storage []test.
|
|||||||
return fulls, storers
|
return fulls, storers
|
||||||
}
|
}
|
||||||
|
|
||||||
func mockSbBuilderOpts(t *testing.T, fullOpts []test.FullNodeOpts, storage []test.StorageMiner, rpc bool) ([]test.TestNode, []test.TestStorageNode) {
|
func mockSbBuilderOpts(t *testing.T, fullOpts []FullNodeOpts, storage []StorageMiner, rpc bool) ([]TestNode, []TestStorageNode) {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
t.Cleanup(cancel)
|
t.Cleanup(cancel)
|
||||||
|
|
||||||
mn := mocknet.New(ctx)
|
mn := mocknet.New(ctx)
|
||||||
|
|
||||||
fulls := make([]test.TestNode, len(fullOpts))
|
fulls := make([]TestNode, len(fullOpts))
|
||||||
storers := make([]test.TestStorageNode, len(storage))
|
storers := make([]TestStorageNode, len(storage))
|
||||||
|
|
||||||
var genbuf bytes.Buffer
|
var genbuf bytes.Buffer
|
||||||
|
|
||||||
@ -406,8 +405,8 @@ func mockSbBuilderOpts(t *testing.T, fullOpts []test.FullNodeOpts, storage []tes
|
|||||||
}
|
}
|
||||||
|
|
||||||
preseals := storage[i].Preseal
|
preseals := storage[i].Preseal
|
||||||
if preseals == test.PresealGenesis {
|
if preseals == PresealGenesis {
|
||||||
preseals = test.GenesisPreseals
|
preseals = GenesisPreseals
|
||||||
}
|
}
|
||||||
|
|
||||||
genm, k, err := mockstorage.PreSeal(abi.RegisteredSealProof_StackedDrg2KiBV1, maddr, preseals)
|
genm, k, err := mockstorage.PreSeal(abi.RegisteredSealProof_StackedDrg2KiBV1, maddr, preseals)
|
||||||
@ -545,11 +544,11 @@ func mockSbBuilderOpts(t *testing.T, fullOpts []test.FullNodeOpts, storage []tes
|
|||||||
var wait sync.Mutex
|
var wait sync.Mutex
|
||||||
wait.Lock()
|
wait.Lock()
|
||||||
|
|
||||||
test.MineUntilBlock(ctx, t, fulls[0], storers[0], func(abi.ChainEpoch) {
|
MineUntilBlock(ctx, t, fulls[0], storers[0], func(abi.ChainEpoch) {
|
||||||
wait.Unlock()
|
wait.Unlock()
|
||||||
})
|
})
|
||||||
wait.Lock()
|
wait.Lock()
|
||||||
test.MineUntilBlock(ctx, t, fulls[0], storers[0], func(abi.ChainEpoch) {
|
MineUntilBlock(ctx, t, fulls[0], storers[0], func(abi.ChainEpoch) {
|
||||||
wait.Unlock()
|
wait.Unlock()
|
||||||
})
|
})
|
||||||
wait.Lock()
|
wait.Lock()
|
||||||
@ -558,7 +557,7 @@ func mockSbBuilderOpts(t *testing.T, fullOpts []test.FullNodeOpts, storage []tes
|
|||||||
return fulls, storers
|
return fulls, storers
|
||||||
}
|
}
|
||||||
|
|
||||||
func fullRpc(t *testing.T, nd test.TestNode) test.TestNode {
|
func fullRpc(t *testing.T, nd TestNode) TestNode {
|
||||||
ma, listenAddr, err := CreateRPCServer(t, map[string]interface{}{
|
ma, listenAddr, err := CreateRPCServer(t, map[string]interface{}{
|
||||||
"/rpc/v1": nd,
|
"/rpc/v1": nd,
|
||||||
"/rpc/v0": &v0api.WrapperV1Full{FullNode: nd},
|
"/rpc/v0": &v0api.WrapperV1Full{FullNode: nd},
|
||||||
@ -566,7 +565,7 @@ func fullRpc(t *testing.T, nd test.TestNode) test.TestNode {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
var stop func()
|
var stop func()
|
||||||
var full test.TestNode
|
var full TestNode
|
||||||
full.FullNode, stop, err = client.NewFullNodeRPCV1(context.Background(), listenAddr+"/rpc/v1", nil)
|
full.FullNode, stop, err = client.NewFullNodeRPCV1(context.Background(), listenAddr+"/rpc/v1", nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
t.Cleanup(stop)
|
t.Cleanup(stop)
|
||||||
@ -575,14 +574,14 @@ func fullRpc(t *testing.T, nd test.TestNode) test.TestNode {
|
|||||||
return full
|
return full
|
||||||
}
|
}
|
||||||
|
|
||||||
func storerRpc(t *testing.T, nd test.TestStorageNode) test.TestStorageNode {
|
func storerRpc(t *testing.T, nd TestStorageNode) TestStorageNode {
|
||||||
ma, listenAddr, err := CreateRPCServer(t, map[string]interface{}{
|
ma, listenAddr, err := CreateRPCServer(t, map[string]interface{}{
|
||||||
"/rpc/v0": nd,
|
"/rpc/v0": nd,
|
||||||
})
|
})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
var stop func()
|
var stop func()
|
||||||
var storer test.TestStorageNode
|
var storer TestStorageNode
|
||||||
storer.StorageMiner, stop, err = client.NewStorageMinerRPCV0(context.Background(), listenAddr+"/rpc/v0", nil)
|
storer.StorageMiner, stop, err = client.NewStorageMinerRPCV0(context.Background(), listenAddr+"/rpc/v0", nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
t.Cleanup(stop)
|
t.Cleanup(stop)
|
||||||
@ -599,7 +598,7 @@ func CreateRPCServer(t *testing.T, handlers map[string]interface{}) (multiaddr.M
|
|||||||
rpcServer.Register("Filecoin", handler)
|
rpcServer.Register("Filecoin", handler)
|
||||||
m.Handle(path, rpcServer)
|
m.Handle(path, rpcServer)
|
||||||
}
|
}
|
||||||
testServ := httptest.NewServer(m) // todo: close
|
testServ := httpNewServer(m) // todo: close
|
||||||
t.Cleanup(testServ.Close)
|
t.Cleanup(testServ.Close)
|
||||||
t.Cleanup(testServ.CloseClientConnections)
|
t.Cleanup(testServ.CloseClientConnections)
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package node_test
|
package itests_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
@ -183,7 +183,7 @@ func TestWindowedPost(t *testing.T) {
|
|||||||
logging.SetLogLevel("sub", "ERROR")
|
logging.SetLogLevel("sub", "ERROR")
|
||||||
logging.SetLogLevel("storageminer", "ERROR")
|
logging.SetLogLevel("storageminer", "ERROR")
|
||||||
|
|
||||||
test.TestWindowPost(t, builder.MockSbBuilder, 2*time.Millisecond, 10)
|
TestWindowPost(t, builder.MockSbBuilder, 2*time.Millisecond, 10)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTerminate(t *testing.T) {
|
func TestTerminate(t *testing.T) {
|
||||||
@ -197,7 +197,7 @@ func TestTerminate(t *testing.T) {
|
|||||||
logging.SetLogLevel("sub", "ERROR")
|
logging.SetLogLevel("sub", "ERROR")
|
||||||
logging.SetLogLevel("storageminer", "ERROR")
|
logging.SetLogLevel("storageminer", "ERROR")
|
||||||
|
|
||||||
test.TestTerminate(t, builder.MockSbBuilder, 2*time.Millisecond)
|
TestTerminate(t, builder.MockSbBuilder, 2*time.Millisecond)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCCUpgrade(t *testing.T) {
|
func TestCCUpgrade(t *testing.T) {
|
@ -1,4 +1,4 @@
|
|||||||
package test
|
package itests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -1,4 +1,4 @@
|
|||||||
package cli
|
package itests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -10,6 +10,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/cli"
|
||||||
clitest "github.com/filecoin-project/lotus/cli/test"
|
clitest "github.com/filecoin-project/lotus/cli/test"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
@ -37,18 +38,18 @@ func init() {
|
|||||||
// commands
|
// commands
|
||||||
func TestPaymentChannels(t *testing.T) {
|
func TestPaymentChannels(t *testing.T) {
|
||||||
_ = os.Setenv("BELLMAN_NO_GPU", "1")
|
_ = os.Setenv("BELLMAN_NO_GPU", "1")
|
||||||
clitest.QuietMiningLogs()
|
QuietMiningLogs()
|
||||||
|
|
||||||
blocktime := 5 * time.Millisecond
|
blocktime := 5 * time.Millisecond
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
nodes, addrs := clitest.StartTwoNodesOneMiner(ctx, t, blocktime)
|
nodes, addrs := StartTwoNodesOneMiner(ctx, t, blocktime)
|
||||||
paymentCreator := nodes[0]
|
paymentCreator := nodes[0]
|
||||||
paymentReceiver := nodes[1]
|
paymentReceiver := nodes[1]
|
||||||
creatorAddr := addrs[0]
|
creatorAddr := addrs[0]
|
||||||
receiverAddr := addrs[1]
|
receiverAddr := addrs[1]
|
||||||
|
|
||||||
// Create mock CLI
|
// Create mock CLI
|
||||||
mockCLI := clitest.NewMockCLI(ctx, t, Commands)
|
mockCLI := NewMockCLI(ctx, t, cli.Commands)
|
||||||
creatorCLI := mockCLI.Client(paymentCreator.ListenAddr)
|
creatorCLI := mockCLI.Client(paymentCreator.ListenAddr)
|
||||||
receiverCLI := mockCLI.Client(paymentReceiver.ListenAddr)
|
receiverCLI := mockCLI.Client(paymentReceiver.ListenAddr)
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package test
|
package itests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -1,4 +1,4 @@
|
|||||||
package test
|
package itests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -1,4 +1,4 @@
|
|||||||
package test
|
package itests
|
||||||
|
|
||||||
import "github.com/ipfs/go-log/v2"
|
import "github.com/ipfs/go-log/v2"
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package test
|
package itests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
@ -1,12 +1,11 @@
|
|||||||
package test
|
package itests
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
"sync/atomic"
|
|
||||||
|
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync/atomic"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -5,7 +5,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
xerrors "golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-state-types/big"
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
@ -13,7 +13,7 @@ import (
|
|||||||
"github.com/libp2p/go-libp2p-core/host"
|
"github.com/libp2p/go-libp2p-core/host"
|
||||||
inet "github.com/libp2p/go-libp2p-core/network"
|
inet "github.com/libp2p/go-libp2p-core/network"
|
||||||
"github.com/libp2p/go-libp2p-core/peer"
|
"github.com/libp2p/go-libp2p-core/peer"
|
||||||
protocol "github.com/libp2p/go-libp2p-core/protocol"
|
"github.com/libp2p/go-libp2p-core/protocol"
|
||||||
|
|
||||||
cborutil "github.com/filecoin-project/go-cbor-util"
|
cborutil "github.com/filecoin-project/go-cbor-util"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
@ -23,6 +23,8 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/lib/peermgr"
|
"github.com/filecoin-project/lotus/lib/peermgr"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// TODO(TEST): missing test coverage.
|
||||||
|
|
||||||
const ProtocolID = "/fil/hello/1.0.0"
|
const ProtocolID = "/fil/hello/1.0.0"
|
||||||
|
|
||||||
var log = logging.Logger("hello")
|
var log = logging.Logger("hello")
|
||||||
@ -33,12 +35,14 @@ type HelloMessage struct {
|
|||||||
HeaviestTipSetWeight big.Int
|
HeaviestTipSetWeight big.Int
|
||||||
GenesisHash cid.Cid
|
GenesisHash cid.Cid
|
||||||
}
|
}
|
||||||
|
|
||||||
type LatencyMessage struct {
|
type LatencyMessage struct {
|
||||||
TArrival int64
|
TArrival int64
|
||||||
TSent int64
|
TSent int64
|
||||||
}
|
}
|
||||||
|
|
||||||
type NewStreamFunc func(context.Context, peer.ID, ...protocol.ID) (inet.Stream, error)
|
type NewStreamFunc func(context.Context, peer.ID, ...protocol.ID) (inet.Stream, error)
|
||||||
|
|
||||||
type Service struct {
|
type Service struct {
|
||||||
h host.Host
|
h host.Host
|
||||||
|
|
||||||
@ -62,7 +66,6 @@ func NewHelloService(h host.Host, cs *store.ChainStore, syncer *chain.Syncer, pm
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (hs *Service) HandleStream(s inet.Stream) {
|
func (hs *Service) HandleStream(s inet.Stream) {
|
||||||
|
|
||||||
var hmsg HelloMessage
|
var hmsg HelloMessage
|
||||||
if err := cborutil.ReadCborRPC(s, &hmsg); err != nil {
|
if err := cborutil.ReadCborRPC(s, &hmsg); err != nil {
|
||||||
log.Infow("failed to read hello message, disconnecting", "error", err)
|
log.Infow("failed to read hello message, disconnecting", "error", err)
|
||||||
@ -121,7 +124,6 @@ func (hs *Service) HandleStream(s inet.Stream) {
|
|||||||
log.Debugf("Got new tipset through Hello: %s from %s", ts.Cids(), s.Conn().RemotePeer())
|
log.Debugf("Got new tipset through Hello: %s from %s", ts.Cids(), s.Conn().RemotePeer())
|
||||||
hs.syncer.InformNewHead(s.Conn().RemotePeer(), ts)
|
hs.syncer.InformNewHead(s.Conn().RemotePeer(), ts)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hs *Service) SayHello(ctx context.Context, pid peer.ID) error {
|
func (hs *Service) SayHello(ctx context.Context, pid peer.ID) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user