Skip to content
This repository has been archived by the owner on Mar 28, 2023. It is now read-only.

Commit

Permalink
Fixed serialisation issue with multiadds (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
ischasny authored Sep 15, 2022
1 parent 6e05750 commit ee4cdad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions client/provide.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ func bytesToMA(b []byte) (interface{}, error) {
return multiaddr.NewMultiaddrBytes(b)
}
func maToBytes(iface interface{}) ([]byte, error) {
if ma, ok := iface.(multiaddr.Multiaddr); ok {
return ma.Bytes(), nil
if ma, ok := iface.(*multiaddr.Multiaddr); ok {
return (*ma).Bytes(), nil
}
return nil, fmt.Errorf("did not get expected MA type")
}
Expand Down
10 changes: 8 additions & 2 deletions test/provide_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/libp2p/go-libp2p-core/crypto"
"github.com/libp2p/go-libp2p-core/peer"
multiaddr "github.com/multiformats/go-multiaddr"
"github.com/multiformats/go-multicodec"
"github.com/multiformats/go-multihash"
)

Expand All @@ -34,12 +35,17 @@ func TestProvideRoundtrip(t *testing.T) {
t.Fatal("should get sync error on unsigned provide request.")
}

ma, err := multiaddr.NewMultiaddr("/ip4/0.0.0.0/tcp/4001")
if err != nil {
t.Fatal(err)
}

c, s := createClientAndServer(t, testDelegatedRoutingService{}, &client.Provider{
Peer: peer.AddrInfo{
ID: pID,
Addrs: []multiaddr.Multiaddr{},
Addrs: []multiaddr.Multiaddr{ma},
},
ProviderProto: []client.TransferProtocol{},
ProviderProto: []client.TransferProtocol{{Codec: multicodec.TransportBitswap}},
}, priv)
defer s.Close()

Expand Down

0 comments on commit ee4cdad

Please sign in to comment.