2024-01-06 23:47:09 +00:00
|
|
|
package das
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2024-02-15 05:46:47 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
|
|
|
|
"github.com/prysmaticlabs/prysm/v5/consensus-types/primitives"
|
2024-01-06 23:47:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// MockAvailabilityStore is an implementation of AvailabilityStore that can be used by other packages in tests.
|
|
|
|
type MockAvailabilityStore struct {
|
|
|
|
VerifyAvailabilityCallback func(ctx context.Context, current primitives.Slot, b blocks.ROBlock) error
|
|
|
|
PersistBlobsCallback func(current primitives.Slot, sc ...blocks.ROBlob) error
|
|
|
|
}
|
|
|
|
|
|
|
|
var _ AvailabilityStore = &MockAvailabilityStore{}
|
|
|
|
|
|
|
|
// IsDataAvailable satisfies the corresponding method of the AvailabilityStore interface in a way that is useful for tests.
|
|
|
|
func (m *MockAvailabilityStore) IsDataAvailable(ctx context.Context, current primitives.Slot, b blocks.ROBlock) error {
|
|
|
|
if m.VerifyAvailabilityCallback != nil {
|
|
|
|
return m.VerifyAvailabilityCallback(ctx, current, b)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Persist satisfies the corresponding method of the AvailabilityStore interface in a way that is useful for tests.
|
|
|
|
func (m *MockAvailabilityStore) Persist(current primitives.Slot, sc ...blocks.ROBlob) error {
|
|
|
|
if m.PersistBlobsCallback != nil {
|
|
|
|
return m.PersistBlobsCallback(current, sc...)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|