Make it so I can run the tests again on the parts I have converted so far

This commit is contained in:
idk
2021-05-21 19:12:49 -04:00
parent 4a9943de9b
commit a3b83b5e1e
2 changed files with 14 additions and 24 deletions

View File

@ -130,15 +130,6 @@ func (lease_set LeaseSet) GetDestination() (destination Destination, err error)
// Return the PublicKey in this LeaseSet and any errors ancountered parsing the LeaseSet.
//
func (lease_set LeaseSet) GetPublicKey() (public_key crypto.ElgPublicKey, err error) {
if lease_set.PublicKey == nil {
log.WithFields(log.Fields{
"at": "(LeaseSet) PublicKey",
"public": lease_set.PublicKey,
"reason": "not enough data",
}).Error("error parsing public key")
err = errors.New("error parsing public key: not enough data")
return
}
public_key = lease_set.ElgPublicKey
return
}
@ -162,15 +153,6 @@ func (lease_set LeaseSet) GetSigningKey() (signing_public_key crypto.SigningPubl
}
func (lease_set LeaseSet) Leases() (leases []Lease, err error) {
if lease_set.Leases == nil {
log.WithFields(log.Fields{
"at": "(LeaseSet) Leases",
"public": lease_set.Leases,
"reason": "not enough data",
}).Error("error parsing signing leases")
err = errors.New("error parsing leases")
return
}
leases = lease_set.LeaseList
return
}
@ -319,8 +301,12 @@ func ReadLeases(bytes []byte) (leases []Lease, remainder []byte, err error) {
err = errors.New("error parsing lease set: some leases missing")
return
}
lease, remainder, err := ReadLease(bytes[start:end])
var lease Lease
lease, remainder, err = ReadLease(bytes[start:end])
leases = append(leases, lease)
if err != nil {
return
}
}
return
}

View File

@ -10,7 +10,11 @@ import (
func buildRouterIdentity() RouterIdentity {
router_ident_data := make([]byte, 128+256)
router_ident_data = append(router_ident_data, []byte{0x05, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00}...)
return RouterIdentity(router_ident_data)
b, _, err := ReadRouterIdentity(router_ident_data)
if err != nil {
panic(err)
}
return b
}
func buildDate() []byte {
@ -33,7 +37,7 @@ func buildRouterAddress(transport string) RouterAddress {
func buildFullRouterInfo() RouterInfo {
router_info_data := make([]byte, 0)
router_info_data = append(router_info_data, buildRouterIdentity()...)
router_info_data = append(router_info_data, buildRouterIdentity().Bytes()...)
router_info_data = append(router_info_data, buildDate()...)
router_info_data = append(router_info_data, 0x01)
router_info_data = append(router_info_data, buildRouterAddress("foo")...)
@ -116,7 +120,7 @@ func TestRouterAddressesReturnsAddressesWithMultiple(t *testing.T) {
assert := assert.New(t)
router_info_data := make([]byte, 0)
router_info_data = append(router_info_data, buildRouterIdentity()...)
router_info_data = append(router_info_data, buildRouterIdentity().Bytes()...)
router_info_data = append(router_info_data, buildDate()...)
router_info_data = append(router_info_data, 0x03)
router_info_data = append(router_info_data, buildRouterAddress("foo0")...)
@ -184,8 +188,8 @@ func TestRouterIdentityIsCorrect(t *testing.T) {
assert.Equal(
0,
bytes.Compare(
[]byte(buildRouterIdentity()),
[]byte(router_identity),
[]byte(buildRouterIdentity().Bytes()),
[]byte(router_identity.Bytes()),
),
)
}