2021-11-10 10:46:11 +01:00
|
|
|
package lightpush
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"crypto/rand"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
2022-11-09 15:53:01 -04:00
|
|
|
"github.com/waku-org/go-waku/tests"
|
|
|
|
"github.com/waku-org/go-waku/waku/v2/utils"
|
2021-11-10 10:46:11 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestLightPushOption(t *testing.T) {
|
|
|
|
port, err := tests.FindFreePort(t, "", 5)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
host, err := tests.MakeHost(context.Background(), port, rand.Reader)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
2023-07-19 12:25:35 -04:00
|
|
|
options := []Option{
|
2021-11-10 10:46:11 +01:00
|
|
|
WithPeer("QmWLxGxG65CZ7vRj5oNXCJvbY9WkF9d9FxuJg8cg8Y7q3"),
|
2022-08-15 13:13:45 -04:00
|
|
|
WithAutomaticPeerSelection(),
|
2023-10-16 22:12:01 +05:30
|
|
|
WithFastestPeerSelection(),
|
2023-07-19 12:25:35 -04:00
|
|
|
WithRequestID([]byte("requestID")),
|
|
|
|
WithAutomaticRequestID(),
|
2021-11-10 10:46:11 +01:00
|
|
|
}
|
|
|
|
|
2023-07-19 12:25:35 -04:00
|
|
|
params := new(lightPushParameters)
|
2021-11-10 10:46:11 +01:00
|
|
|
params.host = host
|
2022-05-30 11:55:30 -04:00
|
|
|
params.log = utils.Logger()
|
2021-11-10 10:46:11 +01:00
|
|
|
|
|
|
|
for _, opt := range options {
|
|
|
|
opt(params)
|
|
|
|
}
|
|
|
|
|
|
|
|
require.Equal(t, host, params.host)
|
|
|
|
require.NotNil(t, params.selectedPeer)
|
2023-07-19 12:25:35 -04:00
|
|
|
require.NotNil(t, params.requestID)
|
2021-11-10 10:46:11 +01:00
|
|
|
}
|