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

test(core): ensure .q4 file not stored for blocks outside sampling window #4035

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
9 changes: 8 additions & 1 deletion core/exchange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package core
import (
"bytes"
"context"
"os"
"path/filepath"
"testing"
"time"

Expand Down Expand Up @@ -144,7 +146,7 @@ func TestExchange_StoreHistoricIfArchival(t *testing.T) {
headers, err := ce.GetRangeByHeight(ctx, genHeader, 30)
require.NoError(t, err)

// ensure all "historic" EDSs were stored
// ensure all "historic" EDSs were stored but not the .q4 files
for _, h := range headers {
has, err := store.HasByHeight(ctx, h.Height())
require.NoError(t, err)
Expand All @@ -157,6 +159,11 @@ func TestExchange_StoreHistoricIfArchival(t *testing.T) {
has, err = store.HasByHash(ctx, h.DAH.Hash())
require.NoError(t, err)
assert.True(t, has)

// ensure .q4 file was not stored
fp := filepath.Join(t.TempDir(), "blocks", h.DAH.String()) + ".q4"
_, err = os.Open(fp)
assert.True(t, os.IsNotExist(err))
}
}

Expand Down
7 changes: 7 additions & 0 deletions core/listener_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package core

import (
"context"
"os"
"path/filepath"
"testing"
"time"

Expand Down Expand Up @@ -130,6 +132,11 @@ func TestListener_DoesNotStoreHistoric(t *testing.T) {
has, err := store.HasByHash(ctx, hash)
require.NoError(t, err)
assert.False(t, has)

// ensure .q4 file was not stored
fp := filepath.Join(t.TempDir(), "blocks", hash.String()) + ".q4"
_, err = os.Open(fp)
assert.True(t, os.IsNotExist(err))
}
}

Expand Down
Loading