diff options
author | Balint Gabor <balint.g@gmail.com> | 2018-09-13 17:42:19 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-13 17:42:19 +0800 |
commit | 3ff2f756368f2d8ec0d1d9d25f6ba9cdabd7383e (patch) | |
tree | 62a2896b3b824449595272f0b92dda877ba1c58d /swarm/storage/hasherstore_test.go | |
parent | ff3a5d24d2e40fd66f7813173e9cfc31144f3c53 (diff) | |
download | go-tangerine-3ff2f756368f2d8ec0d1d9d25f6ba9cdabd7383e.tar go-tangerine-3ff2f756368f2d8ec0d1d9d25f6ba9cdabd7383e.tar.gz go-tangerine-3ff2f756368f2d8ec0d1d9d25f6ba9cdabd7383e.tar.bz2 go-tangerine-3ff2f756368f2d8ec0d1d9d25f6ba9cdabd7383e.tar.lz go-tangerine-3ff2f756368f2d8ec0d1d9d25f6ba9cdabd7383e.tar.xz go-tangerine-3ff2f756368f2d8ec0d1d9d25f6ba9cdabd7383e.tar.zst go-tangerine-3ff2f756368f2d8ec0d1d9d25f6ba9cdabd7383e.zip |
swarm: Chunk refactor (#17659)
Co-authored-by: Janos Guljas <janos@resenje.org>
Co-authored-by: Balint Gabor <balint.g@gmail.com>
Co-authored-by: Anton Evangelatov <anton.evangelatov@gmail.com>
Co-authored-by: Viktor TrĂ³n <viktor.tron@gmail.com>
Diffstat (limited to 'swarm/storage/hasherstore_test.go')
-rw-r--r-- | swarm/storage/hasherstore_test.go | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/swarm/storage/hasherstore_test.go b/swarm/storage/hasherstore_test.go index ddf1c39b0..22cf98d0e 100644 --- a/swarm/storage/hasherstore_test.go +++ b/swarm/storage/hasherstore_test.go @@ -46,14 +46,16 @@ func TestHasherStore(t *testing.T) { hasherStore := NewHasherStore(chunkStore, MakeHashFunc(DefaultHash), tt.toEncrypt) // Put two random chunks into the hasherStore - chunkData1 := GenerateRandomChunk(int64(tt.chunkLength)).SData - key1, err := hasherStore.Put(context.TODO(), chunkData1) + chunkData1 := GenerateRandomChunk(int64(tt.chunkLength)).Data() + ctx, cancel := context.WithTimeout(context.Background(), getTimeout) + defer cancel() + key1, err := hasherStore.Put(ctx, chunkData1) if err != nil { t.Fatalf("Expected no error got \"%v\"", err) } - chunkData2 := GenerateRandomChunk(int64(tt.chunkLength)).SData - key2, err := hasherStore.Put(context.TODO(), chunkData2) + chunkData2 := GenerateRandomChunk(int64(tt.chunkLength)).Data() + key2, err := hasherStore.Put(ctx, chunkData2) if err != nil { t.Fatalf("Expected no error got \"%v\"", err) } @@ -61,13 +63,13 @@ func TestHasherStore(t *testing.T) { hasherStore.Close() // Wait until chunks are really stored - err = hasherStore.Wait(context.TODO()) + err = hasherStore.Wait(ctx) if err != nil { t.Fatalf("Expected no error got \"%v\"", err) } // Get the first chunk - retrievedChunkData1, err := hasherStore.Get(context.TODO(), key1) + retrievedChunkData1, err := hasherStore.Get(ctx, key1) if err != nil { t.Fatalf("Expected no error, got \"%v\"", err) } @@ -78,7 +80,7 @@ func TestHasherStore(t *testing.T) { } // Get the second chunk - retrievedChunkData2, err := hasherStore.Get(context.TODO(), key2) + retrievedChunkData2, err := hasherStore.Get(ctx, key2) if err != nil { t.Fatalf("Expected no error, got \"%v\"", err) } @@ -105,12 +107,12 @@ func TestHasherStore(t *testing.T) { } // Check if chunk data in store is encrypted or not - chunkInStore, err := chunkStore.Get(context.TODO(), hash1) + chunkInStore, err := chunkStore.Get(ctx, hash1) if err != nil { t.Fatalf("Expected no error got \"%v\"", err) } - chunkDataInStore := chunkInStore.SData + chunkDataInStore := chunkInStore.Data() if tt.toEncrypt && bytes.Equal(chunkData1, chunkDataInStore) { t.Fatalf("Chunk expected to be encrypted but it is stored without encryption") |