mirror of
https://github.com/logos-messaging/logos-messaging-go.git
synced 2026-01-08 00:43:10 +00:00
refactor: remove WakuStoreWithRetentionPolicy and add build tag to migrations (#281)
This commit is contained in:
parent
fb6d59ff33
commit
546416a9d5
@ -201,7 +201,7 @@ func Execute(options Options) {
|
|||||||
|
|
||||||
if options.Store.Enable {
|
if options.Store.Enable {
|
||||||
if options.Store.PersistMessages {
|
if options.Store.PersistMessages {
|
||||||
nodeOpts = append(nodeOpts, node.WithWakuStoreAndRetentionPolicy(options.Store.ShouldResume, options.Store.RetentionMaxSecondsDuration(), options.Store.RetentionMaxMessages))
|
nodeOpts = append(nodeOpts, node.WithWakuStore(true, options.Store.ShouldResume))
|
||||||
dbStore, err := persistence.NewDBStore(logger, persistence.WithDB(db), persistence.WithRetentionPolicy(options.Store.RetentionMaxMessages, options.Store.RetentionMaxSecondsDuration()))
|
dbStore, err := persistence.NewDBStore(logger, persistence.WithDB(db), persistence.WithRetentionPolicy(options.Store.RetentionMaxMessages, options.Store.RetentionMaxSecondsDuration()))
|
||||||
failOnErr(err, "DBStore")
|
failOnErr(err, "DBStore")
|
||||||
nodeOpts = append(nodeOpts, node.WithMessageProvider(dbStore))
|
nodeOpts = append(nodeOpts, node.WithMessageProvider(dbStore))
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
|
//go:build !gowaku_skip_migrations
|
||||||
|
// +build !gowaku_skip_migrations
|
||||||
|
|
||||||
package migrations
|
package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
13
waku/persistence/migrations/no_migrations.go
Normal file
13
waku/persistence/migrations/no_migrations.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
//go:build gowaku_skip_migrations
|
||||||
|
// +build gowaku_skip_migrations
|
||||||
|
|
||||||
|
package migrations
|
||||||
|
|
||||||
|
import (
|
||||||
|
"database/sql"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Skip migration code
|
||||||
|
func Migrate(db *sql.DB) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@ -37,6 +37,8 @@ type DBStore struct {
|
|||||||
maxMessages int
|
maxMessages int
|
||||||
maxDuration time.Duration
|
maxDuration time.Duration
|
||||||
|
|
||||||
|
enableMigrations bool
|
||||||
|
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
quit chan struct{}
|
quit chan struct{}
|
||||||
}
|
}
|
||||||
@ -81,6 +83,21 @@ func WithRetentionPolicy(maxMessages int, maxDuration time.Duration) DBOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithMigrationsEnabled is a DBOption used to determine whether migrations should
|
||||||
|
// be executed or not
|
||||||
|
func WithMigrationsEnabled(enabled bool) DBOption {
|
||||||
|
return func(d *DBStore) error {
|
||||||
|
d.enableMigrations = enabled
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func DefaultOptions() []DBOption {
|
||||||
|
return []DBOption{
|
||||||
|
WithMigrationsEnabled(true),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Creates a new DB store using the db specified via options.
|
// Creates a new DB store using the db specified via options.
|
||||||
// It will create a messages table if it does not exist and
|
// It will create a messages table if it does not exist and
|
||||||
// clean up records according to the retention policy used
|
// clean up records according to the retention policy used
|
||||||
@ -89,7 +106,10 @@ func NewDBStore(log *zap.Logger, options ...DBOption) (*DBStore, error) {
|
|||||||
result.log = log.Named("dbstore")
|
result.log = log.Named("dbstore")
|
||||||
result.quit = make(chan struct{})
|
result.quit = make(chan struct{})
|
||||||
|
|
||||||
for _, opt := range options {
|
optList := DefaultOptions()
|
||||||
|
optList = append(optList, options...)
|
||||||
|
|
||||||
|
for _, opt := range optList {
|
||||||
err := opt(result)
|
err := opt(result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -119,9 +139,11 @@ func NewDBStore(log *zap.Logger, options ...DBOption) (*DBStore, error) {
|
|||||||
return nil, fmt.Errorf("unable to set journal_mode to WAL. actual mode %s", mode)
|
return nil, fmt.Errorf("unable to set journal_mode to WAL. actual mode %s", mode)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = migrations.Migrate(result.db)
|
if result.enableMigrations {
|
||||||
if err != nil {
|
err = migrations.Migrate(result.db)
|
||||||
return nil, err
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = result.cleanOlderRecords()
|
err = result.cleanOlderRecords()
|
||||||
|
|||||||
@ -89,7 +89,7 @@ type WakuNode struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func defaultStoreFactory(w *WakuNode) store.Store {
|
func defaultStoreFactory(w *WakuNode) store.Store {
|
||||||
return store.NewWakuStore(w.host, w.swap, w.opts.messageProvider, w.opts.maxMessages, w.opts.maxDuration, w.log)
|
return store.NewWakuStore(w.host, w.swap, w.opts.messageProvider, w.log)
|
||||||
}
|
}
|
||||||
|
|
||||||
// New is used to instantiate a WakuNode using a set of WakuNodeOptions
|
// New is used to instantiate a WakuNode using a set of WakuNodeOptions
|
||||||
|
|||||||
@ -327,19 +327,6 @@ func WithWakuSwap(mode int, disconnectThreshold, paymentThreshold int) WakuNodeO
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithWakuStoreAndRetentionPolicy enables the Waku V2 Store protocol, storing them in an optional message provider
|
|
||||||
// applying an specific retention policy
|
|
||||||
func WithWakuStoreAndRetentionPolicy(shouldResume bool, maxDuration time.Duration, maxMessages int) WakuNodeOption {
|
|
||||||
return func(params *WakuNodeParameters) error {
|
|
||||||
params.enableStore = true
|
|
||||||
params.storeMsgs = true
|
|
||||||
params.shouldResume = shouldResume
|
|
||||||
params.maxDuration = maxDuration
|
|
||||||
params.maxMessages = maxMessages
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// WithMessageProvider is a WakuNodeOption that sets the MessageProvider
|
// WithMessageProvider is a WakuNodeOption that sets the MessageProvider
|
||||||
// used to store and retrieve persisted messages
|
// used to store and retrieve persisted messages
|
||||||
func WithMessageProvider(s store.MessageProvider) WakuNodeOption {
|
func WithMessageProvider(s store.MessageProvider) WakuNodeOption {
|
||||||
|
|||||||
@ -31,7 +31,7 @@ func TestWakuOptions(t *testing.T) {
|
|||||||
advertiseAddr, _ := net.ResolveTCPAddr("tcp", "0.0.0.0:0")
|
advertiseAddr, _ := net.ResolveTCPAddr("tcp", "0.0.0.0:0")
|
||||||
|
|
||||||
storeFactory := func(w *WakuNode) store.Store {
|
storeFactory := func(w *WakuNode) store.Store {
|
||||||
return store.NewWakuStore(w.host, w.swap, w.opts.messageProvider, w.opts.maxMessages, w.opts.maxDuration, w.log)
|
return store.NewWakuStore(w.host, w.swap, w.opts.messageProvider, w.log)
|
||||||
}
|
}
|
||||||
|
|
||||||
options := []WakuNodeOption{
|
options := []WakuNodeOption{
|
||||||
@ -46,7 +46,6 @@ func TestWakuOptions(t *testing.T) {
|
|||||||
WithWakuFilter(true),
|
WithWakuFilter(true),
|
||||||
WithDiscoveryV5(123, nil, false),
|
WithDiscoveryV5(123, nil, false),
|
||||||
WithWakuStore(true, true),
|
WithWakuStore(true, true),
|
||||||
WithWakuStoreAndRetentionPolicy(true, time.Hour, 100),
|
|
||||||
WithMessageProvider(&persistence.DBStore{}),
|
WithMessageProvider(&persistence.DBStore{}),
|
||||||
WithLightPush(),
|
WithLightPush(),
|
||||||
WithKeepAlive(time.Hour),
|
WithKeepAlive(time.Hour),
|
||||||
|
|||||||
@ -21,7 +21,7 @@ func TestFindLastSeenMessage(t *testing.T) {
|
|||||||
msg4 := protocol.NewEnvelope(tests.CreateWakuMessage("4", 4), utils.GetUnixEpoch(), "test")
|
msg4 := protocol.NewEnvelope(tests.CreateWakuMessage("4", 4), utils.GetUnixEpoch(), "test")
|
||||||
msg5 := protocol.NewEnvelope(tests.CreateWakuMessage("5", 5), utils.GetUnixEpoch(), "test")
|
msg5 := protocol.NewEnvelope(tests.CreateWakuMessage("5", 5), utils.GetUnixEpoch(), "test")
|
||||||
|
|
||||||
s := NewWakuStore(nil, nil, MemoryDB(t), 0, 0, utils.Logger())
|
s := NewWakuStore(nil, nil, MemoryDB(t), utils.Logger())
|
||||||
_ = s.storeMessage(msg1)
|
_ = s.storeMessage(msg1)
|
||||||
_ = s.storeMessage(msg3)
|
_ = s.storeMessage(msg3)
|
||||||
_ = s.storeMessage(msg5)
|
_ = s.storeMessage(msg5)
|
||||||
@ -41,7 +41,7 @@ func TestResume(t *testing.T) {
|
|||||||
host1, err := libp2p.New(libp2p.DefaultTransports, libp2p.ListenAddrStrings("/ip4/0.0.0.0/tcp/0"))
|
host1, err := libp2p.New(libp2p.DefaultTransports, libp2p.ListenAddrStrings("/ip4/0.0.0.0/tcp/0"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
s1 := NewWakuStore(host1, nil, MemoryDB(t), 0, 0, utils.Logger())
|
s1 := NewWakuStore(host1, nil, MemoryDB(t), utils.Logger())
|
||||||
s1.Start(ctx)
|
s1.Start(ctx)
|
||||||
defer s1.Stop()
|
defer s1.Stop()
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ func TestResume(t *testing.T) {
|
|||||||
host2, err := libp2p.New(libp2p.DefaultTransports, libp2p.ListenAddrStrings("/ip4/0.0.0.0/tcp/0"))
|
host2, err := libp2p.New(libp2p.DefaultTransports, libp2p.ListenAddrStrings("/ip4/0.0.0.0/tcp/0"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
s2 := NewWakuStore(host2, nil, MemoryDB(t), 0, 0, utils.Logger())
|
s2 := NewWakuStore(host2, nil, MemoryDB(t), utils.Logger())
|
||||||
s2.Start(ctx)
|
s2.Start(ctx)
|
||||||
defer s2.Stop()
|
defer s2.Stop()
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ func TestResumeWithListOfPeers(t *testing.T) {
|
|||||||
host1, err := libp2p.New(libp2p.DefaultTransports, libp2p.ListenAddrStrings("/ip4/0.0.0.0/tcp/0"))
|
host1, err := libp2p.New(libp2p.DefaultTransports, libp2p.ListenAddrStrings("/ip4/0.0.0.0/tcp/0"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
s1 := NewWakuStore(host1, nil, MemoryDB(t), 0, 0, utils.Logger())
|
s1 := NewWakuStore(host1, nil, MemoryDB(t), utils.Logger())
|
||||||
s1.Start(ctx)
|
s1.Start(ctx)
|
||||||
defer s1.Stop()
|
defer s1.Stop()
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ func TestResumeWithListOfPeers(t *testing.T) {
|
|||||||
host2, err := libp2p.New(libp2p.DefaultTransports, libp2p.ListenAddrStrings("/ip4/0.0.0.0/tcp/0"))
|
host2, err := libp2p.New(libp2p.DefaultTransports, libp2p.ListenAddrStrings("/ip4/0.0.0.0/tcp/0"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
s2 := NewWakuStore(host2, nil, MemoryDB(t), 0, 0, utils.Logger())
|
s2 := NewWakuStore(host2, nil, MemoryDB(t), utils.Logger())
|
||||||
s2.Start(ctx)
|
s2.Start(ctx)
|
||||||
defer s2.Stop()
|
defer s2.Stop()
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ func TestResumeWithoutSpecifyingPeer(t *testing.T) {
|
|||||||
host1, err := libp2p.New(libp2p.DefaultTransports, libp2p.ListenAddrStrings("/ip4/0.0.0.0/tcp/0"))
|
host1, err := libp2p.New(libp2p.DefaultTransports, libp2p.ListenAddrStrings("/ip4/0.0.0.0/tcp/0"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
s1 := NewWakuStore(host1, nil, MemoryDB(t), 0, 0, utils.Logger())
|
s1 := NewWakuStore(host1, nil, MemoryDB(t), utils.Logger())
|
||||||
s1.Start(ctx)
|
s1.Start(ctx)
|
||||||
defer s1.Stop()
|
defer s1.Stop()
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ func TestResumeWithoutSpecifyingPeer(t *testing.T) {
|
|||||||
host2, err := libp2p.New(libp2p.DefaultTransports, libp2p.ListenAddrStrings("/ip4/0.0.0.0/tcp/0"))
|
host2, err := libp2p.New(libp2p.DefaultTransports, libp2p.ListenAddrStrings("/ip4/0.0.0.0/tcp/0"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
s2 := NewWakuStore(host2, nil, MemoryDB(t), 0, 0, utils.Logger())
|
s2 := NewWakuStore(host2, nil, MemoryDB(t), utils.Logger())
|
||||||
s2.Start(ctx)
|
s2.Start(ctx)
|
||||||
defer s2.Stop()
|
defer s2.Stop()
|
||||||
|
|
||||||
|
|||||||
@ -167,7 +167,7 @@ type Store interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewWakuStore creates a WakuStore using an specific MessageProvider for storing the messages
|
// NewWakuStore creates a WakuStore using an specific MessageProvider for storing the messages
|
||||||
func NewWakuStore(host host.Host, swap *swap.WakuSwap, p MessageProvider, maxNumberOfMessages int, maxRetentionDuration time.Duration, log *zap.Logger) *WakuStore {
|
func NewWakuStore(host host.Host, swap *swap.WakuSwap, p MessageProvider, log *zap.Logger) *WakuStore {
|
||||||
wakuStore := new(WakuStore)
|
wakuStore := new(WakuStore)
|
||||||
wakuStore.msgProvider = p
|
wakuStore.msgProvider = p
|
||||||
wakuStore.h = host
|
wakuStore.h = host
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import (
|
|||||||
func TestStorePersistence(t *testing.T) {
|
func TestStorePersistence(t *testing.T) {
|
||||||
db := MemoryDB(t)
|
db := MemoryDB(t)
|
||||||
|
|
||||||
s1 := NewWakuStore(nil, nil, db, 0, 0, utils.Logger())
|
s1 := NewWakuStore(nil, nil, db, utils.Logger())
|
||||||
|
|
||||||
defaultPubSubTopic := "test"
|
defaultPubSubTopic := "test"
|
||||||
defaultContentTopic := "1"
|
defaultContentTopic := "1"
|
||||||
|
|||||||
@ -20,7 +20,7 @@ func TestWakuStoreProtocolQuery(t *testing.T) {
|
|||||||
host1, err := libp2p.New(libp2p.DefaultTransports, libp2p.ListenAddrStrings("/ip4/0.0.0.0/tcp/0"))
|
host1, err := libp2p.New(libp2p.DefaultTransports, libp2p.ListenAddrStrings("/ip4/0.0.0.0/tcp/0"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
s1 := NewWakuStore(host1, nil, MemoryDB(t), 0, 0, utils.Logger())
|
s1 := NewWakuStore(host1, nil, MemoryDB(t), utils.Logger())
|
||||||
s1.Start(ctx)
|
s1.Start(ctx)
|
||||||
defer s1.Stop()
|
defer s1.Stop()
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ func TestWakuStoreProtocolQuery(t *testing.T) {
|
|||||||
// Simulate a message has been received via relay protocol
|
// Simulate a message has been received via relay protocol
|
||||||
s1.MsgC <- protocol.NewEnvelope(msg, utils.GetUnixEpoch(), pubsubTopic1)
|
s1.MsgC <- protocol.NewEnvelope(msg, utils.GetUnixEpoch(), pubsubTopic1)
|
||||||
|
|
||||||
s2 := NewWakuStore(host2, nil, MemoryDB(t), 0, 0, utils.Logger())
|
s2 := NewWakuStore(host2, nil, MemoryDB(t), utils.Logger())
|
||||||
s2.Start(ctx)
|
s2.Start(ctx)
|
||||||
defer s2.Stop()
|
defer s2.Stop()
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ func TestWakuStoreProtocolNext(t *testing.T) {
|
|||||||
|
|
||||||
db := MemoryDB(t)
|
db := MemoryDB(t)
|
||||||
|
|
||||||
s1 := NewWakuStore(host1, nil, db, 0, 0, utils.Logger())
|
s1 := NewWakuStore(host1, nil, db, utils.Logger())
|
||||||
s1.Start(ctx)
|
s1.Start(ctx)
|
||||||
defer s1.Stop()
|
defer s1.Stop()
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ func TestWakuStoreProtocolNext(t *testing.T) {
|
|||||||
err = host2.Peerstore().AddProtocols(host1.ID(), string(StoreID_v20beta4))
|
err = host2.Peerstore().AddProtocols(host1.ID(), string(StoreID_v20beta4))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
s2 := NewWakuStore(host2, nil, db, 0, 0, utils.Logger())
|
s2 := NewWakuStore(host2, nil, db, utils.Logger())
|
||||||
s2.Start(ctx)
|
s2.Start(ctx)
|
||||||
defer s2.Stop()
|
defer s2.Stop()
|
||||||
|
|
||||||
|
|||||||
@ -17,7 +17,7 @@ func TestStoreQuery(t *testing.T) {
|
|||||||
msg1 := tests.CreateWakuMessage(defaultContentTopic, utils.GetUnixEpoch())
|
msg1 := tests.CreateWakuMessage(defaultContentTopic, utils.GetUnixEpoch())
|
||||||
msg2 := tests.CreateWakuMessage("2", utils.GetUnixEpoch())
|
msg2 := tests.CreateWakuMessage("2", utils.GetUnixEpoch())
|
||||||
|
|
||||||
s := NewWakuStore(nil, nil, MemoryDB(t), 0, 0, utils.Logger())
|
s := NewWakuStore(nil, nil, MemoryDB(t), utils.Logger())
|
||||||
_ = s.storeMessage(protocol.NewEnvelope(msg1, utils.GetUnixEpoch(), defaultPubSubTopic))
|
_ = s.storeMessage(protocol.NewEnvelope(msg1, utils.GetUnixEpoch(), defaultPubSubTopic))
|
||||||
_ = s.storeMessage(protocol.NewEnvelope(msg2, utils.GetUnixEpoch(), defaultPubSubTopic))
|
_ = s.storeMessage(protocol.NewEnvelope(msg2, utils.GetUnixEpoch(), defaultPubSubTopic))
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ func TestStoreQueryMultipleContentFilters(t *testing.T) {
|
|||||||
msg2 := tests.CreateWakuMessage(topic2, utils.GetUnixEpoch())
|
msg2 := tests.CreateWakuMessage(topic2, utils.GetUnixEpoch())
|
||||||
msg3 := tests.CreateWakuMessage(topic3, utils.GetUnixEpoch())
|
msg3 := tests.CreateWakuMessage(topic3, utils.GetUnixEpoch())
|
||||||
|
|
||||||
s := NewWakuStore(nil, nil, MemoryDB(t), 0, 0, utils.Logger())
|
s := NewWakuStore(nil, nil, MemoryDB(t), utils.Logger())
|
||||||
|
|
||||||
_ = s.storeMessage(protocol.NewEnvelope(msg1, utils.GetUnixEpoch(), defaultPubSubTopic))
|
_ = s.storeMessage(protocol.NewEnvelope(msg1, utils.GetUnixEpoch(), defaultPubSubTopic))
|
||||||
_ = s.storeMessage(protocol.NewEnvelope(msg2, utils.GetUnixEpoch(), defaultPubSubTopic))
|
_ = s.storeMessage(protocol.NewEnvelope(msg2, utils.GetUnixEpoch(), defaultPubSubTopic))
|
||||||
@ -77,7 +77,7 @@ func TestStoreQueryPubsubTopicFilter(t *testing.T) {
|
|||||||
msg2 := tests.CreateWakuMessage(topic2, utils.GetUnixEpoch())
|
msg2 := tests.CreateWakuMessage(topic2, utils.GetUnixEpoch())
|
||||||
msg3 := tests.CreateWakuMessage(topic3, utils.GetUnixEpoch())
|
msg3 := tests.CreateWakuMessage(topic3, utils.GetUnixEpoch())
|
||||||
|
|
||||||
s := NewWakuStore(nil, nil, MemoryDB(t), 0, 0, utils.Logger())
|
s := NewWakuStore(nil, nil, MemoryDB(t), utils.Logger())
|
||||||
_ = s.storeMessage(protocol.NewEnvelope(msg1, utils.GetUnixEpoch(), pubsubTopic1))
|
_ = s.storeMessage(protocol.NewEnvelope(msg1, utils.GetUnixEpoch(), pubsubTopic1))
|
||||||
_ = s.storeMessage(protocol.NewEnvelope(msg2, utils.GetUnixEpoch(), pubsubTopic2))
|
_ = s.storeMessage(protocol.NewEnvelope(msg2, utils.GetUnixEpoch(), pubsubTopic2))
|
||||||
_ = s.storeMessage(protocol.NewEnvelope(msg3, utils.GetUnixEpoch(), pubsubTopic2))
|
_ = s.storeMessage(protocol.NewEnvelope(msg3, utils.GetUnixEpoch(), pubsubTopic2))
|
||||||
@ -109,7 +109,7 @@ func TestStoreQueryPubsubTopicNoMatch(t *testing.T) {
|
|||||||
msg2 := tests.CreateWakuMessage(topic2, utils.GetUnixEpoch())
|
msg2 := tests.CreateWakuMessage(topic2, utils.GetUnixEpoch())
|
||||||
msg3 := tests.CreateWakuMessage(topic3, utils.GetUnixEpoch())
|
msg3 := tests.CreateWakuMessage(topic3, utils.GetUnixEpoch())
|
||||||
|
|
||||||
s := NewWakuStore(nil, nil, MemoryDB(t), 0, 0, utils.Logger())
|
s := NewWakuStore(nil, nil, MemoryDB(t), utils.Logger())
|
||||||
_ = s.storeMessage(protocol.NewEnvelope(msg1, utils.GetUnixEpoch(), pubsubTopic2))
|
_ = s.storeMessage(protocol.NewEnvelope(msg1, utils.GetUnixEpoch(), pubsubTopic2))
|
||||||
_ = s.storeMessage(protocol.NewEnvelope(msg2, utils.GetUnixEpoch(), pubsubTopic2))
|
_ = s.storeMessage(protocol.NewEnvelope(msg2, utils.GetUnixEpoch(), pubsubTopic2))
|
||||||
_ = s.storeMessage(protocol.NewEnvelope(msg3, utils.GetUnixEpoch(), pubsubTopic2))
|
_ = s.storeMessage(protocol.NewEnvelope(msg3, utils.GetUnixEpoch(), pubsubTopic2))
|
||||||
@ -131,7 +131,7 @@ func TestStoreQueryPubsubTopicAllMessages(t *testing.T) {
|
|||||||
msg2 := tests.CreateWakuMessage(topic2, utils.GetUnixEpoch())
|
msg2 := tests.CreateWakuMessage(topic2, utils.GetUnixEpoch())
|
||||||
msg3 := tests.CreateWakuMessage(topic3, utils.GetUnixEpoch())
|
msg3 := tests.CreateWakuMessage(topic3, utils.GetUnixEpoch())
|
||||||
|
|
||||||
s := NewWakuStore(nil, nil, MemoryDB(t), 0, 0, utils.Logger())
|
s := NewWakuStore(nil, nil, MemoryDB(t), utils.Logger())
|
||||||
_ = s.storeMessage(protocol.NewEnvelope(msg1, utils.GetUnixEpoch(), pubsubTopic1))
|
_ = s.storeMessage(protocol.NewEnvelope(msg1, utils.GetUnixEpoch(), pubsubTopic1))
|
||||||
_ = s.storeMessage(protocol.NewEnvelope(msg2, utils.GetUnixEpoch(), pubsubTopic1))
|
_ = s.storeMessage(protocol.NewEnvelope(msg2, utils.GetUnixEpoch(), pubsubTopic1))
|
||||||
_ = s.storeMessage(protocol.NewEnvelope(msg3, utils.GetUnixEpoch(), pubsubTopic1))
|
_ = s.storeMessage(protocol.NewEnvelope(msg3, utils.GetUnixEpoch(), pubsubTopic1))
|
||||||
@ -150,7 +150,7 @@ func TestStoreQueryForwardPagination(t *testing.T) {
|
|||||||
topic1 := "1"
|
topic1 := "1"
|
||||||
pubsubTopic1 := "topic1"
|
pubsubTopic1 := "topic1"
|
||||||
|
|
||||||
s := NewWakuStore(nil, nil, MemoryDB(t), 0, 0, utils.Logger())
|
s := NewWakuStore(nil, nil, MemoryDB(t), utils.Logger())
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
msg := tests.CreateWakuMessage(topic1, utils.GetUnixEpoch())
|
msg := tests.CreateWakuMessage(topic1, utils.GetUnixEpoch())
|
||||||
msg.Payload = []byte{byte(i)}
|
msg.Payload = []byte{byte(i)}
|
||||||
@ -174,7 +174,7 @@ func TestStoreQueryBackwardPagination(t *testing.T) {
|
|||||||
topic1 := "1"
|
topic1 := "1"
|
||||||
pubsubTopic1 := "topic1"
|
pubsubTopic1 := "topic1"
|
||||||
|
|
||||||
s := NewWakuStore(nil, nil, MemoryDB(t), 0, 0, utils.Logger())
|
s := NewWakuStore(nil, nil, MemoryDB(t), utils.Logger())
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
msg := &pb.WakuMessage{
|
msg := &pb.WakuMessage{
|
||||||
Payload: []byte{byte(i)},
|
Payload: []byte{byte(i)},
|
||||||
@ -200,7 +200,7 @@ func TestStoreQueryBackwardPagination(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTemporalHistoryQueries(t *testing.T) {
|
func TestTemporalHistoryQueries(t *testing.T) {
|
||||||
s := NewWakuStore(nil, nil, MemoryDB(t), 0, 0, utils.Logger())
|
s := NewWakuStore(nil, nil, MemoryDB(t), utils.Logger())
|
||||||
|
|
||||||
var messages []*pb.WakuMessage
|
var messages []*pb.WakuMessage
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user