Added/modified types and constants according to specs

This commit is contained in:
Kirk Baird
2019-01-16 10:39:02 +11:00
parent 0b47b81a6c
commit 8dec3c1dc7
9 changed files with 160 additions and 48 deletions

View File

@@ -35,6 +35,12 @@ impl Signature {
pub fn as_raw(&self) -> &RawSignature {
&self.0
}
/// Returns a new empty signature.
pub fn empty_sig() -> Self {
let empty: Vec<u8> = vec![0; 97];
Signature(RawSignature::from_bytes(&empty).unwrap())
}
}
impl Encodable for Signature {
@@ -68,4 +74,16 @@ mod tests {
assert_eq!(original, decoded);
}
#[test]
pub fn test_empty_sig() {
let sig = Signature::empty_sig();
let sig_as_bytes: Vec<u8> = sig.as_raw().as_bytes();
assert_eq!(sig_as_bytes.len(), 97);
for one_byte in sig_as_bytes.iter() {
assert_eq!(*one_byte, 0);
}
}
}