aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/storage/filestore_test.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2019-02-20 16:48:12 +0800
committerGitHub <noreply@github.com>2019-02-20 16:48:12 +0800
commitc942700427557e3ff6de3aaf6b916e2f056c1ec2 (patch)
treecadf68e7206d6de42b1eefc6967214cf86e35ff2 /swarm/storage/filestore_test.go
parent7fa3509e2eaf1a4ebc12344590e5699406690f15 (diff)
parentcde35439e058b4f9579830fec9fb65ae0b998346 (diff)
downloadgo-tangerine-1.8.23.tar
go-tangerine-1.8.23.tar.gz
go-tangerine-1.8.23.tar.bz2
go-tangerine-1.8.23.tar.lz
go-tangerine-1.8.23.tar.xz
go-tangerine-1.8.23.tar.zst
go-tangerine-1.8.23.zip
Merge pull request #19029 from holiman/update1.8v1.8.23
Update1.8
Diffstat (limited to 'swarm/storage/filestore_test.go')
-rw-r--r--swarm/storage/filestore_test.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/swarm/storage/filestore_test.go b/swarm/storage/filestore_test.go
index fb0f761a4..06c4be1d7 100644
--- a/swarm/storage/filestore_test.go
+++ b/swarm/storage/filestore_test.go
@@ -173,3 +173,35 @@ func testFileStoreCapacity(toEncrypt bool, t *testing.T) {
t.Fatalf("Comparison error after clearing memStore.")
}
}
+
+// TestGetAllReferences only tests that GetAllReferences returns an expected
+// number of references for a given file
+func TestGetAllReferences(t *testing.T) {
+ tdb, cleanup, err := newTestDbStore(false, false)
+ defer cleanup()
+ if err != nil {
+ t.Fatalf("init dbStore failed: %v", err)
+ }
+ db := tdb.LDBStore
+ memStore := NewMemStore(NewDefaultStoreParams(), db)
+ localStore := &LocalStore{
+ memStore: memStore,
+ DbStore: db,
+ }
+ fileStore := NewFileStore(localStore, NewFileStoreParams())
+
+ // testRuns[i] and expectedLen[i] are dataSize and expected length respectively
+ testRuns := []int{1024, 8192, 16000, 30000, 1000000}
+ expectedLens := []int{1, 3, 5, 9, 248}
+ for i, r := range testRuns {
+ slice := testutil.RandomBytes(1, r)
+
+ addrs, err := fileStore.GetAllReferences(context.Background(), bytes.NewReader(slice), false)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(addrs) != expectedLens[i] {
+ t.Fatalf("Expected reference array length to be %d, but is %d", expectedLens[i], len(addrs))
+ }
+ }
+}