-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: boost provider retrieval-transports CLI command
- Loading branch information
Showing
9 changed files
with
178 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/multiformats/go-multiaddr" | ||
"github.com/stretchr/testify/require" | ||
"testing" | ||
) | ||
|
||
func TestMultiaddrToNative(t *testing.T) { | ||
testCases := []struct { | ||
name string | ||
proto string | ||
ma string | ||
expected string | ||
}{{ | ||
name: "http", | ||
proto: "http", | ||
ma: "/dns/foo.com/http", | ||
expected: "http://foo.com", | ||
}, { | ||
name: "http IP 4 address", | ||
proto: "http", | ||
ma: "/ip4/192.168.0.1/tcp/80/http", | ||
expected: "http://192.168.0.1:80", | ||
}, { | ||
name: "https", | ||
proto: "https", | ||
ma: "/dns/foo.com/tcp/443/https", | ||
expected: "https://foo.com:443", | ||
}, { | ||
name: "unknown protocol", | ||
proto: "fancynewproto", | ||
ma: "/dns/foo.com/tcp/80/http", | ||
expected: "", | ||
}} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
ma, err := multiaddr.NewMultiaddr(tc.ma) | ||
require.NoError(t, err) | ||
res := multiaddrToNative(tc.proto, ma) | ||
require.Equal(t, tc.expected, res) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters