Commit 2a406f6e authored by tavit ohanian's avatar tavit ohanian

Merge branch 'port-2021-08-16'

parents fe7a8c2e 5f9e6c96
Pipeline #895 passed with stages
in 18 seconds
# File managed by web3-bot. DO NOT EDIT.
# See https://github.com/protocol/.github/ for details.
# Automatically merge pull requests opened by web3-bot, as soon as (and only if) all tests pass.
# This reduces the friction associated with updating with our workflows.
on: [ pull_request ]
name: Automerge
jobs:
automerge-check:
if: github.event.pull_request.user.login == 'web3-bot'
runs-on: ubuntu-latest
outputs:
status: ${{ steps.should-automerge.outputs.status }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Check if we should automerge
id: should-automerge
run: |
for commit in $(git rev-list --first-parent origin/${{ github.event.pull_request.base.ref }}..${{ github.event.pull_request.head.sha }}); do
committer=$(git show --format=$'%ce' -s $commit)
echo "Committer: $committer"
if [[ "$committer" != "web3-bot@users.noreply.github.com" ]]; then
echo "Commit $commit wasn't committed by web3-bot, but by $committer."
echo "::set-output name=status::false"
exit
fi
done
echo "::set-output name=status::true"
automerge:
needs: automerge-check
runs-on: ubuntu-latest
if: ${{ needs.automerge-check.outputs.status == 'true' }}
steps:
- name: Wait on tests
uses: lewagon/wait-on-check-action@bafe56a6863672c681c3cf671f5e10b20abf2eaa # v0.2
with:
ref: ${{ github.event.pull_request.head.sha }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 10
running-workflow-name: 'automerge' # the name of this job
- name: Merge PR
uses: pascalgn/automerge-action@741c311a47881be9625932b0a0de1b0937aab1ae # v0.13.1
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
MERGE_LABELS: ""
MERGE_METHOD: "squash"
MERGE_DELETE_BRANCH: true
# File managed by web3-bot. DO NOT EDIT.
# See https://github.com/protocol/.github/ for details.
on: [push, pull_request]
name: Go Checks
jobs:
unit:
runs-on: ubuntu-latest
name: All
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: actions/setup-go@v2
with:
go-version: "1.16.x"
- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@434f5f3816b358fe468fa83dcba62d794e7fe04b # 2021.1 (v0.2.0)
- name: Check that go.mod is tidy
uses: protocol/multiple-go-modules@v1.0
with:
run: |
go mod tidy
if [[ -n $(git ls-files --other --exclude-standard --directory -- go.sum) ]]; then
echo "go.sum was added by go mod tidy"
exit 1
fi
git diff --exit-code -- go.sum go.mod
- name: gofmt
if: ${{ success() || failure() }} # run this step even if the previous one failed
run: |
out=$(gofmt -s -l .)
if [[ -n "$out" ]]; then
echo $out | awk '{print "::error file=" $0 ",line=0,col=0::File is not gofmt-ed."}'
exit 1
fi
- name: go vet
if: ${{ success() || failure() }} # run this step even if the previous one failed
uses: protocol/multiple-go-modules@v1.0
with:
run: go vet ./...
- name: staticcheck
if: ${{ success() || failure() }} # run this step even if the previous one failed
uses: protocol/multiple-go-modules@v1.0
with:
run: |
set -o pipefail
staticcheck ./... | sed -e 's@\(.*\)\.go@./\1.go@g'
# File managed by web3-bot. DO NOT EDIT.
# See https://github.com/protocol/.github/ for details.
on: [push, pull_request]
name: Go Test
jobs:
unit:
strategy:
fail-fast: false
matrix:
os: [ "ubuntu", "windows", "macos" ]
go: [ "1.15.x", "1.16.x" ]
runs-on: ${{ matrix.os }}-latest
name: ${{ matrix.os}} (go ${{ matrix.go }})
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Go information
run: |
go version
go env
- name: Run tests
uses: protocol/multiple-go-modules@v1.0
with:
run: go test -v -coverprofile coverage.txt ./...
- name: Run tests (32 bit)
if: ${{ matrix.os != 'macos' }} # can't run 32 bit tests on OSX.
uses: protocol/multiple-go-modules@v1.0
env:
GOARCH: 386
with:
run: go test -v ./...
- name: Run tests with race detector
if: ${{ matrix.os == 'ubuntu' }} # speed things up. Windows and OSX VMs are slow
uses: protocol/multiple-go-modules@v1.0
with:
run: go test -v -race ./...
- name: Upload coverage to Codecov
uses: codecov/codecov-action@a1ed4b322b4b38cb846afb5a0ebfa17086917d27 # v1.5.0
with:
file: coverage.txt
env_vars: OS=${{ matrix.os }}, GO=${{ matrix.go }}
stages:
- build
- test
variables:
BUILD_DIR: "/tmp/$CI_CONCURRENT_PROJECT_ID"
before_script:
- mkdir -p $BUILD_DIR/src
- cd $BUILD_DIR/src
- if [ -d $CI_PROJECT_DIR ]
- then
- echo "soft link $CI_PROJECT_DIR exists"
- else
- echo "creating soft link $CI_PROJECT_DIR"
- ln -s $CI_PROJECT_DIR
- fi
- cd $CI_PROJECT_DIR
build:
stage: build
tags:
- testing
script:
- echo $CI_JOB_STAGE
- go build
test:
stage: test
tags:
- testing
script:
- echo $CI_JOB_STAGE
- go test -cover
coverage: '/coverage: \d+.\d+% of statements/'
1.2.11: QmUrZZavcArYChpibtP8KgQXsAEpvgzUk73B2oj3HLbWc4
The MIT License (MIT)
Copyright (c) 2016 Jeromy Johnson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
# go-multiaddr-fmt
# multiaddr format
A validation checker for multiaddrs. Some basic validators for common address
types are provided, but creating your own combinations is easy.
dms3 go-multiaddr-fmt
\ No newline at end of file
Usage:
```go
a, _ := ma.NewMultiaddr("/ip4/5.2.67.3/tcp/1708")
TCP.Matches(a) // returns true
```
Making your own validators is easy, for example, the `Reliable` multiaddr is
defined as follows:
```go
// Define IP as either ipv4 or ipv6
var IP = Or(Base(ma.P_IP4), Base(ma.P_IP6))
// Define TCP as 'tcp' on top of either ipv4 or ipv6
var TCP = And(IP, Base(ma.P_TCP))
// Define UDP as 'udp' on top of either ipv4 or ipv6
var UDP = And(IP, Base(ma.P_UDP))
// Define UTP as 'utp' on top of udp (on top of ipv4 or ipv6)
var UTP = And(UDP, Base(ma.P_UTP))
// Now define a Reliable transport as either tcp or utp
var Reliable = Or(TCP, UTP)
// From here, we can easily define multiaddrs for protocols that can run on top
// of any 'reliable' transport (such as ipfs)
```
NOTE: the above patterns are already implemented in package
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 h1:lYpkrQH5ajf0OXOcUbGjvZxxijuBwbbmlSxLiuofa+g=
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1/go.mod h1:pD8RvIylQ358TN4wwqatJ8rNavkEINozVn9DtGI3dfQ=
github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771 h1:MHkK1uRtFbVqvAgvWxafZe54+5uBxLluGylDiKgdhwo=
github.com/minio/sha256-simd v0.1.1-0.20190913151208-6de447530771/go.mod h1:B5e1o+1/KgNmWrSQK08Y6Z1Vb5pwIktudl0J58iy0KM=
github.com/mr-tron/base58 v1.1.0/go.mod h1:xcD2VGqlgYjBdcBLw+TuYLr8afG+Hj8g2eTVqeSzSU8=
github.com/mr-tron/base58 v1.1.3 h1:v+sk57XuaCKGXpWtVBX8YJzO7hMGx4Aajh4TQbdEFdc=
github.com/mr-tron/base58 v1.1.3/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc=
github.com/multiformats/go-base32 v0.0.3 h1:tw5+NhuwaOjJCC5Pp82QuXbrmLzWg7uxlMFp8Nq/kkI=
github.com/multiformats/go-base32 v0.0.3/go.mod h1:pLiuGC8y0QR3Ue4Zug5UzK9LjgbkL8NSQj0zQ5Nz/AA=
github.com/multiformats/go-base36 v0.1.0 h1:JR6TyF7JjGd3m6FbLU2cOxhC0Li8z8dLNGQ89tUg4F4=
github.com/multiformats/go-base36 v0.1.0/go.mod h1:kFGE83c6s80PklsHO9sRn2NCoffoRdUUOENyW/Vv6sM=
github.com/multiformats/go-multibase v0.0.3 h1:l/B6bJDQjvQ5G52jw4QGSYeOTZoAwIO77RblWplfIqk=
github.com/multiformats/go-multibase v0.0.3/go.mod h1:5+1R4eQrT3PkYZ24C3W2Ue2tPwIdYQD509ZjSb5y9Oc=
github.com/multiformats/go-multihash v0.0.14 h1:QoBceQYQQtNUuf6s7wHxnE2c8bhbMqhfGzNI032se/I=
github.com/multiformats/go-multihash v0.0.14/go.mod h1:VdAWLKTwram9oKAatUcLxBNUjdtcVwxObEQBtRfuyjc=
github.com/multiformats/go-varint v0.0.5 h1:XVZwSo04Cs3j/jS0uAEPpT3JY6DzMcVLLoWOSnCxOjg=
github.com/multiformats/go-varint v0.0.5/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE=
github.com/multiformats/go-varint v0.0.6 h1:gk85QWKxh3TazbLxED/NlDVv8+q+ReFJk7Y2W/KhfNY=
github.com/multiformats/go-varint v0.0.6/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE=
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
gitlab.dms3.io/dms3/go-cid v0.0.3 h1:5qZ1sl1Bi26naLz7Vsc8fjWcJKX8bR6njt3WPCteXac=
gitlab.dms3.io/dms3/go-cid v0.0.3/go.mod h1:qT/Q1NZD31UnWQ+rwsQgzGrrsQhpq7dYSlXf7ulDgtk=
gitlab.dms3.io/mf/go-multiaddr v0.0.2 h1:MZSIKYi5qBk5iurELtESiTsczdXauQhaqKOnk9vMJfI=
gitlab.dms3.io/mf/go-multiaddr v0.0.2/go.mod h1:BMNP0l/IA8/dbE6vNBf/ben61YNaPU0kn6wXgqZs9vU=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8 h1:1wopBVtVdWnn03fZelqdXTqk7U7zPQCb+T4rbU9ZEoU=
golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
package mafmt
import (
"strings"
ma "gitlab.dms3.io/mf/go-multiaddr"
)
// Define a dns4 format multiaddr
var DNS4 = Base(ma.P_DNS4)
// Define a dns6 format multiaddr
var DNS6 = Base(ma.P_DNS6)
// Define a dnsaddr, dns, dns4 or dns6 format multiaddr
var DNS = Or(
Base(ma.P_DNS),
DNS4,
DNS6,
)
// Define IP as either ipv4 or ipv6
var IP = Or(Base(ma.P_IP4), Base(ma.P_IP6))
// Define TCP as 'tcp' on top of either ipv4 or ipv6, or dns equivalents.
var TCP = Or(
And(DNS, Base(ma.P_TCP)),
And(IP, Base(ma.P_TCP)),
)
// Define UDP as 'udp' on top of either ipv4 or ipv6, or dns equivalents.
var UDP = Or(
And(DNS, Base(ma.P_UDP)),
And(IP, Base(ma.P_UDP)),
)
// Define UTP as 'utp' on top of udp (on top of ipv4 or ipv6).
var UTP = And(UDP, Base(ma.P_UTP))
// Define QUIC as 'quic' on top of udp (on top of ipv4 or ipv6)
var QUIC = And(UDP, Base(ma.P_QUIC))
// Define unreliable transport as udp
var Unreliable = Or(UDP)
// Now define a Reliable transport as either tcp or utp or quic
var Reliable = Or(TCP, UTP, QUIC)
// P2P can run over any reliable underlying transport protocol
var P2P = And(Reliable, Base(ma.P_P2P))
// IPFS can run over any reliable underlying transport protocol
//
// Deprecated: use P2P
var IPFS = P2P
// Define http over TCP or DNS or http over DNS format multiaddr
var HTTP = Or(
And(TCP, Base(ma.P_HTTP)),
And(IP, Base(ma.P_HTTP)),
And(DNS, Base(ma.P_HTTP)),
)
// Define https over TCP or DNS or https over DNS format multiaddr
var HTTPS = Or(
And(TCP, Base(ma.P_HTTPS)),
And(IP, Base(ma.P_HTTPS)),
And(DNS, Base(ma.P_HTTPS)),
)
// Define p2p-webrtc-direct over HTTP or p2p-webrtc-direct over HTTPS format multiaddr
var WebRTCDirect = Or(
And(HTTP, Base(ma.P_P2P_WEBRTC_DIRECT)),
And(HTTPS, Base(ma.P_P2P_WEBRTC_DIRECT)))
const (
or = iota
and = iota
)
func And(ps ...Pattern) Pattern {
return &pattern{
Op: and,
Args: ps,
}
}
func Or(ps ...Pattern) Pattern {
return &pattern{
Op: or,
Args: ps,
}
}
type Pattern interface {
Matches(ma.Multiaddr) bool
partialMatch([]ma.Protocol) (bool, []ma.Protocol)
String() string
}
type pattern struct {
Args []Pattern
Op int
}
func (ptrn *pattern) Matches(a ma.Multiaddr) bool {
ok, rem := ptrn.partialMatch(a.Protocols())
return ok && len(rem) == 0
}
func (ptrn *pattern) partialMatch(pcs []ma.Protocol) (bool, []ma.Protocol) {
switch ptrn.Op {
case or:
for _, a := range ptrn.Args {
ok, rem := a.partialMatch(pcs)
if ok {
return true, rem
}
}
return false, nil
case and:
if len(pcs) < len(ptrn.Args) {
return false, nil
}
for i := 0; i < len(ptrn.Args); i++ {
ok, rem := ptrn.Args[i].partialMatch(pcs)
if !ok {
return false, nil
}
pcs = rem
}
return true, pcs
default:
panic("unrecognized pattern operand")
}
}
func (ptrn *pattern) String() string {
var sub []string
for _, a := range ptrn.Args {
sub = append(sub, a.String())
}
switch ptrn.Op {
case and:
return strings.Join(sub, "/")
case or:
return "{" + strings.Join(sub, "|") + "}"
default:
panic("unrecognized pattern op!")
}
}
type Base int
func (p Base) Matches(a ma.Multiaddr) bool {
pcs := a.Protocols()
return pcs[0].Code == int(p) && len(pcs) == 1
}
func (p Base) partialMatch(pcs []ma.Protocol) (bool, []ma.Protocol) {
if len(pcs) == 0 {
return false, nil
}
if pcs[0].Code == int(p) {
return true, pcs[1:]
}
return false, nil
}
func (p Base) String() string {
return ma.ProtocolWithCode(int(p)).Name
}
package mafmt
import (
"testing"
ma "gitlab.dms3.io/mf/go-multiaddr"
)
type testVector struct {
Pattern Pattern
Good []string
Bad []string
}
var TestVectors = map[string]*testVector{
"IP": {
Pattern: IP,
Good: []string{"/ip4/0.0.0.0", "/ip6/fc00::"},
Bad: []string{"/ip4/0.0.0.0/tcp/555", "/udp/789/ip6/fc00::"},
},
"TCP": {
Pattern: TCP,
Good: []string{"/ip4/0.0.7.6/tcp/1234", "/ip6/::/tcp/0"},
Bad: []string{"/tcp/12345", "/ip6/fc00::/udp/5523/tcp/9543"},
},
"UDP": {
Pattern: UDP,
Good: []string{"/ip4/0.0.7.6/udp/1234", "/ip6/::/udp/0"},
Bad: []string{"/udp/12345", "/ip6/fc00::/tcp/5523/udp/9543"},
},
"UTP": {
Pattern: UTP,
Good: []string{"/ip4/1.2.3.4/udp/3456/utp", "/ip6/::/udp/0/utp"},
Bad: []string{"/ip4/0.0.0.0/tcp/12345/utp", "/ip6/1.2.3.4/ip4/0.0.0.0/udp/1234/utp", "/utp"},
},
"QUIC": {
Pattern: QUIC,
Good: []string{"/ip4/1.2.3.4/udp/1234/quic", "/ip6/::/udp/1234/quic"},
Bad: []string{"/ip4/0.0.0.0/tcp/12345/quic", "/ip6/1.2.3.4/ip4/0.0.0.0/udp/1234/quic", "/quic"},
},
"IPFS": {
Pattern: IPFS,
Good: []string{
"/ip4/1.2.3.4/tcp/1234/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
"/ip6/::/tcp/1234/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
"/ip6/::/udp/1234/utp/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
"/ip4/0.0.0.0/udp/1234/utp/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
},
Bad: []string{
"/ip4/1.2.3.4/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
"/ip6/::/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
"/tcp/123/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
"/ip6/::/udp/1234/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
"/ip6/::/utp/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
"/ipfs/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
},
},
"DNS": {
Pattern: DNS,
Good: []string{"/dns4/example.io", "/dns6/example.io", "/dns/exmaple.io"},
Bad: []string{"/dnsaddr/example.io", "/ip4/127.0.0.1"},
},
"WebRTCDirect": {
Pattern: WebRTCDirect,
Good: []string{"/ip4/1.2.3.4/tcp/3456/http/p2p-webrtc-direct", "/ip6/::/tcp/0/http/p2p-webrtc-direct"},
Bad: []string{"/ip4/0.0.0.0", "/ip6/fc00::", "/udp/12345", "/ip6/fc00::/tcp/5523/udp/9543"},
},
"HTTP": {
Pattern: HTTP,
Good: []string{"/ip4/1.2.3.4/http", "/dns4/example.io/http", "/dns6/::/tcp/7011/http", "/ip6/fc00::/http"},
Bad: []string{"/ip4/1.2.3.4/https", "/ip4/0.0.0.0/tcp/12345/quic", "/ip6/fc00::/tcp/5523", "/dnsaddr/example.io/http"},
},
"HTTPS": {
Pattern: HTTPS,
Good: []string{"/ip4/1.2.3.4/https", "/dns4/example.io/https", "/dns6/::/tcp/7011/https", "/ip6/fc00::/https"},
Bad: []string{"/ip4/1.2.3.4/http", "/ip4/0.0.0.0/tcp/12345/quic", "/ip6/fc00::/tcp/5523"},
},
}
func TestProtocolMatching(t *testing.T) {
for name, tc := range TestVectors {
name := name
tc := tc
t.Run(name, func(t *testing.T) {
t.Parallel()
assertMatches(t, tc.Pattern, tc.Good)
bad := [][]string{tc.Bad}
for _, other := range TestVectors {
if other == tc {
continue
}
bad = append(bad, other.Good)
}
assertMismatches(t, tc.Pattern, bad...)
})
}
}
func TestReliableGroup(t *testing.T) {
assertMatches(t, Reliable, TestVectors["UTP"].Good, TestVectors["TCP"].Good, TestVectors["QUIC"].Good)
assertMismatches(t, Reliable, TestVectors["IP"].Good, TestVectors["UDP"].Good, TestVectors["IPFS"].Good)
}
func TestUnreliableGroup(t *testing.T) {
assertMatches(t, Unreliable, TestVectors["UDP"].Good)
assertMismatches(t, Unreliable, TestVectors["IP"].Good, TestVectors["TCP"].Good, TestVectors["UTP"].Good, TestVectors["IPFS"].Good, TestVectors["QUIC"].Good)
}
func assertMatches(t *testing.T, p Pattern, args ...[]string) {
t.Helper()
t.Logf("testing assertions for %q", p)
for _, argset := range args {
for _, s := range argset {
addr, err := ma.NewMultiaddr(s)
if err != nil {
t.Fatal(err)
}
if !p.Matches(addr) {
t.Fatal("mismatch!", s, p)
}
}
}
}
func assertMismatches(t *testing.T, p Pattern, args ...[]string) {
t.Helper()
for _, argset := range args {
for _, s := range argset {
addr, err := ma.NewMultiaddr(s)
if err != nil {
t.Fatal(err)
}
if p.Matches(addr) {
t.Fatal("incorrect match!", s, p)
}
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment