From 6575a9b6625ea42bf4b9bb51d0036efaab9c34e3 Mon Sep 17 00:00:00 2001 From: istae <14264581+istae@users.noreply.github.com> Date: Mon, 4 Nov 2024 17:08:37 +0300 Subject: [PATCH] chore: reserve changes are not handling certain cases --- pkg/storer/internal/reserve/reserve_test.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkg/storer/internal/reserve/reserve_test.go b/pkg/storer/internal/reserve/reserve_test.go index 15993fd7de8..411d4cf9d71 100644 --- a/pkg/storer/internal/reserve/reserve_test.go +++ b/pkg/storer/internal/reserve/reserve_test.go @@ -288,11 +288,13 @@ func TestSameChunkAddress(t *testing.T) { } }) - t.Run("not a soc and newer timestamp", func(t *testing.T) { + t.Run("not a soc and different timestamps", func(t *testing.T) { size1 := r.Size() batch := postagetesting.MustNewBatch() ch1 := chunk.GenerateTestRandomChunkAt(t, baseAddr, 0).WithStamp(postagetesting.MustNewFields(batch.ID, 0, 7)) ch2 := swarm.NewChunk(ch1.Address(), []byte("update")).WithStamp(postagetesting.MustNewFields(batch.ID, 0, 8)) + ch3 := swarm.NewChunk(ch1.Address(), []byte("update")).WithStamp(postagetesting.MustNewFields(batch.ID, 0, 6)) + ch4 := swarm.NewChunk(ch1.Address(), []byte("update")).WithStamp(postagetesting.MustNewFields(batch.ID, 1, 6)) err := r.Put(ctx, ch1) if err != nil { t.Fatal(err) @@ -322,6 +324,16 @@ func TestSameChunkAddress(t *testing.T) { if size2-size1 != 1 { t.Fatalf("expected reserve size to increase by 2, got %d", size2-size1) } + + err = r.Put(ctx, ch3) + if !errors.Is(err, storage.ErrOverwriteNewerChunk) { + t.Fatal(err) + } + + err = r.Put(ctx, ch4) + if err != nil { + t.Fatal(err) + } }) t.Run("chunk with different batchID remains untouched", func(t *testing.T) {