Skip to content

Commit

Permalink
fix_: not enough peers to publish
Browse files Browse the repository at this point in the history
  • Loading branch information
qfrank committed May 1, 2024
1 parent 09a62b8 commit afbb823
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
23 changes: 23 additions & 0 deletions api/messenger_raw_message_resend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"testing"
"time"

"github.com/cenkalti/backoff/v3"

"go.uber.org/zap"

"github.com/status-im/status-go/eth-node/types"
Expand Down Expand Up @@ -134,6 +136,27 @@ func (s *MessengerRawMessageResendTest) createAliceBobBackendAndLogin() {
s.T().Logf("shareLogDir: %s", shareLogDir)
s.createBackendAndLogin(&s.aliceBackend, &s.aliceMessenger, "alice66", pxServerNodeENR, shareLogDir)
s.createBackendAndLogin(&s.bobBackend, &s.bobMessenger, "bob66", pxServerNodeENR, shareLogDir)

aliceWaku := s.aliceBackend.StatusNode().WakuV2Service()
bobWaku := s.bobBackend.StatusNode().WakuV2Service()
// NOTE: default MaxInterval is 10s, which is too short for the test
// TODO(frank) figure out why it takes so long for the peers to know each other
err = tt.RetryWithBackOff(func() error {
if len(aliceWaku.Peerstore().Addrs(bobWaku.PeerID())) > 0 {
return nil
}
s.T().Logf("alice don't know bob's addresses")
return errors.New("alice don't know bob's addresses")
}, func(b *backoff.ExponentialBackOff) { b.MaxInterval = 20 * time.Second })
s.Require().NoError(err)
err = tt.RetryWithBackOff(func() error {
if len(bobWaku.Peerstore().Addrs(aliceWaku.PeerID())) > 0 {
return nil
}
s.T().Logf("bob don't know alice's addresses")
return errors.New("bob don't know alice's addresses")
}, func(b *backoff.ExponentialBackOff) { b.MaxInterval = 20 * time.Second })
s.Require().NoError(err)
}

func (s *MessengerRawMessageResendTest) createBackendAndLogin(backend **GethStatusBackend, messenger **protocol.Messenger, displayName, pxServerNodeENR, shareLogDir string) {
Expand Down
5 changes: 5 additions & 0 deletions wakuv2/waku.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (

"github.com/jellydator/ttlcache/v3"
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/core/peerstore"
"github.com/libp2p/go-libp2p/p2p/protocol/identify"
"github.com/multiformats/go-multiaddr"
"google.golang.org/protobuf/proto"
Expand Down Expand Up @@ -1776,6 +1777,10 @@ func (w *Waku) PeerID() peer.ID {
return w.node.Host().ID()
}

func (w *Waku) Peerstore() peerstore.Peerstore {
return w.node.Host().Peerstore()
}

// validatePrivateKey checks the format of the given private key.
func validatePrivateKey(k *ecdsa.PrivateKey) bool {
if k == nil || k.D == nil || k.D.Sign() == 0 {
Expand Down

0 comments on commit afbb823

Please sign in to comment.