Add test for transaction and block version serialization
This commit is contained in:
parent
e9f1f11c2c
commit
945db009b2
|
@ -311,6 +311,21 @@ mod tests {
|
|||
assert_eq!(serialize(&real_decode), segwit_block);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn block_version_test() {
|
||||
let block = Vec::from_hex("ffffff7f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap();
|
||||
let decode: Result<Block, _> = deserialize(&block);
|
||||
assert!(decode.is_ok());
|
||||
let real_decode = decode.unwrap();
|
||||
assert_eq!(real_decode.header.version, 2147483647);
|
||||
|
||||
let block2 = Vec::from_hex("000000800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000").unwrap();
|
||||
let decode2: Result<Block, _> = deserialize(&block2);
|
||||
assert!(decode2.is_ok());
|
||||
let real_decode2 = decode2.unwrap();
|
||||
assert_eq!(real_decode2.header.version, -2147483648);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compact_roundrtip_test() {
|
||||
let some_header = Vec::from_hex("010000004ddccd549d28f385ab457e98d1b11ce80bfea2c5ab93015ade4973e400000000bf4473e53794beae34e64fccc471dace6ae544180816f89591894e0f417a914cd74d6e49ffff001d323b3a7b").unwrap();
|
||||
|
|
|
@ -761,6 +761,21 @@ mod tests {
|
|||
assert_eq!(realtx.get_size(), tx_bytes.len());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_transaction_version() {
|
||||
let tx_bytes = Vec::from_hex("ffffff7f0100000000000000000000000000000000000000000000000000000000000000000000000000ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000").unwrap();
|
||||
let tx: Result<Transaction, _> = deserialize(&tx_bytes);
|
||||
assert!(tx.is_ok());
|
||||
let realtx = tx.unwrap();
|
||||
assert_eq!(realtx.version, 2147483647);
|
||||
|
||||
let tx2_bytes = Vec::from_hex("000000800100000000000000000000000000000000000000000000000000000000000000000000000000ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000").unwrap();
|
||||
let tx2: Result<Transaction, _> = deserialize(&tx2_bytes);
|
||||
assert!(tx2.is_ok());
|
||||
let realtx2 = tx2.unwrap();
|
||||
assert_eq!(realtx2.version, -2147483648);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tx_no_input_deserialization() {
|
||||
let tx_bytes = Vec::from_hex(
|
||||
|
|
Loading…
Reference in New Issue