fix: use u64 instead of i64 for unit interval and rational numerator (#268)

This commit is contained in:
Harper 2023-07-18 13:21:35 +01:00 committed by GitHub
parent 554fa1578e
commit f2a746b831
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View file

@ -375,7 +375,7 @@ pub type Scripthash = Hash<28>;
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
pub struct RationalNumber {
pub numerator: i64,
pub numerator: u64,
pub denominator: u64,
}

View file

@ -761,6 +761,8 @@ mod tests {
include_str!("../../../test_data/babbage8.block"),
// block with inline datum that fails hashes
include_str!("../../../test_data/babbage9.block"),
// block with pool margin numerator greater than i64::MAX
include_str!("../../../test_data/babbage10.block"),
];
for (idx, block_str) in test_blocks.iter().enumerate() {
@ -768,10 +770,10 @@ mod tests {
let bytes = hex::decode(block_str).unwrap_or_else(|_| panic!("bad block file {idx}"));
let block: BlockWrapper = minicbor::decode(&bytes[..])
.unwrap_or_else(|_| panic!("error decoding cbor for file {idx}"));
.unwrap_or_else(|e| panic!("error decoding cbor for file {idx}: {e:?}"));
let bytes2 = minicbor::to_vec(block)
.unwrap_or_else(|_| panic!("error encoding block cbor for file {idx}"));
.unwrap_or_else(|e| panic!("error encoding block cbor for file {idx}: {e:?}"));
assert!(bytes.eq(&bytes2), "re-encoded bytes didn't match original");
}