Fix most of the router info tests, all errors are now Mapping-related.

This commit is contained in:
idk
2022-08-06 14:16:42 -04:00
parent 76fba3c8ba
commit c3147c3570
4 changed files with 117 additions and 56 deletions

View File

@ -95,7 +95,25 @@ type RouterInfo struct {
signature *Signature
}
//[]byte
//
// Bytes returns the RouterInfo as a slice of bytes suitable for writing to a stream.
//
func (router_info RouterInfo) Bytes() ([]byte, error) {
var err error
var bytes []byte
bytes = append(bytes, router_info.router_identity.KeysAndCert.Bytes()...)
bytes = append(bytes, router_info.published.Bytes()...)
bytes = append(bytes, router_info.size.Bytes()...)
for _, router_address := range router_info.addresses {
bytes = append(bytes, router_address.Bytes()...)
}
bytes = append(bytes, router_info.peer_size.Bytes()...)
//bytes = append(bytes, router_info.options.Bytes()...)
bytes = append(bytes, []byte(*router_info.signature)...)
return bytes, err
}
//
// Read a RouterIdentity from the RouterInfo, returning the RouterIdentity and any errors