Skip to content

Commit

Permalink
remove wrapping value tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joe bebel committed Aug 31, 2023
1 parent ba0f76f commit abfdfc9
Showing 1 changed file with 1 addition and 41 deletions.
42 changes: 1 addition & 41 deletions masp_primitives/src/transaction/components/transparent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,44 +274,4 @@ mod test_serialization {
let deserialized = TxOut::read::<&[u8]>(&mut buf.as_ref()).expect("Test failed");
assert_eq!(deserialized, txout);
}

/// Test value bounds checking
#[test]
fn test_value_bounds_txin() {
let asset_type = AssetType::new_with_nonce(&[1, 2, 3, 4], 1).expect("Test failed");
let txin = TxIn::<Authorized> {
asset_type,
value: MAX_MONEY.wrapping_add(1),
address: TransparentAddress([12u8; 20]),
transparent_sig: (),
};
let mut buf = vec![];
assert!(txin.write(&mut buf).is_err());
let mut buf = vec![];
Write::write_all(&mut buf, txin.asset_type.get_identifier()).expect("Test failed");
Write::write_all(&mut buf, &txin.value.to_le_bytes()).expect("Test failed");
Write::write_all(&mut buf, &txin.address.0).expect("Test failed");
let deserialized = TxIn::read::<&[u8]>(&mut buf.as_ref()).expect("Test failed");
assert_ne!(deserialized, txin);
}

/// Test value bounds checking
#[test]
fn test_value_bounds_txout() {
let asset_type = AssetType::new_with_nonce(&[1, 2, 3, 4], 1).expect("Test failed");
let txout = TxOut {
asset_type,
value: MAX_MONEY.wrapping_add(1),
address: TransparentAddress([12u8; 20]),
};
let mut buf = vec![];
assert!(txout.write(&mut buf).is_err());
let mut buf = vec![];
Write::write_all(&mut buf, txout.asset_type.get_identifier()).expect("Test failed");
Write::write_all(&mut buf, &txout.value.to_le_bytes()).expect("Test failed");
Write::write_all(&mut buf, &txout.address.0).expect("Test failed");

let deserialized = TxOut::read::<&[u8]>(&mut buf.as_ref()).expect("Test failed");
assert_ne!(deserialized, txout);
}
}
}

0 comments on commit abfdfc9

Please sign in to comment.