2018-11-25 16:55:02 +00:00
|
|
|
package p2p
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
ma "github.com/multiformats/go-multiaddr"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestRelayAddrsOnlyFactory(t *testing.T) {
|
|
|
|
relay := "/ip4/127.0.0.1/tcp/6660/p2p/QmQ7zhY7nGY66yK1n8hLGevfVyjbtvHSgtZuXkCH9oTrgi"
|
2019-03-17 02:56:05 +00:00
|
|
|
f := withRelayAddrs(relay)
|
2018-11-25 16:55:02 +00:00
|
|
|
|
|
|
|
a, err := ma.NewMultiaddr("/ip4/127.0.0.1/tcp/33201/p2p/QmaXZhW44pwQxBSeLkE5FNeLz8tGTTEsRciFg1DNWXXrWG")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
addrs := []ma.Multiaddr{a}
|
|
|
|
|
|
|
|
result := f(addrs)
|
|
|
|
|
2019-03-17 02:56:05 +00:00
|
|
|
if len(result) != 2 {
|
2018-11-25 16:55:02 +00:00
|
|
|
t.Errorf("Unexpected number of addresses. Wanted %d, got %d", 2, len(result))
|
|
|
|
}
|
|
|
|
|
|
|
|
expected := "/ip4/127.0.0.1/tcp/6660/ipfs/QmQ7zhY7nGY66yK1n8hLGevfVyjbtvHSgtZuXkCH9oTrgi/p2p-circuit/ip4/127.0.0.1/tcp/33201/ipfs/QmaXZhW44pwQxBSeLkE5FNeLz8tGTTEsRciFg1DNWXXrWG"
|
2019-03-17 02:56:05 +00:00
|
|
|
if result[1].String() != expected {
|
|
|
|
t.Errorf("Address at index 1 (%s) is not the expected p2p-circuit address", result[1].String())
|
2018-11-25 16:55:02 +00:00
|
|
|
}
|
|
|
|
}
|