diff --git a/pkg/node/statestore_test.go b/pkg/node/statestore_test.go deleted file mode 100644 index 55feb9e0e8a..00000000000 --- a/pkg/node/statestore_test.go +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2023 The Swarm Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package node - -import ( - "crypto/rand" - "fmt" - "math/big" - "testing" - "time" - - "github.com/ethersphere/bee/pkg/log" - "github.com/ethersphere/bee/pkg/postage" - "github.com/ethersphere/bee/pkg/storage" -) - -func TestInitStamperStore(t *testing.T) { - dataDir := t.TempDir() - stateStore, _, err := InitStateStore(log.Noop, dataDir, 100_000) - if err != nil { - t.Fatal(err) - } - - ids := make(map[string]int) - - // add 10 stamps to the state store - for i := 0; i < 10; i++ { - bID := make([]byte, 32) - _, err = rand.Read(bID) - if err != nil { - t.Fatal(err) - } - si := postage.NewStampIssuer("", "", bID, big.NewInt(3), 11, 10, 1000, true) - err = stateStore.Put(fmt.Sprintf("postage%s", string(si.ID())), si) - if err != nil { - t.Fatal(err) - } - ids[string(si.ID())] = 0 - } - - stamperStore, err := InitStamperStore(log.Noop, dataDir, stateStore) - if err != nil { - t.Fatal("init stamper store should migrate stamps from state store", err) - } - - err = stamperStore.Iterate( - storage.Query{ - Factory: func() storage.Item { return new(postage.StampIssuerItem) }, - }, func(result storage.Result) (bool, error) { - issuer := result.Entry.(*postage.StampIssuerItem).Issuer - ids[string(issuer.ID())]++ - return false, nil - }) - if err != nil { - t.Fatal(err) - } - - var got int - for _, v := range ids { - if v > 0 { - got++ - } - } - if got != 10 { - t.Fatalf("want %d stamps. got %d", 10, got) - } - - t.Cleanup(func() { - err = stateStore.Close() - if err != nil { - t.Fatal(err) - } - err = stamperStore.Close() - if err != nil { - t.Fatal(err) - } - time.Sleep(1 * time.Second) - }) -} diff --git a/pkg/postage/batchstore/store_test.go b/pkg/postage/batchstore/store_test.go index 2c13dd2054b..afa094a977d 100644 --- a/pkg/postage/batchstore/store_test.go +++ b/pkg/postage/batchstore/store_test.go @@ -222,7 +222,7 @@ func TestBatchStore_Reset(t *testing.T) { // we expect one key in the statestore since the schema name // will always be there. - if c != 1 { + if c != 0 { t.Fatalf("expected only one key in statestore, got %d", c) } } @@ -242,11 +242,6 @@ func TestBatchSave(t *testing.T) { defaultDepth := uint8(8) defaultValue := 1 - type testCase struct { - add []testBatch - name string - } - // Test cases define each batches's depth, value, and the new radius // of the reserve state after the batch is saved. // In some cases, batches with zero values are added to check that the radius is not altered. @@ -258,7 +253,10 @@ func TestBatchSave(t *testing.T) { // With two batches of the same depth, the calculation is as such: log2((256 + 256) / 32) = 5. // The ceiling function is used to round up results so the actual formula is ceil(log2(totalCommitment/node_capacity)) = R - tcs := []testCase{ + tcs := []struct { + add []testBatch + name string + }{ { name: "first batch's depth is below capacity", add: []testBatch{ diff --git a/pkg/statestore/mock/store.go b/pkg/statestore/mock/store.go index c1150260c2e..15f3995faf9 100644 --- a/pkg/statestore/mock/store.go +++ b/pkg/statestore/mock/store.go @@ -7,7 +7,6 @@ package mock import ( "encoding" "encoding/json" - "fmt" "strings" "sync" @@ -28,10 +27,6 @@ func NewStateStore() storage.StateStorer { store: make(map[string][]byte), } - if err := s.Put(mockSchemaNameKey, "mock_schema"); err != nil { - panic(fmt.Errorf("put schema name: %w", err)) - } - return s } diff --git a/pkg/statestore/storeadapter/storeadapter_test.go b/pkg/statestore/storeadapter/storeadapter_test.go index 7364a297ed4..5065a5158da 100644 --- a/pkg/statestore/storeadapter/storeadapter_test.go +++ b/pkg/statestore/storeadapter/storeadapter_test.go @@ -30,12 +30,6 @@ func TestStateStoreAdapter(t *testing.T) { } }) - // The test requires the state store to have - // a schema, otherwise the delete test fails. - if err := store.Put("test_schema", "name"); err != nil { - t.Fatalf("unexpected error: %v", err) - } - return store }) diff --git a/pkg/statestore/test/store.go b/pkg/statestore/test/store.go index 11c7acb9fe5..40fa90b1bef 100644 --- a/pkg/statestore/test/store.go +++ b/pkg/statestore/test/store.go @@ -225,5 +225,5 @@ func testStoreIterator(t *testing.T, store storage.StateStorer, prefix string, s func testEmpty(t *testing.T, store storage.StateStorer) { t.Helper() - testStoreIterator(t, store, "", 1) // 1 because of the schema entry. + testStoreIterator(t, store, "", 0) // 1 because of the schema entry. }