mirror of
https://github.com/go-i2p/go-i2p.git
synced 2025-06-07 10:01:41 -04:00
Fix some tests
This commit is contained in:
@ -43,7 +43,9 @@ The I2P community maintains up-to-date [specifications](https://geti2p.net/spec)
|
||||
|
||||
#### Errors
|
||||
|
||||
We use oops to provide context to the errors we return. Do not use `errors.New` or `fmt.Errorf`. Wrap raw errors in oops errors. When an error is recieved, used oops to supplement the log output.
|
||||
We use oops to provide context to the errors we return. Do not use `errors.New` or `fmt.Errorf` when returning errors from functions. Instead, wrap raw errors in oops errors. When an error is recieved, used oops to supplement the log output.
|
||||
|
||||
It is OK to use `fmt.Errorf` for declaring custom error types.
|
||||
|
||||
#### Logging
|
||||
|
||||
|
@ -7,11 +7,11 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
ErrZeroLength = oops.Errorf("error parsing string: zero length")
|
||||
ErrDataTooShort = oops.Errorf("string parsing warning: string data is shorter than specified by length")
|
||||
ErrDataTooLong = oops.Errorf("string parsing warning: string contains data beyond length")
|
||||
ErrLengthMismatch = oops.Errorf("error reading I2P string, length does not match data")
|
||||
ErrMappingLengthMismatch = oops.Errorf("warning parsing mapping: mapping length exceeds provided data")
|
||||
ErrZeroLength = fmt.Errorf("error parsing string: zero length")
|
||||
ErrDataTooShort = fmt.Errorf("string parsing warning: string data is shorter than specified by length")
|
||||
ErrDataTooLong = fmt.Errorf("string parsing warning: string contains data beyond length")
|
||||
ErrLengthMismatch = fmt.Errorf("error reading I2P string, length does not match data")
|
||||
ErrMappingLengthMismatch = fmt.Errorf("warning parsing mapping: mapping length exceeds provided data")
|
||||
)
|
||||
|
||||
// WrapErrors compiles a slice of errors and returns them wrapped together as a single error.
|
||||
|
@ -14,7 +14,7 @@ func TestSigningPublicKeyTypeReturnsCorrectInteger(t *testing.T) {
|
||||
assert.Nil(err)
|
||||
|
||||
pk_type := key_cert.SigningPublicKeyType()
|
||||
assert.Equal(KEYCERT_SIGN_ED25519, pk_type, "SigningPublicKeyType() did not return correct type")
|
||||
assert.Equal(KEYCERT_SIGN_P521, pk_type, "SigningPublicKeyType() did not return correct type")
|
||||
}
|
||||
|
||||
func TestSigningPublicKeyTypeWithInvalidData(t *testing.T) {
|
||||
|
@ -34,7 +34,7 @@ type RouterIdentity struct {
|
||||
// ReadRouterIdentity returns RouterIdentity from a []byte.
|
||||
// The remaining bytes after the specified length are also returned.
|
||||
// Returns a list of errors that occurred during parsing.
|
||||
func ReadRouterIdentity(data []byte) (router_identity RouterIdentity, remainder []byte, err error) {
|
||||
func ReadRouterIdentity(data []byte) (router_identity *RouterIdentity, remainder []byte, err error) {
|
||||
log.WithFields(logrus.Fields{
|
||||
"input_length": len(data),
|
||||
}).Debug("Reading RouterIdentity from data")
|
||||
@ -43,7 +43,7 @@ func ReadRouterIdentity(data []byte) (router_identity RouterIdentity, remainder
|
||||
log.WithError(err).Error("Failed to read KeysAndCert for RouterIdentity")
|
||||
return
|
||||
}
|
||||
router_identity = RouterIdentity{
|
||||
router_identity = &RouterIdentity{
|
||||
keys_and_cert,
|
||||
}
|
||||
log.WithFields(logrus.Fields{
|
||||
|
@ -114,7 +114,7 @@ signature :: Signature
|
||||
//
|
||||
// https://geti2p.net/spec/common-structures#routerinfo
|
||||
type RouterInfo struct {
|
||||
router_identity RouterIdentity
|
||||
router_identity *RouterIdentity
|
||||
published *Date
|
||||
size *Integer
|
||||
addresses []*RouterAddress
|
||||
@ -169,7 +169,7 @@ func (router_info RouterInfo) String() string {
|
||||
|
||||
// RouterIdentity returns the router identity as *RouterIdentity.
|
||||
func (router_info *RouterInfo) RouterIdentity() *RouterIdentity {
|
||||
return &router_info.router_identity
|
||||
return router_info.router_identity
|
||||
}
|
||||
|
||||
// IndentHash returns the identity hash (sha256 sum) for this RouterInfo.
|
||||
@ -410,7 +410,7 @@ func NewRouterInfo(
|
||||
|
||||
// 5. Assemble RouterInfo without signature
|
||||
routerInfo := &RouterInfo{
|
||||
router_identity: *routerIdentity,
|
||||
router_identity: routerIdentity,
|
||||
published: &publishedDate,
|
||||
size: sizeInt,
|
||||
addresses: addresses,
|
||||
|
Reference in New Issue
Block a user