revised ad magic and fixed address test
This commit is contained in:
@@ -68,9 +68,7 @@ func (x *Ad) Decode(s *splice.Splice) (e error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (x *Ad) Encode(s *splice.Splice) (e error) {
|
func (x *Ad) Encode(s *splice.Splice) (e error) {
|
||||||
log.T.S("encoding", reflect.TypeOf(x),
|
log.T.S("encoding", reflect.TypeOf(x), x)
|
||||||
x.ID, x.Sig,
|
|
||||||
)
|
|
||||||
x.Splice(s)
|
x.Splice(s)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/indra-labs/indra/pkg/util/splice"
|
"github.com/indra-labs/indra/pkg/util/splice"
|
||||||
"github.com/multiformats/go-multiaddr"
|
"github.com/multiformats/go-multiaddr"
|
||||||
"testing"
|
"testing"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNew(t *testing.T) {
|
func TestNew(t *testing.T) {
|
||||||
@@ -23,7 +24,7 @@ func TestNew(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 := New(id, pr, ma)
|
aa := New(id, pr, ma, time.Now().Add(time.Hour*24*7))
|
||||||
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()
|
||||||
@@ -24,7 +24,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Magic = "peer"
|
Magic = "pead"
|
||||||
Len = adproto.Len +
|
Len = adproto.Len +
|
||||||
slice.Uint32Len
|
slice.Uint32Len
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Magic = "prot"
|
Magic = "prad"
|
||||||
Len = magic.Len +
|
Len = magic.Len +
|
||||||
nonce.IDLen +
|
nonce.IDLen +
|
||||||
crypto.PubKeyLen +
|
crypto.PubKeyLen +
|
||||||
|
|||||||
Reference in New Issue
Block a user