diff --git a/lib/common/router_info/router_info.go b/lib/common/router_info/router_info.go index a024fa3..d5cb485 100644 --- a/lib/common/router_info/router_info.go +++ b/lib/common/router_info/router_info.go @@ -4,11 +4,12 @@ package router_info import ( "encoding/binary" "errors" - "github.com/go-i2p/go-i2p/lib/crypto" "strconv" "strings" "time" + "github.com/go-i2p/go-i2p/lib/crypto" + "github.com/go-i2p/go-i2p/lib/util/logger" "github.com/sirupsen/logrus" @@ -221,7 +222,7 @@ func ReadRouterInfo(bytes []byte) (info RouterInfo, remainder []byte, err error) "required_len": ROUTER_INFO_MIN_SIZE, "reason": "not enough data", }).Error("error parsing router info") - err = errors.New("error parsing router info: not enough data") + err = errors.New("error parsing router info: not enough data to read identity") return } info.published, remainder, err = NewDate(remainder) @@ -232,7 +233,7 @@ func ReadRouterInfo(bytes []byte) (info RouterInfo, remainder []byte, err error) "required_len": DATE_SIZE, "reason": "not enough data", }).Error("error parsing router info") - err = errors.New("error parsing router info: not enough data") + err = errors.New("error parsing router info: not enough data to read publish date") } info.size, remainder, err = NewInteger(remainder, 1) if err != nil { @@ -253,7 +254,7 @@ func ReadRouterInfo(bytes []byte) (info RouterInfo, remainder []byte, err error) //"required_len": ROUTER_ADDRESS_SIZE, "reason": "not enough data", }).Error("error parsing router address") - err = errors.New("error parsing router info: not enough data") + err = errors.New("error parsing router info: not enough data to read router addresses") } info.addresses = append(info.addresses, &address) } @@ -285,7 +286,7 @@ func ReadRouterInfo(bytes []byte) (info RouterInfo, remainder []byte, err error) //"required_len": MAPPING_SIZE, "reason": "not enough data", }).Error("error parsing router info") - err = errors.New("error parsing router info: not enough data") + err = errors.New("error parsing router info: not enough data to read signature") } log.WithFields(logrus.Fields{ diff --git a/lib/common/router_info/router_info2_test.go b/lib/common/router_info/router_info2_test.go index a9ed3c0..155734b 100644 --- a/lib/common/router_info/router_info2_test.go +++ b/lib/common/router_info/router_info2_test.go @@ -4,13 +4,15 @@ import ( "bytes" "crypto/rand" "encoding/binary" + "testing" + "time" + "github.com/go-i2p/go-i2p/lib/common/certificate" "github.com/go-i2p/go-i2p/lib/common/data" + "github.com/go-i2p/go-i2p/lib/common/router_address" "github.com/go-i2p/go-i2p/lib/common/router_identity" "github.com/go-i2p/go-i2p/lib/crypto" "golang.org/x/crypto/openpgp/elgamal" - "testing" - "time" ) func TestCreateRouterInfo(t *testing.T) { @@ -82,8 +84,17 @@ func TestCreateRouterInfo(t *testing.T) { if err != nil { t.Fatalf("Failed to create router identity: %v\n", err) } - - routerInfo, err := NewRouterInfo(routerIdentity, time.Now(), nil, nil, &ed25519_privkey) + // create some dummy addresses + routerAddress, err := router_address.NewRouterAddress(3, <-time.After(1*time.Second), "NTCP2", nil) + if err != nil { + t.Fatalf("Failed to create router address: %v\n", err) + } + routerAddresses := []*router_address.RouterAddress{routerAddress} + // create router info + routerInfo, err := NewRouterInfo(routerIdentity, time.Now(), routerAddresses, nil, &ed25519_privkey) + if err != nil { + t.Fatalf("Failed to create router info: %v\n", err) + } t.Run("Serialize and Deserialize RouterInfo", func(t *testing.T) { routerInfoBytes, err := routerInfo.Bytes()