diff --git a/node/config/def_test.go b/node/config/def_test.go index d45bc6ec8f3..6b4546c5a6c 100644 --- a/node/config/def_test.go +++ b/node/config/def_test.go @@ -24,6 +24,7 @@ func TestDefaultFullNodeRoundtrip(t *testing.T) { s = buf.String() } + //stm: @NODE_CONFIG_003 c2, err := FromReader(strings.NewReader(s), DefaultFullNode()) require.NoError(t, err) @@ -45,6 +46,7 @@ func TestDefaultMinerRoundtrip(t *testing.T) { s = buf.String() } + //stm: @NODE_CONFIG_004 c2, err := FromReader(strings.NewReader(s), DefaultStorageMiner()) require.NoError(t, err) diff --git a/node/config/load_test.go b/node/config/load_test.go index 9abe8a54b7b..c8e8aef194d 100644 --- a/node/config/load_test.go +++ b/node/config/load_test.go @@ -1,3 +1,4 @@ +//stm: #unit package config import ( @@ -14,6 +15,7 @@ func TestDecodeNothing(t *testing.T) { assert := assert.New(t) { + //stm: @NODE_CONFIG_001 cfg, err := FromFile(os.DevNull, DefaultFullNode()) assert.Nil(err, "error should be nil") assert.Equal(DefaultFullNode(), cfg, @@ -21,6 +23,7 @@ func TestDecodeNothing(t *testing.T) { } { + //stm: @NODE_CONFIG_002 cfg, err := FromFile("./does-not-exist.toml", DefaultFullNode()) assert.Nil(err, "error should be nil") assert.Equal(DefaultFullNode(), cfg, diff --git a/node/impl/client/client_test.go b/node/impl/client/client_test.go index 834c980ab14..642ae572a23 100644 --- a/node/impl/client/client_test.go +++ b/node/impl/client/client_test.go @@ -1,3 +1,4 @@ +//stm: #unit package client import ( @@ -44,10 +45,12 @@ func TestImportLocal(t *testing.T) { b, err := testdata.ReadFile("testdata/payload.txt") require.NoError(t, err) + //stm: @CLIENT_IMPORT_003 root, err := a.ClientImportLocal(ctx, bytes.NewReader(b)) require.NoError(t, err) require.NotEqual(t, cid.Undef, root) + //stm: @CLIENT_IMPORT_004 list, err := a.ClientListImports(ctx) require.NoError(t, err) require.Len(t, list, 1) @@ -68,6 +71,7 @@ func TestImportLocal(t *testing.T) { // retrieve as UnixFS. out1 := filepath.Join(dir, "retrieval1.data") // as unixfs out2 := filepath.Join(dir, "retrieval2.data") // as car + //stm: @CLIENT_IMPORT_005 err = a.ClientRetrieve(ctx, order, &api.FileRef{ Path: out1, }) @@ -84,6 +88,7 @@ func TestImportLocal(t *testing.T) { require.NoError(t, err) // open the CARv2 being custodied by the import manager + //stm: @CLIENT_IMPORT_006 orig, err := carv2.OpenReader(it.CARPath) require.NoError(t, err) @@ -94,6 +99,7 @@ func TestImportLocal(t *testing.T) { require.EqualValues(t, 1, exported.Version) require.EqualValues(t, 2, orig.Version) + //stm: @CLIENT_IMPORT_007 origRoots, err := orig.Roots() require.NoError(t, err) require.Len(t, origRoots, 1) diff --git a/node/impl/client/import_test.go b/node/impl/client/import_test.go index adf6531d088..93041d22e8c 100644 --- a/node/impl/client/import_test.go +++ b/node/impl/client/import_test.go @@ -1,3 +1,4 @@ +//stm: #unit package client import ( @@ -35,11 +36,13 @@ func TestRoundtripUnixFS_Dense(t *testing.T) { defer os.Remove(carv2File) //nolint:errcheck // import a file to a Unixfs DAG using a CARv2 read/write blockstore. + //stm: @CLIENT_IMPORT_001, @CLIENT_BLOCKSTORE_001 bs, err := blockstore.OpenReadWrite(carv2File, nil, carv2.ZeroLengthSectionAsEOF(true), blockstore.UseWholeCIDs(true)) require.NoError(t, err) + //stm: @CLIENT_IMPORT_001 root, err := buildUnixFS(ctx, bytes.NewBuffer(inputContents), bs, false) require.NoError(t, err) require.NotEqual(t, cid.Undef, root) @@ -85,11 +88,13 @@ func TestRoundtripUnixFS_Filestore(t *testing.T) { dst := newTmpFile(t) defer os.Remove(dst) //nolint:errcheck + //stm: @CLIENT_FS_001 root, err := a.createUnixFSFilestore(ctx, inputPath, dst) require.NoError(t, err) require.NotEqual(t, cid.Undef, root) // convert the CARv2 to a normal file again and ensure the contents match + //stm: @CLIENT_FS_002 fs, err := stores.ReadOnlyFilestore(dst) require.NoError(t, err) defer fs.Close() //nolint:errcheck @@ -116,6 +121,7 @@ func TestRoundtripUnixFS_Filestore(t *testing.T) { } func newTmpFile(t *testing.T) string { + //stm: @CLIENT_FS_003 f, err := os.CreateTemp("", "") require.NoError(t, err) require.NoError(t, f.Close()) @@ -123,6 +129,7 @@ func newTmpFile(t *testing.T) string { } func genInputFile(t *testing.T) (filepath string, contents []byte) { + //stm: @CLIENT_FS_004 s := strings.Repeat("abcde", 100) tmp, err := os.CreateTemp("", "") require.NoError(t, err) diff --git a/node/impl/full/gas_test.go b/node/impl/full/gas_test.go index 028e039ce4f..854a2c4798d 100644 --- a/node/impl/full/gas_test.go +++ b/node/impl/full/gas_test.go @@ -1,3 +1,4 @@ +//stm: #unit package full import ( @@ -12,6 +13,7 @@ import ( ) func TestMedian(t *testing.T) { + //stm: @REPO_GAS_001 require.Equal(t, types.NewInt(5), medianGasPremium([]GasMeta{ {big.NewInt(5), build.BlockGasTarget}, }, 1)) diff --git a/node/repo/fsrepo_test.go b/node/repo/fsrepo_test.go index bd03cc084ea..dcf44778b9d 100644 --- a/node/repo/fsrepo_test.go +++ b/node/repo/fsrepo_test.go @@ -1,3 +1,4 @@ +//stm: #unit package repo import ( @@ -12,11 +13,13 @@ func genFsRepo(t *testing.T) (*FsRepo, func()) { t.Fatal(err) } + //stm: @REPO_FS_001 repo, err := NewFS(path) if err != nil { t.Fatal(err) } + //stm: @REPO_FS_002 err = repo.Init(FullNode) if err != ErrRepoExists && err != nil { t.Fatal(err) @@ -29,5 +32,6 @@ func genFsRepo(t *testing.T) (*FsRepo, func()) { func TestFsBasic(t *testing.T) { repo, closer := genFsRepo(t) defer closer() + //stm: @REPO_FS_003 basicTest(t, repo) } diff --git a/node/repo/memrepo_test.go b/node/repo/memrepo_test.go index 965bc02c195..457a4b6d986 100644 --- a/node/repo/memrepo_test.go +++ b/node/repo/memrepo_test.go @@ -1,3 +1,4 @@ +//stm: #unit package repo import ( @@ -6,5 +7,6 @@ import ( func TestMemBasic(t *testing.T) { repo := NewMemory(nil) + //stm: @REPO_MEM_001 basicTest(t, repo) } diff --git a/node/repo/repo_test.go b/node/repo/repo_test.go index 444fab267af..6c69b4cb3be 100644 --- a/node/repo/repo_test.go +++ b/node/repo/repo_test.go @@ -1,3 +1,4 @@ +//stm: #unit package repo import ( @@ -14,17 +15,20 @@ import ( ) func basicTest(t *testing.T, repo Repo) { + //stm: @REPO_NET_001 apima, err := repo.APIEndpoint() if assert.Error(t, err) { assert.Equal(t, ErrNoAPIEndpoint, err) } assert.Nil(t, apima, "with no api endpoint, return should be nil") + //stm: @REPO_MUT_001 lrepo, err := repo.Lock(FullNode) assert.NoError(t, err, "should be able to lock once") assert.NotNil(t, lrepo, "locked repo shouldn't be nil") { + //stm: @REPO_MUT_002 lrepo2, err := repo.Lock(FullNode) if assert.Error(t, err) { assert.Equal(t, ErrRepoAlreadyLocked, err) @@ -32,6 +36,7 @@ func basicTest(t *testing.T, repo Repo) { assert.Nil(t, lrepo2, "with locked repo errors, nil should be returned") } + //stm: @REPO_MUT_003 err = lrepo.Close() assert.NoError(t, err, "should be able to unlock") @@ -42,6 +47,7 @@ func basicTest(t *testing.T, repo Repo) { ma, err := multiaddr.NewMultiaddr("/ip4/127.0.0.1/tcp/43244") assert.NoError(t, err, "creating multiaddr shouldn't error") + //stm: @REPO_NET_002 err = lrepo.SetAPIEndpoint(ma) assert.NoError(t, err, "setting multiaddr shouldn't error") @@ -69,6 +75,7 @@ func basicTest(t *testing.T, repo Repo) { err = lrepo.Close() assert.NoError(t, err, "should be able to close") + //stm: @REPO_NET_003 apima, err = repo.APIEndpoint() if assert.Error(t, err) { @@ -83,22 +90,27 @@ func basicTest(t *testing.T, repo Repo) { assert.NoError(t, err, "should be able to relock") assert.NotNil(t, lrepo, "locked repo shouldn't be nil") + //stm: @REPO_KEYSTR_001 kstr, err := lrepo.KeyStore() assert.NoError(t, err, "should be able to get keystore") assert.NotNil(t, lrepo, "keystore shouldn't be nil") + //stm: @REPO_KEYSTR_002 list, err := kstr.List() assert.NoError(t, err, "should be able to list key") assert.Empty(t, list, "there should be no keys") + //stm: @REPO_KEYSTR_003 err = kstr.Put("k1", k1) assert.NoError(t, err, "should be able to put k1") + //stm: @REPO_KEYSTR_004 err = kstr.Put("k1", k1) if assert.Error(t, err, "putting key under the same name should error") { assert.True(t, xerrors.Is(err, types.ErrKeyExists), "returned error is ErrKeyExists") } + //stm: @REPO_KEYSTR_005 k1prim, err := kstr.Get("k1") assert.NoError(t, err, "should be able to get k1") assert.Equal(t, k1, k1prim, "returned key should be the same") @@ -116,6 +128,7 @@ func basicTest(t *testing.T, repo Repo) { assert.NoError(t, err, "should be able to list keys") assert.ElementsMatch(t, []string{"k1", "k2"}, list, "returned elements match") + //stm: @REPO_KEYSTR_006 err = kstr.Delete("k2") assert.NoError(t, err, "should be able to delete key") diff --git a/node/shutdown_test.go b/node/shutdown_test.go index 15e2af93e5e..58c79a34e53 100644 --- a/node/shutdown_test.go +++ b/node/shutdown_test.go @@ -15,6 +15,7 @@ func TestMonitorShutdown(t *testing.T) { // Three shutdown handlers. var wg sync.WaitGroup wg.Add(3) + //stm: @NODE_SHUTDOWN_001 h := ShutdownHandler{ Component: "handler", StopFunc: func(_ context.Context) error { @@ -23,6 +24,7 @@ func TestMonitorShutdown(t *testing.T) { }, } + //stm: @NODE_SHUTDOWN_002 finishCh := MonitorShutdown(signalCh, h, h, h) // Nothing here after 10ms. diff --git a/paychmgr/paych_test.go b/paychmgr/paych_test.go index ab04ad7e0ea..1edb840cc5e 100644 --- a/paychmgr/paych_test.go +++ b/paychmgr/paych_test.go @@ -1,3 +1,4 @@ +//stm: #unit package paychmgr import ( @@ -196,6 +197,7 @@ func TestCheckVoucherValid(t *testing.T) { for _, tcase := range tcases { tcase := tcase + //stm: @PAYMENT_CHANNEL_VOUCHER_001, PAYMENT_CHANNEL_VOUCHER_002, PAYMENT_CHANNEL_VOUCHER_003, PAYMENT_CHANNEL_VOUCHER_004 t.Run(tcase.name, func(t *testing.T) { // Create an actor for the channel with the test case balance act := &types.Actor{