diff options
author | lash <nolash@users.noreply.github.com> | 2018-11-15 21:57:03 +0800 |
---|---|---|
committer | Anton Evangelatov <anton.evangelatov@gmail.com> | 2018-11-15 21:57:03 +0800 |
commit | a6942b9f25bd6c67a5ab9e80ab95aae25a08da6d (patch) | |
tree | 3c6fb2287364f2e21daa171905c4c877c8485535 /swarm/storage/ldbstore_test.go | |
parent | 17d67c5834679f2b27ef08eddfce3b3a154a96a8 (diff) | |
download | dexon-a6942b9f25bd6c67a5ab9e80ab95aae25a08da6d.tar dexon-a6942b9f25bd6c67a5ab9e80ab95aae25a08da6d.tar.gz dexon-a6942b9f25bd6c67a5ab9e80ab95aae25a08da6d.tar.bz2 dexon-a6942b9f25bd6c67a5ab9e80ab95aae25a08da6d.tar.lz dexon-a6942b9f25bd6c67a5ab9e80ab95aae25a08da6d.tar.xz dexon-a6942b9f25bd6c67a5ab9e80ab95aae25a08da6d.tar.zst dexon-a6942b9f25bd6c67a5ab9e80ab95aae25a08da6d.zip |
swarm/storage: Batched database migration (#18113)
Diffstat (limited to 'swarm/storage/ldbstore_test.go')
-rw-r--r-- | swarm/storage/ldbstore_test.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/swarm/storage/ldbstore_test.go b/swarm/storage/ldbstore_test.go index 07557980c..9c10b3629 100644 --- a/swarm/storage/ldbstore_test.go +++ b/swarm/storage/ldbstore_test.go @@ -761,6 +761,38 @@ func TestCleanIndex(t *testing.T) { t.Fatalf("expected sum of bin indices to be 3, was %d", binTotal) } } + + // check that the iterator quits properly + chunks, err = mputRandomChunks(ldb, 4100, 4096) + if err != nil { + t.Fatal(err) + } + + po = ldb.po(chunks[4099].Address()[:]) + dataKey = make([]byte, 10) + dataKey[0] = keyData + dataKey[1] = byte(po) + binary.BigEndian.PutUint64(dataKey[2:], 4099+3) + if _, err := ldb.db.Get(dataKey); err != nil { + t.Fatal(err) + } + if err := ldb.db.Delete(dataKey); err != nil { + t.Fatal(err) + } + + if err := ldb.CleanGCIndex(); err != nil { + t.Fatal(err) + } + + // entrycount should now be one less of added chunks + c, err = ldb.db.Get(keyEntryCnt) + if err != nil { + t.Fatalf("expected gc 2 idx to be present: %v", idxKey) + } + entryCount = binary.BigEndian.Uint64(c) + if entryCount != 4099+2 { + t.Fatalf("expected entrycnt to be 2, was %d", c) + } } func waitGc(ctx context.Context, ldb *LDBStore) { |