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

Fixed the issue with payload serialisation when a multiaddr is present for provider #49

Merged
merged 1 commit into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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