Skip to content

Commit

Permalink
Fix CI test failure (#1216)
Browse files Browse the repository at this point in the history
  • Loading branch information
jianoaix authored Feb 5, 2025
1 parent 1c6a730 commit 0fdef92
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
6 changes: 3 additions & 3 deletions disperser/common/v2/blobstore/dynamo_metadata_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ func (s *BlobMetadataStore) GetAttestationByAttestedAt(
return nil, errors.New("start must be less than end")
}

startBucket, endBucket := getAttestedAtBucketIDRange(start, end)
startBucket, endBucket := GetAttestedAtBucketIDRange(start, end)

result := make([]*corev2.Attestation, 0)
for bucket := startBucket; bucket <= endBucket; bucket++ {
Expand Down Expand Up @@ -1550,9 +1550,9 @@ func getRequestedAtBucketIDRange(startTime, endTime uint64) (uint64, uint64) {
return startBucket, endBucket
}

// getAttestedAtBucketIDRange returns the adjusted start and end bucket IDs based on
// GetAttestedAtBucketIDRange returns the adjusted start and end bucket IDs based on
// the allowed time range for blobs.
func getAttestedAtBucketIDRange(startTime, endTime uint64) (uint64, uint64) {
func GetAttestedAtBucketIDRange(startTime, endTime uint64) (uint64, uint64) {
now := uint64(time.Now().UnixNano())
oldestAllowed := now - maxBlobAgeInNano

Expand Down
16 changes: 10 additions & 6 deletions disperser/common/v2/blobstore/dynamo_metadata_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,15 +663,19 @@ func TestBlobMetadataStoreGetAttestationByAttestedAt(t *testing.T) {
func TestBlobMetadataStoreGetAttestationByAttestedAtPagination(t *testing.T) {
ctx := context.Background()

// Use a fixed "now" so all attestations will deterministically fall in just one
now := uint64(time.Now().UnixNano())
firstBatchTs := now - uint64(5*time.Minute.Nanoseconds())
// Adjust "now" so all attestations will deterministically fall in just one
// bucket.
timestamp := "2025-01-21T15:04:05Z"
parsedTime, err := time.Parse(time.RFC3339, timestamp)
require.NoError(t, err)
now := uint64(parsedTime.UnixNano())
startBucket, endBucket := blobstore.GetAttestedAtBucketIDRange(firstBatchTs-1, now)
if startBucket < endBucket {
now -= uint64(25 * time.Hour.Nanoseconds())
firstBatchTs = now - uint64(5*time.Minute.Nanoseconds())
}
startBucket, endBucket = blobstore.GetAttestedAtBucketIDRange(firstBatchTs-1, now)
require.Equal(t, startBucket, endBucket)

numBatches := 240
firstBatchTs := now - uint64(5*time.Minute.Nanoseconds())
nanoSecsPerBatch := uint64(time.Second.Nanoseconds()) // 1 batch per second

// Create attestations for testing
Expand Down

0 comments on commit 0fdef92

Please sign in to comment.