mirror of
https://github.com/getAlby/hub.git
synced 2026-08-13 12:33:39 +02:00
40 lines
913 B
Go
40 lines
913 B
Go
package tests
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/getAlby/go-nostr"
|
|
"github.com/getAlby/hub/logger"
|
|
)
|
|
|
|
type mockSimplePool struct {
|
|
PublishedEvents []*nostr.Event
|
|
}
|
|
|
|
func NewMockSimplePool() *mockSimplePool {
|
|
return &mockSimplePool{}
|
|
}
|
|
|
|
func (relay *mockSimplePool) PublishMany(ctx context.Context, relayUrls []string, event nostr.Event) chan nostr.PublishResult {
|
|
logger.Logger.WithField("event", event).Info("Mock Publishing event")
|
|
relay.PublishedEvents = append(relay.PublishedEvents, &event)
|
|
|
|
channel := make(chan nostr.PublishResult)
|
|
go func() {
|
|
channel <- nostr.PublishResult{
|
|
RelayURL: "wss://fakerelay.com",
|
|
}
|
|
close(channel)
|
|
}()
|
|
return channel
|
|
}
|
|
|
|
func (relay *mockSimplePool) QuerySingle(
|
|
ctx context.Context,
|
|
urls []string,
|
|
filter nostr.Filter,
|
|
opts ...nostr.SubscriptionOption,
|
|
) *nostr.RelayEvent {
|
|
logger.Logger.Error("Mock pool QuerySingle is not supported yet")
|
|
return nil
|
|
}
|