feat: bump to libp2p 0.23

Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
This commit is contained in:
gfanton 2022-11-08 15:59:16 +01:00
parent 5b527303a3
commit 9eac124763
7 changed files with 245 additions and 807 deletions

View File

@ -2,10 +2,12 @@ package rendezvous
import (
"context"
"github.com/libp2p/go-libp2p-core/peer"
"testing"
"time"
"github.com/libp2p/go-libp2p-core/peer"
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-rendezvous/test_utils"
)
@ -26,7 +28,10 @@ func TestClientRegistrationAndDiscovery(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
hosts := getRendezvousHosts(t, ctx, 5)
m := mocknet.New()
defer m.Close()
hosts := getRendezvousHosts(t, ctx, m, 5)
svc, err := makeRendezvousService(ctx, hosts[0], ":memory:")
if err != nil {
@ -91,7 +96,10 @@ func TestClientRegistrationAndDiscoveryAsync(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
hosts := getRendezvousHosts(t, ctx, 5)
m := mocknet.New()
defer m.Close()
hosts := getRendezvousHosts(t, ctx, m, 5)
svc, err := makeRendezvousService(ctx, hosts[0], ":memory:")
if err != nil {

View File

@ -9,6 +9,7 @@ import (
"github.com/libp2p/go-libp2p-core/discovery"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/peer"
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
)
func getRendezvousDiscovery(hosts []host.Host) []discovery.Discovery {
@ -49,13 +50,16 @@ func TestDiscoveryClientAdvertiseAndFindPeers(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
m := mocknet.New()
defer m.Close()
// Define parameters
const namespace = "foo1"
const numClients = 4
const ttl = DefaultTTL * time.Second
// Instantiate server and clients
hosts := getRendezvousHosts(t, ctx, numClients+1)
hosts := getRendezvousHosts(t, ctx, m, numClients+1)
svc, err := makeRendezvousService(ctx, hosts[0], ":memory:")
if err != nil {
@ -106,8 +110,11 @@ func BaseDiscoveryClientCacheExpirationTest(t *testing.T, onlyRequestFromCache b
const longTTL = DefaultTTL * time.Second
const shortTTL = 2 * time.Second
m := mocknet.New()
defer m.Close()
// Instantiate server and clients
hosts := getRendezvousHosts(t, ctx, numBaseRegs+3)
hosts := getRendezvousHosts(t, ctx, m, numBaseRegs+3)
svc, err := makeRendezvousService(ctx, hosts[0], ":memory:")
if err != nil {

65
go.mod
View File

@ -1,16 +1,65 @@
module github.com/libp2p/go-libp2p-rendezvous
go 1.15
go 1.18
require (
github.com/gogo/protobuf v1.3.2
github.com/golang/protobuf v1.5.2
github.com/google/uuid v1.1.1
github.com/ipfs/go-log/v2 v2.1.3
github.com/libp2p/go-libp2p-blankhost v0.2.0
github.com/libp2p/go-libp2p-core v0.10.0
github.com/libp2p/go-libp2p-swarm v0.6.0
github.com/mattn/go-sqlite3 v1.14.4
github.com/multiformats/go-multiaddr v0.4.0
github.com/google/uuid v1.3.0
github.com/ipfs/go-log/v2 v2.5.1
github.com/libp2p/go-libp2p v0.23.0
github.com/libp2p/go-libp2p-core v0.20.1
github.com/mattn/go-sqlite3 v1.14.16
github.com/multiformats/go-multiaddr v0.7.0
github.com/mutecomm/go-sqlcipher/v4 v4.4.2
github.com/stretchr/testify v1.8.0
)
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/google/gopacket v1.1.19 // indirect
github.com/huin/goupnp v1.0.3 // indirect
github.com/ipfs/go-cid v0.3.2 // indirect
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
github.com/klauspost/cpuid/v2 v2.1.1 // indirect
github.com/koron/go-ssdp v0.0.3 // indirect
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
github.com/libp2p/go-cidranger v1.1.0 // indirect
github.com/libp2p/go-libp2p-asn-util v0.2.0 // indirect
github.com/libp2p/go-msgio v0.2.0 // indirect
github.com/libp2p/go-nat v0.1.0 // indirect
github.com/libp2p/go-netroute v0.2.0 // indirect
github.com/libp2p/go-openssl v0.1.0 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mattn/go-pointer v0.0.1 // indirect
github.com/miekg/dns v1.1.50 // indirect
github.com/minio/sha256-simd v1.0.0 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/multiformats/go-base32 v0.1.0 // indirect
github.com/multiformats/go-base36 v0.1.0 // indirect
github.com/multiformats/go-multiaddr-dns v0.3.1 // indirect
github.com/multiformats/go-multiaddr-fmt v0.1.0 // indirect
github.com/multiformats/go-multibase v0.1.1 // indirect
github.com/multiformats/go-multicodec v0.6.0 // indirect
github.com/multiformats/go-multihash v0.2.1 // indirect
github.com/multiformats/go-multistream v0.3.3 // indirect
github.com/multiformats/go-varint v0.0.6 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.23.0 // indirect
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/net v0.0.0-20220920183852-bf014ff85ad5 // indirect
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
golang.org/x/tools v0.1.12 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/blake3 v1.1.7 // indirect
)

925
go.sum generated

File diff suppressed because it is too large Load Diff

View File

@ -11,14 +11,15 @@ import (
"github.com/libp2p/go-libp2p-core/host"
inet "github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
db "github.com/libp2p/go-libp2p-rendezvous/db/sqlite"
pb "github.com/libp2p/go-libp2p-rendezvous/pb"
"github.com/libp2p/go-libp2p-rendezvous/test_utils"
)
func getRendezvousHosts(t *testing.T, ctx context.Context, n int) []host.Host {
return test_utils.GetRendezvousHosts(t, ctx, n)
func getRendezvousHosts(t *testing.T, ctx context.Context, m mocknet.Mocknet, n int) []host.Host {
return test_utils.GetRendezvousHosts(t, ctx, m, n)
}
func makeRendezvousService(ctx context.Context, host host.Host, path string) (*RendezvousService, error) {
@ -42,7 +43,10 @@ func TestSVCRegistrationAndDiscovery(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
hosts := getRendezvousHosts(t, ctx, 5)
m := mocknet.New()
defer m.Close()
hosts := getRendezvousHosts(t, ctx, m, 5)
svc, err := makeRendezvousService(ctx, hosts[0], ":memory:")
if err != nil {
@ -163,7 +167,10 @@ func TestSVCErrors(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
hosts := getRendezvousHosts(t, ctx, 2)
m := mocknet.New()
defer m.Close()
hosts := getRendezvousHosts(t, ctx, m, 2)
svc, err := makeRendezvousService(ctx, hosts[0], ":memory:")
if err != nil {

View File

@ -11,6 +11,7 @@ import (
rendezvous "github.com/libp2p/go-libp2p-rendezvous"
db "github.com/libp2p/go-libp2p-rendezvous/db/sqlite"
"github.com/libp2p/go-libp2p-rendezvous/test_utils"
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
)
func makeRendezvousService(ctx context.Context, host host.Host, path string, rzs ...rendezvous.RendezvousSync) (*rendezvous.RendezvousService, error) {
@ -37,8 +38,11 @@ func TestFlow(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
m := mocknet.New()
defer m.Close()
// Instantiate server and clients
hosts := test_utils.GetRendezvousHosts(t, ctx, 4)
hosts := test_utils.GetRendezvousHosts(t, ctx, m, 4)
inmemPubSubSync, err := rendezvous.NewSyncInMemProvider(hosts[0])
if err != nil {

View File

@ -4,29 +4,31 @@ import (
"context"
"testing"
bhost "github.com/libp2p/go-libp2p-blankhost"
"github.com/libp2p/go-libp2p-core/host"
"github.com/libp2p/go-libp2p-core/peer"
testutil "github.com/libp2p/go-libp2p-swarm/testing"
mocknet "github.com/libp2p/go-libp2p/p2p/net/mock"
"github.com/stretchr/testify/require"
)
func GetRendezvousHosts(t *testing.T, ctx context.Context, n int) []host.Host {
hosts := GetNetHosts(t, ctx, n)
func GetRendezvousHosts(t *testing.T, ctx context.Context, m mocknet.Mocknet, n int) []host.Host {
hosts := GetNetHosts(t, ctx, m, n)
for i := 1; i < len(hosts); i++ {
Connect(t, hosts[0], hosts[i])
}
return hosts
}
func GetNetHosts(t *testing.T, ctx context.Context, n int) []host.Host {
func GetNetHosts(t *testing.T, ctx context.Context, m mocknet.Mocknet, n int) []host.Host {
var out []host.Host
for i := 0; i < n; i++ {
netw := testutil.GenSwarm(t)
h := bhost.NewBlankHost(netw)
h, err := m.GenPeer()
require.NoError(t, err)
out = append(out, h)
}
err := m.LinkAll()
require.NoError(t, err)
return out
}