revised ad magic and fixed address test

This commit is contained in:
херетик
2023-06-17 09:08:13 +01:00
parent ea63945f1c
commit 5380d5f01e
4 changed files with 5 additions and 6 deletions

View File

@@ -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
} }

View File

@@ -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()

View File

@@ -24,7 +24,7 @@ var (
) )
const ( const (
Magic = "peer" Magic = "pead"
Len = adproto.Len + Len = adproto.Len +
slice.Uint32Len slice.Uint32Len
) )

View File

@@ -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 +