go-waku/waku/v2/rpc/relay_test.go

56 lines
991 B
Go
Raw Normal View History

package rpc
import (
"context"
"testing"
"github.com/status-im/go-waku/waku/v2/node"
"github.com/stretchr/testify/require"
)
func makeRelayService(t *testing.T) *RelayService {
options := node.WithWakuRelay()
n, err := node.New(context.Background(), options)
require.NoError(t, err)
err = n.Start()
require.NoError(t, err)
return &RelayService{n}
}
func TestPostV1Message(t *testing.T) {
var reply SuccessReply
d := makeRelayService(t)
err := d.PostV1Message(
makeRequest(t),
&RelayMessageArgs{},
&reply,
)
require.NoError(t, err)
require.True(t, reply.Success)
}
2021-11-17 16:04:54 +00:00
func TestRelaySubscription(t *testing.T) {
var reply SuccessReply
d := makeRelayService(t)
args := &TopicsArgs{Topics: []string{"test"}}
err := d.PostV1Subscription(
makeRequest(t),
args,
&reply,
)
require.NoError(t, err)
require.True(t, reply.Success)
err = d.DeleteV1Subscription(
makeRequest(t),
args,
&reply,
)
require.NoError(t, err)
require.True(t, reply.Success)
}