Skip to content

Commit

Permalink
Fixed serialisation issue with multiadds (#49)
Browse files Browse the repository at this point in the history
This commit was moved from ipfs/go-delegated-routing@ee4cdad
  • Loading branch information
ischasny authored Sep 15, 2022
1 parent be5d6db commit cbcf08b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions routing/http/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 routing/http/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 cbcf08b

Please sign in to comment.