From 2e4d45ef0734f508cf9f8f67ef906dc601fbce61 Mon Sep 17 00:00:00 2001 From: vyzo Date: Sat, 27 Feb 2021 13:40:26 +0200 Subject: [PATCH] test for bolt backed tracking store --- chain/store/splitstore/snoop_test.go | 36 ++++++++++++++++++---------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/chain/store/splitstore/snoop_test.go b/chain/store/splitstore/snoop_test.go index 225c5936b..96cfb667d 100644 --- a/chain/store/splitstore/snoop_test.go +++ b/chain/store/splitstore/snoop_test.go @@ -1,19 +1,18 @@ package splitstore import ( + "os" "testing" - "golang.org/x/xerrors" - - "github.com/ledgerwatch/lmdb-go/lmdb" - cid "github.com/ipfs/go-cid" "github.com/multiformats/go-multihash" "github.com/filecoin-project/go-state-types/abi" ) -func TestTrackingStore(t *testing.T) { +func testTrackingStore(t *testing.T, useLMDB bool) { + t.Helper() + makeCid := func(key string) cid.Cid { h, err := multihash.Sum([]byte(key), multihash.SHA2_256, -1) if err != nil { @@ -36,16 +35,19 @@ func TestTrackingStore(t *testing.T) { mustNotHave := func(s TrackingStore, cid cid.Cid) { _, err := s.Get(cid) - xerr := xerrors.Unwrap(err) - if xerr == nil { - xerr = err - } - if !lmdb.IsNotFound(xerr) { - t.Fatal("expected key not found") + if err == nil { + t.Fatal("expected error") } } - s, err := NewLMDBTrackingStore("/tmp/snoop-test") + path := "/tmp/liveset-test" + + err := os.MkdirAll(path, 0777) + if err != nil { + t.Fatal(err) + } + + s, err := NewTrackingStore(path, useLMDB) if err != nil { t.Fatal(err) } @@ -112,7 +114,7 @@ func TestTrackingStore(t *testing.T) { t.Fatal(err) } - s, err = NewLMDBTrackingStore("/tmp/snoop-test") + s, err = NewTrackingStore(path, useLMDB) if err != nil { t.Fatal(err) } @@ -124,3 +126,11 @@ func TestTrackingStore(t *testing.T) { s.Close() //nolint:errcheck } + +func TestLMDBTrackingStore(t *testing.T) { + testTrackingStore(t, true) +} + +func TestBoltTrackingStore(t *testing.T) { + testTrackingStore(t, false) +}