From c46d4ae52985be7b13f972835f38f5f404a97b03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Kripalani?= Date: Mon, 17 May 2021 13:28:09 +0100 Subject: [PATCH] wip --- cli/client_test.go | 22 ------- {api/test => itests}/blockminer.go | 3 +- {api/test => itests}/ccupgrade.go | 6 +- itests/cliclient_test.go | 21 +++++++ {cli/test => itests}/client.go | 9 ++- {api/test => itests}/deadlines.go | 2 +- {api/test => itests}/deals.go | 2 +- {api/test => itests}/mining.go | 2 +- {cli/test => itests}/mockcli.go | 2 +- {cli/test => itests}/multisig.go | 2 +- {cli => itests}/multisig_test.go | 10 ++-- {cli/test => itests}/net.go | 12 ++-- .../test/builder.go => itests/node_builder.go | 57 +++++++++---------- {node => itests}/node_test.go | 6 +- {api/test => itests}/paych.go | 2 +- {cli => itests}/paych_test.go | 9 +-- {api/test => itests}/tape.go | 2 +- {api/test => itests}/test.go | 2 +- {cli/test => itests}/util.go | 2 +- api/test/util.go => itests/util2.go | 2 +- {api/test => itests}/window_post.go | 5 +- node/hello/hello.go | 10 ++-- 22 files changed, 95 insertions(+), 95 deletions(-) delete mode 100644 cli/client_test.go rename {api/test => itests}/blockminer.go (93%) rename {api/test => itests}/ccupgrade.go (94%) create mode 100644 itests/cliclient_test.go rename {cli/test => itests}/client.go (94%) rename {api/test => itests}/deadlines.go (99%) rename {api/test => itests}/deals.go (99%) rename {api/test => itests}/mining.go (99%) rename {cli/test => itests}/mockcli.go (99%) rename {cli/test => itests}/multisig.go (99%) rename {cli => itests}/multisig_test.go (55%) rename {cli/test => itests}/net.go (84%) rename node/test/builder.go => itests/node_builder.go (87%) rename {node => itests}/node_test.go (98%) rename {api/test => itests}/paych.go (99%) rename {cli => itests}/paych_test.go (98%) rename {api/test => itests}/tape.go (99%) rename {api/test => itests}/test.go (99%) rename {cli/test => itests}/util.go (96%) rename api/test/util.go => itests/util2.go (99%) rename {api/test => itests}/window_post.go (99%) diff --git a/cli/client_test.go b/cli/client_test.go deleted file mode 100644 index f0e8efda8..000000000 --- a/cli/client_test.go +++ /dev/null @@ -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) -} diff --git a/api/test/blockminer.go b/itests/blockminer.go similarity index 93% rename from api/test/blockminer.go rename to itests/blockminer.go index 23af94a36..8418634e9 100644 --- a/api/test/blockminer.go +++ b/itests/blockminer.go @@ -1,4 +1,4 @@ -package test +package itests import ( "context" @@ -11,6 +11,7 @@ import ( "github.com/filecoin-project/lotus/miner" ) +// BlockMiner is a utility that makes a test miner mine blocks on a timer. type BlockMiner struct { ctx context.Context t *testing.T diff --git a/api/test/ccupgrade.go b/itests/ccupgrade.go similarity index 94% rename from api/test/ccupgrade.go rename to itests/ccupgrade.go index 283c8f610..dd8d17d90 100644 --- a/api/test/ccupgrade.go +++ b/itests/ccupgrade.go @@ -1,4 +1,4 @@ -package test +package itests import ( "context" @@ -24,12 +24,12 @@ func TestCCUpgrade(t *testing.T, b APIBuilder, blocktime time.Duration) { } { height := height // make linters happy by copying 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() n, sn := b(t, []FullNodeOpts{FullNodeWithLatestActorsAt(upgradeHeight)}, OneMiner) client := n[0].FullNode.(*impl.FullNodeAPI) diff --git a/itests/cliclient_test.go b/itests/cliclient_test.go new file mode 100644 index 000000000..864e332b1 --- /dev/null +++ b/itests/cliclient_test.go @@ -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) +} diff --git a/cli/test/client.go b/itests/client.go similarity index 94% rename from cli/test/client.go rename to itests/client.go index 4a49f732a..1a9380a44 100644 --- a/cli/test/client.go +++ b/itests/client.go @@ -1,4 +1,4 @@ -package test +package itests import ( "context" @@ -13,7 +13,6 @@ import ( "golang.org/x/xerrors" - "github.com/filecoin-project/lotus/api/test" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/types" "github.com/filecoin-project/specs-actors/v2/actors/builtin" @@ -22,7 +21,7 @@ import ( ) // 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) defer cancel() @@ -44,7 +43,7 @@ func RunClientTest(t *testing.T, cmds []*lcli.Command, clientNode test.TestNode) // Create a deal (non-interactive) // client deal --start-epoch= 1000000attofil - res, _, err := test.CreateClientFile(ctx, clientNode, 1) + res, _, err := CreateClientFile(ctx, clientNode, 1) require.NoError(t, err) startEpoch := fmt.Sprintf("--start-epoch=%d", 2<<12) dataCid := res.Root @@ -60,7 +59,7 @@ func RunClientTest(t *testing.T, cmds []*lcli.Command, clientNode test.TestNode) // // "no" (verified client) // "yes" (confirm deal) - res, _, err = test.CreateClientFile(ctx, clientNode, 2) + res, _, err = CreateClientFile(ctx, clientNode, 2) require.NoError(t, err) dataCid2 := res.Root duration = fmt.Sprintf("%d", build.MinDealDuration/builtin.EpochsInDay) diff --git a/api/test/deadlines.go b/itests/deadlines.go similarity index 99% rename from api/test/deadlines.go rename to itests/deadlines.go index 43fa731be..4d62b5d07 100644 --- a/api/test/deadlines.go +++ b/itests/deadlines.go @@ -1,4 +1,4 @@ -package test +package itests import ( "bytes" diff --git a/api/test/deals.go b/itests/deals.go similarity index 99% rename from api/test/deals.go rename to itests/deals.go index 7a9454bae..63e2d14c8 100644 --- a/api/test/deals.go +++ b/itests/deals.go @@ -1,4 +1,4 @@ -package test +package itests import ( "bytes" diff --git a/api/test/mining.go b/itests/mining.go similarity index 99% rename from api/test/mining.go rename to itests/mining.go index 4a4f1e1a4..b53e63a63 100644 --- a/api/test/mining.go +++ b/itests/mining.go @@ -1,4 +1,4 @@ -package test +package itests import ( "bytes" diff --git a/cli/test/mockcli.go b/itests/mockcli.go similarity index 99% rename from cli/test/mockcli.go rename to itests/mockcli.go index aef7808c8..fa9a89036 100644 --- a/cli/test/mockcli.go +++ b/itests/mockcli.go @@ -1,4 +1,4 @@ -package test +package itests import ( "bytes" diff --git a/cli/test/multisig.go b/itests/multisig.go similarity index 99% rename from cli/test/multisig.go rename to itests/multisig.go index 5a60894e6..5f94a5028 100644 --- a/cli/test/multisig.go +++ b/itests/multisig.go @@ -1,4 +1,4 @@ -package test +package itests import ( "context" diff --git a/cli/multisig_test.go b/itests/multisig_test.go similarity index 55% rename from cli/multisig_test.go rename to itests/multisig_test.go index 82472cd62..e285c3955 100644 --- a/cli/multisig_test.go +++ b/itests/multisig_test.go @@ -1,4 +1,4 @@ -package cli +package itests import ( "context" @@ -6,17 +6,17 @@ import ( "testing" "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 // commands func TestMultisig(t *testing.T) { _ = os.Setenv("BELLMAN_NO_GPU", "1") - clitest.QuietMiningLogs() + QuietMiningLogs() blocktime := 5 * time.Millisecond ctx := context.Background() - clientNode, _ := clitest.StartOneNodeOneMiner(ctx, t, blocktime) - clitest.RunMultisigTest(t, Commands, clientNode) + clientNode, _ := StartOneNodeOneMiner(ctx, t, blocktime) + RunMultisigTest(t, cli.Commands, clientNode) } diff --git a/cli/test/net.go b/itests/net.go similarity index 84% rename from cli/test/net.go rename to itests/net.go index 8e45e3aed..315aab267 100644 --- a/cli/test/net.go +++ b/itests/net.go @@ -1,4 +1,4 @@ -package test +package itests import ( "context" @@ -13,8 +13,8 @@ import ( 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) +func StartOneNodeOneMiner(ctx context.Context, t *testing.T, blocktime time.Duration) (TestNode, address.Address) { + n, sn := RPCMockSbBuilder(t, OneFull, OneMiner) full := n[0] miner := sn[0] @@ -30,7 +30,7 @@ func StartOneNodeOneMiner(ctx context.Context, t *testing.T, blocktime time.Dura } // Start mining blocks - bm := test.NewBlockMiner(ctx, t, miner, blocktime) + bm := NewBlockMiner(ctx, t, miner, blocktime) bm.MineBlocks() t.Cleanup(bm.Stop) @@ -44,8 +44,8 @@ func StartOneNodeOneMiner(ctx context.Context, t *testing.T, blocktime time.Dura return full, fullAddr } -func StartTwoNodesOneMiner(ctx context.Context, t *testing.T, blocktime time.Duration) ([]test.TestNode, []address.Address) { - n, sn := test2.RPCMockSbBuilder(t, test.TwoFull, test.OneMiner) +func StartTwoNodesOneMiner(ctx context.Context, t *testing.T, blocktime time.Duration) ([]TestNode, []address.Address) { + n, sn := RPCMockSbBuilder(t, TwoFull, OneMiner) fullNode1 := n[0] fullNode2 := n[1] diff --git a/node/test/builder.go b/itests/node_builder.go similarity index 87% rename from node/test/builder.go rename to itests/node_builder.go index 7e26966a8..3b3cacb2a 100644 --- a/node/test/builder.go +++ b/itests/node_builder.go @@ -1,4 +1,4 @@ -package test +package itests import ( "bytes" @@ -23,7 +23,6 @@ import ( "github.com/filecoin-project/go-storedcounter" "github.com/filecoin-project/lotus/api" "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/v1api" "github.com/filecoin-project/lotus/build" @@ -65,7 +64,7 @@ func init() { 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) 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) nic := storedcounter.New(ds, datastore.NewKey(modules.StorageCounterDSPrefix)) - for i := 0; i < test.GenesisPreseals; i++ { + for i := 0; i < GenesisPreseals; i++ { _, err := nic.Next() 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 { - return func(ctx context.Context, t *testing.T, spt abi.RegisteredSealProof, owner address.Address) test.TestStorageNode { +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) TestStorageNode { pk, _, err := crypto.GenerateEd25519Key(rand.Reader) 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) } -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) } -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) } -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) } -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()) t.Cleanup(cancel) mn := mocknet.New(ctx) - fulls := make([]test.TestNode, len(fullOpts)) - storers := make([]test.TestStorageNode, len(storage)) + fulls := make([]TestNode, len(fullOpts)) + storers := make([]TestStorageNode, len(storage)) pk, _, err := crypto.GenerateEd25519Key(rand.Reader) require.NoError(t, err) @@ -254,7 +253,7 @@ func mockBuilderOpts(t *testing.T, fullOpts []test.FullNodeOpts, storage []test. if err != nil { 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 { t.Fatal(err) } @@ -366,12 +365,12 @@ func mockBuilderOpts(t *testing.T, fullOpts []test.FullNodeOpts, storage []test. var wait sync.Mutex 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.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.Lock() @@ -380,14 +379,14 @@ func mockBuilderOpts(t *testing.T, fullOpts []test.FullNodeOpts, storage []test. 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()) t.Cleanup(cancel) mn := mocknet.New(ctx) - fulls := make([]test.TestNode, len(fullOpts)) - storers := make([]test.TestStorageNode, len(storage)) + fulls := make([]TestNode, len(fullOpts)) + storers := make([]TestStorageNode, len(storage)) var genbuf bytes.Buffer @@ -406,8 +405,8 @@ func mockSbBuilderOpts(t *testing.T, fullOpts []test.FullNodeOpts, storage []tes } preseals := storage[i].Preseal - if preseals == test.PresealGenesis { - preseals = test.GenesisPreseals + if preseals == PresealGenesis { + preseals = GenesisPreseals } 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 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.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.Lock() @@ -558,7 +557,7 @@ func mockSbBuilderOpts(t *testing.T, fullOpts []test.FullNodeOpts, storage []tes 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{}{ "/rpc/v1": 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) var stop func() - var full test.TestNode + var full TestNode full.FullNode, stop, err = client.NewFullNodeRPCV1(context.Background(), listenAddr+"/rpc/v1", nil) require.NoError(t, err) t.Cleanup(stop) @@ -575,14 +574,14 @@ func fullRpc(t *testing.T, nd test.TestNode) test.TestNode { 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{}{ "/rpc/v0": nd, }) require.NoError(t, err) var stop func() - var storer test.TestStorageNode + var storer TestStorageNode storer.StorageMiner, stop, err = client.NewStorageMinerRPCV0(context.Background(), listenAddr+"/rpc/v0", nil) require.NoError(t, err) t.Cleanup(stop) @@ -599,7 +598,7 @@ func CreateRPCServer(t *testing.T, handlers map[string]interface{}) (multiaddr.M rpcServer.Register("Filecoin", handler) m.Handle(path, rpcServer) } - testServ := httptest.NewServer(m) // todo: close + testServ := httpNewServer(m) // todo: close t.Cleanup(testServ.Close) t.Cleanup(testServ.CloseClientConnections) diff --git a/node/node_test.go b/itests/node_test.go similarity index 98% rename from node/node_test.go rename to itests/node_test.go index 45a5b7f57..0b01ab660 100644 --- a/node/node_test.go +++ b/itests/node_test.go @@ -1,4 +1,4 @@ -package node_test +package itests_test import ( "os" @@ -183,7 +183,7 @@ func TestWindowedPost(t *testing.T) { logging.SetLogLevel("sub", "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) { @@ -197,7 +197,7 @@ func TestTerminate(t *testing.T) { logging.SetLogLevel("sub", "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) { diff --git a/api/test/paych.go b/itests/paych.go similarity index 99% rename from api/test/paych.go rename to itests/paych.go index 93a083c4a..86b4063ea 100644 --- a/api/test/paych.go +++ b/itests/paych.go @@ -1,4 +1,4 @@ -package test +package itests import ( "context" diff --git a/cli/paych_test.go b/itests/paych_test.go similarity index 98% rename from cli/paych_test.go rename to itests/paych_test.go index 44d0a41e7..6c7a081fe 100644 --- a/cli/paych_test.go +++ b/itests/paych_test.go @@ -1,4 +1,4 @@ -package cli +package itests import ( "context" @@ -10,6 +10,7 @@ import ( "testing" "time" + "github.com/filecoin-project/lotus/cli" clitest "github.com/filecoin-project/lotus/cli/test" "github.com/filecoin-project/go-address" @@ -37,18 +38,18 @@ func init() { // commands func TestPaymentChannels(t *testing.T) { _ = os.Setenv("BELLMAN_NO_GPU", "1") - clitest.QuietMiningLogs() + QuietMiningLogs() blocktime := 5 * time.Millisecond ctx := context.Background() - nodes, addrs := clitest.StartTwoNodesOneMiner(ctx, t, blocktime) + nodes, addrs := StartTwoNodesOneMiner(ctx, t, blocktime) paymentCreator := nodes[0] paymentReceiver := nodes[1] creatorAddr := addrs[0] receiverAddr := addrs[1] // Create mock CLI - mockCLI := clitest.NewMockCLI(ctx, t, Commands) + mockCLI := NewMockCLI(ctx, t, cli.Commands) creatorCLI := mockCLI.Client(paymentCreator.ListenAddr) receiverCLI := mockCLI.Client(paymentReceiver.ListenAddr) diff --git a/api/test/tape.go b/itests/tape.go similarity index 99% rename from api/test/tape.go rename to itests/tape.go index 74206a97a..44cc20c68 100644 --- a/api/test/tape.go +++ b/itests/tape.go @@ -1,4 +1,4 @@ -package test +package itests import ( "context" diff --git a/api/test/test.go b/itests/test.go similarity index 99% rename from api/test/test.go rename to itests/test.go index d09827f5e..2664bc626 100644 --- a/api/test/test.go +++ b/itests/test.go @@ -1,4 +1,4 @@ -package test +package itests import ( "context" diff --git a/cli/test/util.go b/itests/util.go similarity index 96% rename from cli/test/util.go rename to itests/util.go index d7959b9d5..9fbc3e395 100644 --- a/cli/test/util.go +++ b/itests/util.go @@ -1,4 +1,4 @@ -package test +package itests import "github.com/ipfs/go-log/v2" diff --git a/api/test/util.go b/itests/util2.go similarity index 99% rename from api/test/util.go rename to itests/util2.go index 219dcf9ed..174499ef7 100644 --- a/api/test/util.go +++ b/itests/util2.go @@ -1,4 +1,4 @@ -package test +package itests import ( "context" diff --git a/api/test/window_post.go b/itests/window_post.go similarity index 99% rename from api/test/window_post.go rename to itests/window_post.go index bb5010b25..4b021a9fe 100644 --- a/api/test/window_post.go +++ b/itests/window_post.go @@ -1,12 +1,11 @@ -package test +package itests import ( "context" "fmt" "sort" - "sync/atomic" - "strings" + "sync/atomic" "testing" "time" diff --git a/node/hello/hello.go b/node/hello/hello.go index d4c631206..a71f9378c 100644 --- a/node/hello/hello.go +++ b/node/hello/hello.go @@ -5,7 +5,7 @@ import ( "time" "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/ipfs/go-cid" @@ -13,7 +13,7 @@ import ( "github.com/libp2p/go-libp2p-core/host" inet "github.com/libp2p/go-libp2p-core/network" "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" "github.com/filecoin-project/lotus/build" @@ -23,6 +23,8 @@ import ( "github.com/filecoin-project/lotus/lib/peermgr" ) +// TODO(TEST): missing test coverage. + const ProtocolID = "/fil/hello/1.0.0" var log = logging.Logger("hello") @@ -33,12 +35,14 @@ type HelloMessage struct { HeaviestTipSetWeight big.Int GenesisHash cid.Cid } + type LatencyMessage struct { TArrival int64 TSent int64 } type NewStreamFunc func(context.Context, peer.ID, ...protocol.ID) (inet.Stream, error) + type Service struct { 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) { - var hmsg HelloMessage if err := cborutil.ReadCborRPC(s, &hmsg); err != nil { 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()) hs.syncer.InformNewHead(s.Conn().RemotePeer(), ts) } - } func (hs *Service) SayHello(ctx context.Context, pid peer.ID) error {