cmd/swarm: hashes command (#19008)

This commit is contained in:
holisticode
2019-02-07 07:51:24 -05:00
committed by Anton Evangelatov
parent 85b3b1c8d6
commit 7f55b0cbd8
4 changed files with 71 additions and 14 deletions

View File

@@ -190,22 +190,18 @@ func TestGetAllReferences(t *testing.T) {
}
fileStore := NewFileStore(localStore, NewFileStoreParams())
checkRefs := func(dataSize int, expectedLen int) {
slice := testutil.RandomBytes(1, dataSize)
// 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) != expectedLen {
t.Fatalf("Expected reference array length to be %d, but is %d", expectedLen, len(addrs))
if len(addrs) != expectedLens[i] {
t.Fatalf("Expected reference array length to be %d, but is %d", expectedLens[i], len(addrs))
}
}
// 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 {
checkRefs(r, expectedLens[i])
}
}