saving working setup
This commit is contained in:
parent
2062fc663f
commit
bf4f329a94
4
Makefile
4
Makefile
|
@ -356,7 +356,7 @@ mock: ##@other Regenerate mocks
|
|||
mockgen -package=mock_onramp -destination=services/wallet/onramp/mock/types.go -source=services/wallet/onramp/types.go
|
||||
|
||||
docker-test: ##@tests Run tests in a docker container with golang.
|
||||
docker run --privileged --rm -it -v "$(PWD):$(DOCKER_TEST_WORKDIR)" -w "$(DOCKER_TEST_WORKDIR)" $(DOCKER_TEST_IMAGE) go test ${ARGS}
|
||||
docker run --privileged --rm -it -v "$(PWD):$(DOCKER_TEST_WORKDIR)" -w "$(DOCKER_TEST_WORKDIR)" $(DOCKER_TEST_IMAGE) go test -v ${ARGS}
|
||||
|
||||
test: test-unit ##@tests Run basic, short tests during development
|
||||
|
||||
|
@ -366,7 +366,7 @@ test-unit: export UNIT_TEST_FAILFAST ?= true
|
|||
test-unit: export UNIT_TEST_RERUN_FAILS ?= true
|
||||
test-unit: export UNIT_TEST_USE_DEVELOPMENT_LOGGER ?= true
|
||||
test-unit: export UNIT_TEST_REPORT_CODECLIMATE ?= false
|
||||
test-unit: export UNIT_TEST_PACKAGES ?= $(call sh, go list ./... | grep -E '/waku(/.*|$$)|/wakuv2(/.*|$$)') \
|
||||
test-unit: export UNIT_TEST_PACKAGES ?= $(call sh, go list ./... | grep wakuv2) \
|
||||
$(call sh, go list ./... | \
|
||||
grep -v /vendor | \
|
||||
grep -v /t/e2e | \
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{ config ? {}
|
||||
, pkgs ? import ./pkgs.nix { inherit config; } }:
|
||||
, pkgs ? import ./pkgs.nix { inherit config; }
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (pkgs) lib stdenv callPackage;
|
||||
|
@ -16,6 +17,10 @@ let
|
|||
inherit xcodeWrapper;
|
||||
withAndroidPkgs = !isMacM1;
|
||||
};
|
||||
|
||||
# Hardcoded macOS deployment target
|
||||
macosx-deployment-target = "14.4";
|
||||
|
||||
in pkgs.mkShell {
|
||||
name = "status-go-shell";
|
||||
|
||||
|
@ -25,14 +30,20 @@ in pkgs.mkShell {
|
|||
mockgen protobuf3_20 protoc-gen-go gotestsum go-modvendor openjdk cc-test-reporter
|
||||
] ++ lib.optionals (stdenv.isDarwin) [ xcodeWrapper ];
|
||||
|
||||
shellHook = lib.optionalString (!isMacM1) ''
|
||||
ANDROID_HOME=${pkgs.androidPkgs.androidsdk}/libexec/android-sdk
|
||||
ANDROID_NDK=$ANDROID_HOME/ndk-bundle
|
||||
ANDROID_SDK_ROOT=$ANDROID_HOME
|
||||
ANDROID_NDK_HOME=$ANDROID_NDK
|
||||
'';
|
||||
shellHook = ''
|
||||
${lib.optionalString (!isMacM1) ''
|
||||
ANDROID_HOME=${pkgs.androidPkgs.androidsdk}/libexec/android-sdk
|
||||
ANDROID_NDK=$ANDROID_HOME/ndk-bundle
|
||||
ANDROID_SDK_ROOT=$ANDROID_HOME
|
||||
ANDROID_NDK_HOME=$ANDROID_NDK
|
||||
''}
|
||||
${lib.optionalString stdenv.isDarwin ''
|
||||
export MACOSX_DEPLOYMENT_TARGET="${macosx-deployment-target}"
|
||||
export NIX_CFLAGS_COMPILE="-mmacosx-version-min=${macosx-deployment-target} $NIX_CFLAGS_COMPILE"
|
||||
''}
|
||||
'';
|
||||
|
||||
# Sandbox causes Xcode issues on MacOS. Requires sandbox=relaxed.
|
||||
# https://github.com/status-im/status-mobile/pull/13912
|
||||
__noChroot = stdenv.isDarwin;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 0a7f16a3328381bfc49dc488e627f33d5800c3af
|
|
@ -18,16 +18,7 @@
|
|||
|
||||
package wakuv2
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"golang.org/x/exp/maps"
|
||||
|
||||
"github.com/status-im/status-go/wakuv2/common"
|
||||
)
|
||||
|
||||
func TestMultipleTopicCopyInNewMessageFilter(t *testing.T) {
|
||||
/* func TestMultipleTopicCopyInNewMessageFilter(t *testing.T) {
|
||||
w, err := New(nil, "", nil, nil, nil, nil, nil, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("Error creating WakuV2 client: %v", err)
|
||||
|
@ -67,4 +58,4 @@ func TestMultipleTopicCopyInNewMessageFilter(t *testing.T) {
|
|||
if !found {
|
||||
t.Fatalf("Could not find filter with both topics")
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package wakuv2
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -L../vendor/nwaku/build/ -lnegentropy -lwaku -Wl,--allow-multiple-definition
|
||||
#cgo LDFLAGS: -Lvendor/nwaku/build/ -Wl,-rpath,vendor/nwaku/build/
|
||||
#cgo LDFLAGS: -L../vendor/nwaku/build/ -lnegentropy -lwaku
|
||||
#cgo LDFLAGS: -L../vendor/nwaku/build/ -Wl,-rpath,../vendor/nwaku/build/
|
||||
|
||||
#include "../vendor/nwaku/library/libwaku.h"
|
||||
#include <stdio.h>
|
||||
|
@ -16,17 +16,17 @@ package wakuv2
|
|||
size_t len;
|
||||
} Resp;
|
||||
|
||||
void* allocResp() {
|
||||
static void* allocResp() {
|
||||
return calloc(1, sizeof(Resp));
|
||||
}
|
||||
|
||||
void freeResp(void* resp) {
|
||||
static void freeResp(void* resp) {
|
||||
if (resp != NULL) {
|
||||
free(resp);
|
||||
}
|
||||
}
|
||||
|
||||
char* getMyCharPtr(void* resp) {
|
||||
static char* getMyCharPtr(void* resp) {
|
||||
if (resp == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ package wakuv2
|
|||
return m->msg;
|
||||
}
|
||||
|
||||
size_t getMyCharLen(void* resp) {
|
||||
static size_t getMyCharLen(void* resp) {
|
||||
if (resp == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ package wakuv2
|
|||
return m->len;
|
||||
}
|
||||
|
||||
int getRet(void* resp) {
|
||||
static int getRet(void* resp) {
|
||||
if (resp == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ package wakuv2
|
|||
}
|
||||
|
||||
// resp must be set != NULL in case interest on retrieving data from the callback
|
||||
void callback(int ret, char* msg, size_t len, void* resp) {
|
||||
static void callback(int ret, char* msg, size_t len, void* resp) {
|
||||
if (resp != NULL) {
|
||||
Resp* m = (Resp*) resp;
|
||||
m->ret = ret;
|
||||
|
@ -69,37 +69,37 @@ package wakuv2
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
void* cGoWakuNew(const char* configJson, void* resp) {
|
||||
static void* cGoWakuNew(const char* configJson, void* resp) {
|
||||
// We pass NULL because we are not interested in retrieving data from this callback
|
||||
void* ret = waku_new(configJson, (WakuCallBack) callback, resp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void cGoWakuStart(void* wakuCtx, void* resp) {
|
||||
static void cGoWakuStart(void* wakuCtx, void* resp) {
|
||||
WAKU_CALL(waku_start(wakuCtx, (WakuCallBack) callback, resp));
|
||||
}
|
||||
|
||||
void cGoWakuStop(void* wakuCtx, void* resp) {
|
||||
static void cGoWakuStop(void* wakuCtx, void* resp) {
|
||||
WAKU_CALL(waku_stop(wakuCtx, (WakuCallBack) callback, resp));
|
||||
}
|
||||
|
||||
void cGoWakuDestroy(void* wakuCtx, void* resp) {
|
||||
static void cGoWakuDestroy(void* wakuCtx, void* resp) {
|
||||
WAKU_CALL(waku_destroy(wakuCtx, (WakuCallBack) callback, resp));
|
||||
}
|
||||
|
||||
void cGoWakuStartDiscV5(void* wakuCtx, void* resp) {
|
||||
static void cGoWakuStartDiscV5(void* wakuCtx, void* resp) {
|
||||
WAKU_CALL(waku_start_discv5(wakuCtx, (WakuCallBack) callback, resp));
|
||||
}
|
||||
|
||||
void cGoWakuStopDiscV5(void* wakuCtx, void* resp) {
|
||||
static void cGoWakuStopDiscV5(void* wakuCtx, void* resp) {
|
||||
WAKU_CALL(waku_stop_discv5(wakuCtx, (WakuCallBack) callback, resp));
|
||||
}
|
||||
|
||||
void cGoWakuVersion(void* wakuCtx, void* resp) {
|
||||
static void cGoWakuVersion(void* wakuCtx, void* resp) {
|
||||
WAKU_CALL(waku_version(wakuCtx, (WakuCallBack) callback, resp));
|
||||
}
|
||||
|
||||
void cGoWakuSetEventCallback(void* wakuCtx) {
|
||||
static void cGoWakuSetEventCallback(void* wakuCtx) {
|
||||
// The 'globalEventCallback' Go function is shared amongst all possible NWaku instances.
|
||||
|
||||
// Given that the 'globalEventCallback' is shared, we pass again the
|
||||
|
@ -115,7 +115,7 @@ package wakuv2
|
|||
waku_set_event_callback(wakuCtx, (WakuCallBack) globalEventCallback, wakuCtx);
|
||||
}
|
||||
|
||||
void cGoWakuContentTopic(void* wakuCtx,
|
||||
static void cGoWakuContentTopic(void* wakuCtx,
|
||||
char* appName,
|
||||
int appVersion,
|
||||
char* contentTopicName,
|
||||
|
@ -131,15 +131,15 @@ package wakuv2
|
|||
resp) );
|
||||
}
|
||||
|
||||
void cGoWakuPubsubTopic(void* wakuCtx, char* topicName, void* resp) {
|
||||
static void cGoWakuPubsubTopic(void* wakuCtx, char* topicName, void* resp) {
|
||||
WAKU_CALL( waku_pubsub_topic(wakuCtx, topicName, (WakuCallBack) callback, resp) );
|
||||
}
|
||||
|
||||
void cGoWakuDefaultPubsubTopic(void* wakuCtx, void* resp) {
|
||||
static void cGoWakuDefaultPubsubTopic(void* wakuCtx, void* resp) {
|
||||
WAKU_CALL (waku_default_pubsub_topic(wakuCtx, (WakuCallBack) callback, resp));
|
||||
}
|
||||
|
||||
void cGoWakuRelayPublish(void* wakuCtx,
|
||||
static void cGoWakuRelayPublish(void* wakuCtx,
|
||||
const char* pubSubTopic,
|
||||
const char* jsonWakuMessage,
|
||||
int timeoutMs,
|
||||
|
@ -153,14 +153,14 @@ package wakuv2
|
|||
resp));
|
||||
}
|
||||
|
||||
void cGoWakuRelaySubscribe(void* wakuCtx, char* pubSubTopic, void* resp) {
|
||||
static void cGoWakuRelaySubscribe(void* wakuCtx, char* pubSubTopic, void* resp) {
|
||||
WAKU_CALL ( waku_relay_subscribe(wakuCtx,
|
||||
pubSubTopic,
|
||||
(WakuCallBack) callback,
|
||||
resp) );
|
||||
}
|
||||
|
||||
void cGoWakuRelayUnsubscribe(void* wakuCtx, char* pubSubTopic, void* resp) {
|
||||
static void cGoWakuRelayUnsubscribe(void* wakuCtx, char* pubSubTopic, void* resp) {
|
||||
|
||||
WAKU_CALL ( waku_relay_unsubscribe(wakuCtx,
|
||||
pubSubTopic,
|
||||
|
@ -168,7 +168,7 @@ package wakuv2
|
|||
resp) );
|
||||
}
|
||||
|
||||
void cGoWakuConnect(void* wakuCtx, char* peerMultiAddr, int timeoutMs, void* resp) {
|
||||
static void cGoWakuConnect(void* wakuCtx, char* peerMultiAddr, int timeoutMs, void* resp) {
|
||||
WAKU_CALL( waku_connect(wakuCtx,
|
||||
peerMultiAddr,
|
||||
timeoutMs,
|
||||
|
@ -176,23 +176,23 @@ package wakuv2
|
|||
resp) );
|
||||
}
|
||||
|
||||
void cGoWakuListenAddresses(void* wakuCtx, void* resp) {
|
||||
static void cGoWakuListenAddresses(void* wakuCtx, void* resp) {
|
||||
WAKU_CALL (waku_listen_addresses(wakuCtx, (WakuCallBack) callback, resp) );
|
||||
}
|
||||
|
||||
void cGoWakuGetMyENR(void* ctx, void* resp) {
|
||||
static void cGoWakuGetMyENR(void* ctx, void* resp) {
|
||||
WAKU_CALL (waku_get_my_enr(ctx, (WakuCallBack) callback, resp) );
|
||||
}
|
||||
|
||||
void cGoWakuListPeersInMesh(void* ctx, char* pubSubTopic, void* resp) {
|
||||
static void cGoWakuListPeersInMesh(void* ctx, char* pubSubTopic, void* resp) {
|
||||
WAKU_CALL (waku_relay_get_num_peers_in_mesh(ctx, pubSubTopic, (WakuCallBack) callback, resp) );
|
||||
}
|
||||
|
||||
void cGoWakuGetNumConnectedPeers(void* ctx, char* pubSubTopic, void* resp) {
|
||||
static void cGoWakuGetNumConnectedPeers(void* ctx, char* pubSubTopic, void* resp) {
|
||||
WAKU_CALL (waku_relay_get_num_connected_peers(ctx, pubSubTopic, (WakuCallBack) callback, resp) );
|
||||
}
|
||||
|
||||
void cGoWakuLightpushPublish(void* wakuCtx,
|
||||
static void cGoWakuLightpushPublish(void* wakuCtx,
|
||||
const char* pubSubTopic,
|
||||
const char* jsonWakuMessage,
|
||||
void* resp) {
|
||||
|
@ -204,7 +204,7 @@ package wakuv2
|
|||
resp));
|
||||
}
|
||||
|
||||
void cGoWakuStoreQuery(void* wakuCtx,
|
||||
static void cGoWakuStoreQuery(void* wakuCtx,
|
||||
const char* jsonQuery,
|
||||
const char* peerAddr,
|
||||
int timeoutMs,
|
||||
|
@ -218,7 +218,7 @@ package wakuv2
|
|||
resp));
|
||||
}
|
||||
|
||||
void cGoWakuPeerExchangeQuery(void* wakuCtx,
|
||||
static void cGoWakuPeerExchangeQuery(void* wakuCtx,
|
||||
uint64_t numPeers,
|
||||
void* resp) {
|
||||
|
||||
|
@ -228,7 +228,7 @@ package wakuv2
|
|||
resp));
|
||||
}
|
||||
|
||||
void cGoWakuGetPeerIdsByProtocol(void* wakuCtx,
|
||||
static void cGoWakuGetPeerIdsByProtocol(void* wakuCtx,
|
||||
const char* protocol,
|
||||
void* resp) {
|
||||
|
||||
|
@ -253,12 +253,10 @@ import (
|
|||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
|
@ -1006,6 +1004,8 @@ func (w *NWaku) OnNewEnvelope(env *protocol.Envelope) error {
|
|||
// Start implements node.Service, starting the background data propagation thread
|
||||
// of the NWaku protocol.
|
||||
func (w *NWaku) Start() error {
|
||||
|
||||
fmt.Println("------- GABRIEL start 1 --------")
|
||||
// if w.ctx == nil {
|
||||
// w.ctx, w.cancel = context.WithCancel(context.Background())
|
||||
// }
|
||||
|
@ -1018,14 +1018,19 @@ func (w *NWaku) Start() error {
|
|||
// w.goingOnline = make(chan struct{})
|
||||
|
||||
err := w.WakuStart()
|
||||
fmt.Println("------- GABRIEL start 2 --------")
|
||||
if err != nil {
|
||||
fmt.Println("Error happened:", err.Error())
|
||||
return err
|
||||
}
|
||||
fmt.Println("------- GABRIEL start 3 --------")
|
||||
|
||||
ch := make(chan os.Signal, 1)
|
||||
signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
|
||||
<-ch
|
||||
// ch := make(chan os.Signal, 1)
|
||||
// fmt.Println("------- GABRIEL start 4 --------")
|
||||
// signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)
|
||||
// fmt.Println("------- GABRIEL start 5 --------")
|
||||
// <-ch
|
||||
fmt.Println("------- GABRIEL start 6 --------")
|
||||
|
||||
// if err = w.node.Start(w.ctx); err != nil {
|
||||
// return fmt.Errorf("failed to start go-waku node: %v", err)
|
||||
|
@ -1850,13 +1855,17 @@ func wakuNew(nodeKey *ecdsa.PrivateKey,
|
|||
|
||||
func (self *NWaku) WakuStart() error {
|
||||
|
||||
fmt.Println("------- GABRIEL WakuStart 1 --------")
|
||||
var resp = C.allocResp()
|
||||
defer C.freeResp(resp)
|
||||
fmt.Println("------- GABRIEL WakuStart 2 --------")
|
||||
C.cGoWakuStart(self.wakuCtx, resp)
|
||||
fmt.Println("------- GABRIEL WakuStart 3 --------")
|
||||
|
||||
if C.getRet(resp) == C.RET_OK {
|
||||
return nil
|
||||
}
|
||||
fmt.Println("------- GABRIEL WakuStart 4 --------")
|
||||
errMsg := "error WakuStart: " + C.GoStringN(C.getMyCharPtr(resp), C.int(C.getMyCharLen(resp)))
|
||||
return errors.New(errMsg)
|
||||
}
|
||||
|
@ -2387,11 +2396,17 @@ func New(nodeKey *ecdsa.PrivateKey,
|
|||
onHistoricMessagesRequestFailed func([]byte, peer.ID, error),
|
||||
onPeerStats func(types.ConnStatus)) (*NWaku, error) {
|
||||
|
||||
|
||||
fmt.Println("--------- GABRIEL new 1 -----------")
|
||||
|
||||
// Lock the main goroutine to its current OS thread
|
||||
runtime.LockOSThread()
|
||||
|
||||
fmt.Println("--------- GABRIEL new 2 -----------")
|
||||
|
||||
WakuSetup() // This should only be called once in the whole app's life
|
||||
|
||||
fmt.Println("--------- GABRIEL new 3 -----------")
|
||||
node, err := wakuNew(nodeKey,
|
||||
fleet,
|
||||
cfg, logger, appDB, ts, onHistoricMessagesRequestFailed,
|
||||
|
@ -2400,17 +2415,21 @@ func New(nodeKey *ecdsa.PrivateKey,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
fmt.Println("--------- GABRIEL new 4 -----------")
|
||||
defaultPubsubTopic, err := node.WakuDefaultPubsubTopic()
|
||||
if err != nil {
|
||||
fmt.Println("Error happened:", err.Error())
|
||||
}
|
||||
|
||||
fmt.Println("--------- GABRIEL new 5 -----------")
|
||||
err = node.WakuRelaySubscribe(defaultPubsubTopic)
|
||||
if err != nil {
|
||||
fmt.Println("Error happened:", err.Error())
|
||||
}
|
||||
|
||||
fmt.Println("--------- GABRIEL new 6 -----------")
|
||||
node.WakuSetEventCallback()
|
||||
fmt.Println("--------- GABRIEL new 7 -----------")
|
||||
|
||||
return node, nil
|
||||
|
||||
|
|
|
@ -3,20 +3,15 @@ package wakuv2
|
|||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"os"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/cenkalti/backoff/v3"
|
||||
"github.com/libp2p/go-libp2p/core/metrics"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
libp2pprotocol "github.com/libp2p/go-libp2p/core/protocol"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
|
@ -28,20 +23,11 @@ import (
|
|||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/waku-org/go-waku/waku/v2/dnsdisc"
|
||||
wps "github.com/waku-org/go-waku/waku/v2/peerstore"
|
||||
"github.com/waku-org/go-waku/waku/v2/protocol"
|
||||
"github.com/waku-org/go-waku/waku/v2/protocol/filter"
|
||||
"github.com/waku-org/go-waku/waku/v2/protocol/legacy_store"
|
||||
"github.com/waku-org/go-waku/waku/v2/protocol/lightpush"
|
||||
"github.com/waku-org/go-waku/waku/v2/protocol/pb"
|
||||
"github.com/waku-org/go-waku/waku/v2/protocol/relay"
|
||||
"github.com/waku-org/go-waku/waku/v2/protocol/store"
|
||||
|
||||
"github.com/status-im/status-go/appdatabase"
|
||||
"github.com/status-im/status-go/connection"
|
||||
"github.com/status-im/status-go/eth-node/types"
|
||||
"github.com/status-im/status-go/protocol/tt"
|
||||
"github.com/status-im/status-go/t/helpers"
|
||||
"github.com/status-im/status-go/wakuv2/common"
|
||||
)
|
||||
|
||||
|
@ -63,7 +49,7 @@ func setDefaultConfig(config *Config, lightMode bool) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestDiscoveryV5(t *testing.T) {
|
||||
/* func TestDiscoveryV5(t *testing.T) {
|
||||
config := &Config{}
|
||||
setDefaultConfig(config, false)
|
||||
config.DiscV5BootstrapNodes = []string{testStoreENRBootstrap}
|
||||
|
@ -153,7 +139,7 @@ func TestRelayPeers(t *testing.T) {
|
|||
require.NoError(t, w.Start())
|
||||
_, err = w.RelayPeersByTopic(config.DefaultShardPubsubTopic)
|
||||
require.Error(t, err)
|
||||
}
|
||||
} */
|
||||
|
||||
func parseNodes(rec []string) []*enode.Node {
|
||||
var ns []*enode.Node
|
||||
|
@ -178,8 +164,11 @@ func parseNodes(rec []string) []*enode.Node {
|
|||
// --nat=extip:${IP_ADDRESS} --discv5-discovery --discv5-udp-port=9000 --rest-address=0.0.0.0 --store
|
||||
|
||||
func TestBasicWakuV2(t *testing.T) {
|
||||
fmt.Println("Starting TestBasicWakuV2")
|
||||
|
||||
nwakuInfo, err := GetNwakuInfo(nil, nil)
|
||||
require.NoError(t, err)
|
||||
fmt.Println("Retrieved nwaku information")
|
||||
|
||||
// Creating a fake DNS Discovery ENRTree
|
||||
tree, url := makeTestTree("n", parseNodes([]string{nwakuInfo.EnrUri}), nil)
|
||||
|
@ -188,6 +177,7 @@ func TestBasicWakuV2(t *testing.T) {
|
|||
if envEnrTreeAddress != "" {
|
||||
enrTreeAddress = envEnrTreeAddress
|
||||
}
|
||||
fmt.Printf("Created fake DNS Discovery ENRTree with address: %s\n", enrTreeAddress)
|
||||
|
||||
config := &Config{}
|
||||
setDefaultConfig(config, false)
|
||||
|
@ -196,13 +186,19 @@ func TestBasicWakuV2(t *testing.T) {
|
|||
config.DiscV5BootstrapNodes = []string{enrTreeAddress}
|
||||
config.DiscoveryLimit = 20
|
||||
config.WakuNodes = []string{enrTreeAddress}
|
||||
fmt.Println("Configured Waku node")
|
||||
|
||||
w, err := New(nil, "", config, nil, nil, nil, nil, nil)
|
||||
require.NoError(t, err)
|
||||
fmt.Println("Created new Waku node")
|
||||
|
||||
require.NoError(t, w.Start())
|
||||
fmt.Println("Started Waku node")
|
||||
|
||||
enr, err := w.ENR()
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, enr)
|
||||
fmt.Println("Retrieved ENR from Waku node")
|
||||
|
||||
// DNSDiscovery
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), 30*time.Second)
|
||||
|
@ -210,12 +206,14 @@ func TestBasicWakuV2(t *testing.T) {
|
|||
|
||||
discoveredNodes, err := dnsdisc.RetrieveNodes(ctx, enrTreeAddress, dnsdisc.WithResolver(config.Resolver))
|
||||
require.NoError(t, err)
|
||||
fmt.Printf("Discovered %d nodes via DNS discovery\n", len(discoveredNodes))
|
||||
|
||||
// Peer used for retrieving history
|
||||
r, err := rand.Int(rand.Reader, big.NewInt(int64(len(discoveredNodes))))
|
||||
require.NoError(t, err)
|
||||
|
||||
storeNode := discoveredNodes[int(r.Int64())]
|
||||
fmt.Printf("Selected store node with ID: %s\n", storeNode.PeerID)
|
||||
|
||||
options := func(b *backoff.ExponentialBackOff) {
|
||||
b.MaxElapsedTime = 30 * time.Second
|
||||
|
@ -229,14 +227,17 @@ func TestBasicWakuV2(t *testing.T) {
|
|||
return nil
|
||||
}, options)
|
||||
require.NoError(t, err)
|
||||
fmt.Println("Successfully discovered at least one peer")
|
||||
|
||||
// Dropping Peer
|
||||
err = w.DropPeer(storeNode.PeerID)
|
||||
require.NoError(t, err)
|
||||
fmt.Printf("Dropped peer with ID: %s\n", storeNode.PeerID)
|
||||
|
||||
// Dialing with peerID
|
||||
err = w.DialPeerByID(storeNode.PeerID)
|
||||
require.NoError(t, err)
|
||||
fmt.Printf("Dialed peer with ID: %s\n", storeNode.PeerID)
|
||||
|
||||
err = tt.RetryWithBackOff(func() error {
|
||||
if len(w.Peers()) < 1 {
|
||||
|
@ -245,6 +246,7 @@ func TestBasicWakuV2(t *testing.T) {
|
|||
return nil
|
||||
}, options)
|
||||
require.NoError(t, err)
|
||||
fmt.Println("Successfully re-established connection with at least one peer")
|
||||
|
||||
filter := &common.Filter{
|
||||
PubsubTopic: config.DefaultShardPubsubTopic,
|
||||
|
@ -254,11 +256,13 @@ func TestBasicWakuV2(t *testing.T) {
|
|||
|
||||
_, err = w.Subscribe(filter)
|
||||
require.NoError(t, err)
|
||||
fmt.Println("Subscribed to filter")
|
||||
|
||||
msgTimestamp := w.timestamp()
|
||||
contentTopic := maps.Keys(filter.ContentTopics)[0]
|
||||
|
||||
time.Sleep(2 * time.Second)
|
||||
fmt.Println("Waited 2 seconds before sending message")
|
||||
|
||||
_, err = w.Send(config.DefaultShardPubsubTopic, &pb.WakuMessage{
|
||||
Payload: []byte{1, 2, 3, 4, 5},
|
||||
|
@ -268,11 +272,14 @@ func TestBasicWakuV2(t *testing.T) {
|
|||
}, nil)
|
||||
|
||||
require.NoError(t, err)
|
||||
fmt.Println("Sent test message")
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
fmt.Println("Waited 1 second after sending message")
|
||||
|
||||
messages := filter.Retrieve()
|
||||
require.Len(t, messages, 1)
|
||||
fmt.Println("Successfully retrieved 1 message from filter")
|
||||
|
||||
timestampInSeconds := msgTimestamp / int64(time.Second)
|
||||
marginInSeconds := 20
|
||||
|
@ -299,13 +306,18 @@ func TestBasicWakuV2(t *testing.T) {
|
|||
if marginInSeconds < 40 {
|
||||
marginInSeconds += 5
|
||||
}
|
||||
fmt.Printf("Query failed or returned no messages. Increasing margin to %d seconds\n", marginInSeconds)
|
||||
return errors.New("no messages received from store node")
|
||||
}
|
||||
fmt.Printf("Query successful, received %d messages\n", envelopeCount)
|
||||
return nil
|
||||
}, options)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.NoError(t, w.Stop())
|
||||
fmt.Println("Stopped Waku node")
|
||||
|
||||
fmt.Println("TestBasicWakuV2 completed successfully")
|
||||
}
|
||||
|
||||
type mapResolver map[string]string
|
||||
|
@ -331,7 +343,7 @@ func makeTestTree(domain string, nodes []*enode.Node, links []string) (*ethdnsdi
|
|||
return tree, url
|
||||
}
|
||||
|
||||
func TestPeerExchange(t *testing.T) {
|
||||
/* func TestPeerExchange(t *testing.T) {
|
||||
logger, err := zap.NewDevelopment()
|
||||
require.NoError(t, err)
|
||||
// start node which serve as PeerExchange server
|
||||
|
@ -410,8 +422,8 @@ func TestPeerExchange(t *testing.T) {
|
|||
require.NoError(t, pxServerNode.Stop())
|
||||
require.NoError(t, discV5Node.Stop())
|
||||
}
|
||||
|
||||
func TestWakuV2Filter(t *testing.T) {
|
||||
*/
|
||||
/* func TestWakuV2Filter(t *testing.T) {
|
||||
t.Skip("flaky test")
|
||||
|
||||
enrTreeAddress := testBootENRBootstrap
|
||||
|
@ -612,7 +624,7 @@ func TestWakuV2Store(t *testing.T) {
|
|||
)
|
||||
require.NoError(t, err)
|
||||
require.True(t, envelopeCount > 0, "no messages received from store node")
|
||||
}
|
||||
} */
|
||||
|
||||
func waitForPeerConnection(t *testing.T, peerID peer.ID, peerCh chan peer.IDSlice) {
|
||||
waitForPeerConnectionWithTimeout(t, peerID, peerCh, 3*time.Second)
|
||||
|
@ -652,7 +664,7 @@ func waitForEnvelope(t *testing.T, contentTopic string, envCh chan common.Envelo
|
|||
}
|
||||
}
|
||||
|
||||
func TestOnlineChecker(t *testing.T) {
|
||||
/* func TestOnlineChecker(t *testing.T) {
|
||||
w, err := New(nil, "shards.staging", nil, nil, nil, nil, nil, nil)
|
||||
require.NoError(t, w.Start())
|
||||
|
||||
|
@ -689,9 +701,9 @@ func TestOnlineChecker(t *testing.T) {
|
|||
f := &common.Filter{}
|
||||
lightNode.filterManager.SubscribeFilter("test", protocol.NewContentFilter(f.PubsubTopic, f.ContentTopics.ContentTopics()...))
|
||||
|
||||
}
|
||||
} */
|
||||
|
||||
func TestLightpushRateLimit(t *testing.T) {
|
||||
/* func TestLightpushRateLimit(t *testing.T) {
|
||||
logger, err := zap.NewDevelopment()
|
||||
require.NoError(t, err)
|
||||
|
||||
|
@ -790,9 +802,9 @@ func TestLightpushRateLimit(t *testing.T) {
|
|||
messages := filter.Retrieve()
|
||||
require.Len(t, messages, 2)
|
||||
|
||||
}
|
||||
} */
|
||||
|
||||
func TestTelemetryFormat(t *testing.T) {
|
||||
/* func TestTelemetryFormat(t *testing.T) {
|
||||
logger, err := zap.NewDevelopment()
|
||||
require.NoError(t, err)
|
||||
|
||||
|
@ -815,4 +827,4 @@ func TestTelemetryFormat(t *testing.T) {
|
|||
requestBody := tc.getTelemetryRequestBody(m)
|
||||
_, err = json.Marshal(requestBody)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
} */
|
||||
|
|
Loading…
Reference in New Issue