From 3cd09df96a8fe27cd5bdb2c4d1dcb0952ed69fd5 Mon Sep 17 00:00:00 2001 From: rene <41963722+renaynay@users.noreply.github.com> Date: Thu, 9 Jan 2025 19:21:14 +0100 Subject: [PATCH] test(core): ensure .q4 file not stored for blocks outside sampling window --- core/exchange_test.go | 9 ++++++++- core/listener_test.go | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/core/exchange_test.go b/core/exchange_test.go index a2187ed7c8..77480a53f4 100644 --- a/core/exchange_test.go +++ b/core/exchange_test.go @@ -3,6 +3,8 @@ package core import ( "bytes" "context" + "os" + "path/filepath" "testing" "time" @@ -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) @@ -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)) } } diff --git a/core/listener_test.go b/core/listener_test.go index 99c6ea1a28..d7fc0d7ced 100644 --- a/core/listener_test.go +++ b/core/listener_test.go @@ -2,6 +2,8 @@ package core import ( "context" + "os" + "path/filepath" "testing" "time" @@ -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)) } }