Skip to content

Commit

Permalink
chore: reserve changes are not handling certain cases
Browse files Browse the repository at this point in the history
  • Loading branch information
istae committed Nov 4, 2024
1 parent 691a43d commit 6575a9b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pkg/storer/internal/reserve/reserve_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 6575a9b

Please sign in to comment.