address ad pass
This commit is contained in:
@@ -121,12 +121,11 @@ func (x *Ad) Validate() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAddressAd(id nonce.ID, key *crypto.Prv,
|
func New(id nonce.ID, key *crypto.Prv,
|
||||||
ma multiaddr.Multiaddr) (peerAd *Ad) {
|
ma multiaddr.Multiaddr) (peerAd *Ad) {
|
||||||
|
|
||||||
pub := crypto.DerivePub(key)
|
pub := crypto.DerivePub(key)
|
||||||
ma = multi.AddKeyToMultiaddr(ma, pub)
|
ma = multi.AddKeyToMultiaddr(ma, pub)
|
||||||
log.D.Ln("ma", ma)
|
|
||||||
peerAd = &Ad{
|
peerAd = &Ad{
|
||||||
Ad: adproto.Ad{
|
Ad: adproto.Ad{
|
||||||
ID: id,
|
ID: id,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAddressAd(t *testing.T) {
|
func TestNew(t *testing.T) {
|
||||||
if indra.CI == "false" {
|
if indra.CI == "false" {
|
||||||
log2.SetLogLevel(log2.Trace)
|
log2.SetLogLevel(log2.Trace)
|
||||||
}
|
}
|
||||||
@@ -23,8 +23,7 @@ func TestAddressAd(t *testing.T) {
|
|||||||
if ma, e = multiaddr.NewMultiaddr("/ip4/127.0.0.1/tcp/4242"); fails(e) {
|
if ma, e = multiaddr.NewMultiaddr("/ip4/127.0.0.1/tcp/4242"); fails(e) {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
aa := NewAddressAd(id, pr, ma)
|
aa := New(id, pr, ma)
|
||||||
log.D.S("ad", aa.Expiry.Unix())
|
|
||||||
s := splice.New(aa.Len())
|
s := splice.New(aa.Len())
|
||||||
if e = aa.Encode(s); fails(e) {
|
if e = aa.Encode(s); fails(e) {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
@@ -45,11 +44,11 @@ func TestAddressAd(t *testing.T) {
|
|||||||
t.Error("did not unwrap expected type")
|
t.Error("did not unwrap expected type")
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
log.D.S(ad.Expiry.Unix())
|
|
||||||
if ad.Expiry.Unix() != aa.Expiry.Unix() {
|
if ad.Expiry.Unix() != aa.Expiry.Unix() {
|
||||||
t.Errorf("expiry did not decode correctly")
|
t.Errorf("expiry did not decode correctly")
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
|
log.D.S(ad)
|
||||||
if ad.ID != aa.ID {
|
if ad.ID != aa.ID {
|
||||||
t.Errorf("ID did not decode correctly")
|
t.Errorf("ID did not decode correctly")
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
"github.com/indra-labs/indra/pkg/util/splice"
|
"github.com/indra-labs/indra/pkg/util/splice"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPeerAd(t *testing.T) {
|
func TestNew(t *testing.T) {
|
||||||
if indra.CI == "false" {
|
if indra.CI == "false" {
|
||||||
log2.SetLogLevel(log2.Trace)
|
log2.SetLogLevel(log2.Trace)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestProtoAd(t *testing.T) {
|
func TestNew(t *testing.T) {
|
||||||
if indra.CI == "false" {
|
if indra.CI == "false" {
|
||||||
log2.SetLogLevel(log2.Trace)
|
log2.SetLogLevel(log2.Trace)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user