address ad pass

This commit is contained in:
херетик
2023-06-16 11:51:17 +01:00
parent 8f8437146d
commit ee65c2eae5
4 changed files with 6 additions and 8 deletions

View File

@@ -121,12 +121,11 @@ func (x *Ad) Validate() bool {
return false
}
func NewAddressAd(id nonce.ID, key *crypto.Prv,
func New(id nonce.ID, key *crypto.Prv,
ma multiaddr.Multiaddr) (peerAd *Ad) {
pub := crypto.DerivePub(key)
ma = multi.AddKeyToMultiaddr(ma, pub)
log.D.Ln("ma", ma)
peerAd = &Ad{
Ad: adproto.Ad{
ID: id,

View File

@@ -12,7 +12,7 @@ import (
"testing"
)
func TestAddressAd(t *testing.T) {
func TestNew(t *testing.T) {
if indra.CI == "false" {
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) {
t.FailNow()
}
aa := NewAddressAd(id, pr, ma)
log.D.S("ad", aa.Expiry.Unix())
aa := New(id, pr, ma)
s := splice.New(aa.Len())
if e = aa.Encode(s); fails(e) {
t.FailNow()
@@ -45,11 +44,11 @@ func TestAddressAd(t *testing.T) {
t.Error("did not unwrap expected type")
t.FailNow()
}
log.D.S(ad.Expiry.Unix())
if ad.Expiry.Unix() != aa.Expiry.Unix() {
t.Errorf("expiry did not decode correctly")
t.FailNow()
}
log.D.S(ad)
if ad.ID != aa.ID {
t.Errorf("ID did not decode correctly")
t.FailNow()

View File

@@ -13,7 +13,7 @@ import (
"github.com/indra-labs/indra/pkg/util/splice"
)
func TestPeerAd(t *testing.T) {
func TestNew(t *testing.T) {
if indra.CI == "false" {
log2.SetLogLevel(log2.Trace)
}

View File

@@ -12,7 +12,7 @@ import (
"time"
)
func TestProtoAd(t *testing.T) {
func TestNew(t *testing.T) {
if indra.CI == "false" {
log2.SetLogLevel(log2.Trace)
}