Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing reserve put cases #4891

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 !errors.Is(err, storage.ErrOverwriteNewerChunk) {
t.Fatal(err)
}
})

t.Run("chunk with different batchID remains untouched", func(t *testing.T) {
Expand Down
Loading