@@ -13,8 +13,10 @@ import (
1313 "github.com/ipfs/kubo/config"
1414 "github.com/ipfs/kubo/test/cli/harness"
1515 . "github.com/ipfs/kubo/test/cli/testutils"
16+ "github.com/libp2p/go-libp2p/core/peer"
1617 "github.com/multiformats/go-multiaddr"
1718 manet "github.com/multiformats/go-multiaddr/net"
19+ "github.com/multiformats/go-multibase"
1820 "github.com/stretchr/testify/assert"
1921 "github.com/stretchr/testify/require"
2022)
@@ -25,10 +27,13 @@ func TestGateway(t *testing.T) {
2527 node := h .NewNode ().Init ().StartDaemon ("--offline" )
2628 cid := node .IPFSAddStr ("Hello Worlds!" )
2729
30+ peerID , err := peer .ToCid (node .PeerID ()).StringOfBase (multibase .Base36 )
31+ assert .Nil (t , err )
32+
2833 client := node .GatewayClient ()
2934 client .TemplateData = map [string ]string {
3035 "CID" : cid ,
31- "PeerID" : node . PeerID (). String () ,
36+ "PeerID" : peerID ,
3237 }
3338
3439 t .Run ("GET IPFS path succeeds" , func (t * testing.T ) {
@@ -182,7 +187,7 @@ func TestGateway(t *testing.T) {
182187 t .Run ("GET /ipfs/ipns/{peerid} returns redirect to the valid path" , func (t * testing.T ) {
183188 t .Parallel ()
184189 resp := client .Get ("/ipfs/ipns/{{.PeerID}}?query=to-remember" )
185- peerID := node . PeerID (). String ()
190+
186191 assert .Contains (t ,
187192 resp .Body ,
188193 fmt .Sprintf (`<meta http-equiv="refresh" content="10;url=/ipns/%s?query=to-remember" />` , peerID ),
@@ -474,6 +479,9 @@ func TestGateway(t *testing.T) {
474479 cfg .Gateway .NoFetch = true
475480 })
476481
482+ node2PeerID , err := peer .ToCid (node2 .PeerID ()).StringOfBase (multibase .Base36 )
483+ assert .Nil (t , err )
484+
477485 nodes .StartDaemons ().Connect ()
478486
479487 t .Run ("not present" , func (t * testing.T ) {
@@ -486,7 +494,7 @@ func TestGateway(t *testing.T) {
486494
487495 t .Run ("not present IPNS key from node 1" , func (t * testing.T ) {
488496 t .Parallel ()
489- assert .Equal (t , 500 , node1 .GatewayClient ().Get ("/ipns/" + node2 . PeerID (). String () ).StatusCode )
497+ assert .Equal (t , 500 , node1 .GatewayClient ().Get ("/ipns/" + node2PeerID ).StatusCode )
490498 })
491499 })
492500
@@ -501,8 +509,7 @@ func TestGateway(t *testing.T) {
501509 t .Run ("present IPNS key from node 1" , func (t * testing.T ) {
502510 t .Parallel ()
503511 node2 .IPFS ("name" , "publish" , "/ipfs/" + cidBar )
504- assert .Equal (t , 200 , node1 .GatewayClient ().Get ("/ipns/" + node2 .PeerID ().String ()).StatusCode )
505-
512+ assert .Equal (t , 200 , node1 .GatewayClient ().Get ("/ipns/" + node2PeerID ).StatusCode )
506513 })
507514 })
508515 })
0 commit comments