chain: add transaction hash test.
This commit is contained in:
parent
ca4a5ce30c
commit
2a50298b2e
|
@ -9,10 +9,7 @@ use crate::serialization::{sha256d, SerializationError, ZcashSerialize};
|
|||
|
||||
use super::Transaction;
|
||||
|
||||
/// A hash of a `Transaction`
|
||||
///
|
||||
/// TODO: I'm pretty sure this is also a SHA256d hash but I haven't
|
||||
/// confirmed it yet.
|
||||
/// A transaction hash.
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Serialize, Deserialize, Hash)]
|
||||
#[cfg_attr(test, derive(Arbitrary))]
|
||||
pub struct Hash(pub [u8; 32]);
|
||||
|
|
|
@ -13,6 +13,20 @@ fn librustzcash_tx_deserialize_and_round_trip() {
|
|||
assert_eq!(&zebra_test::vectors::GENERIC_TESTNET_TX[..], &data2[..]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn librustzcash_tx_hash() {
|
||||
let tx = Transaction::zcash_deserialize(&zebra_test::vectors::GENERIC_TESTNET_TX[..])
|
||||
.expect("transaction test vector from librustzcash should deserialize");
|
||||
|
||||
// TxID taken from comment in zebra_test::vectors
|
||||
let hash = tx.hash();
|
||||
let expected = "3956b54c11736f4ac5e2c474029cba8f5b83dca2e38f355337e20ce37fbdf064"
|
||||
.parse::<Hash>()
|
||||
.expect("hash should parse correctly");
|
||||
|
||||
assert_eq!(hash, expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn zip143_deserialize_and_round_trip() {
|
||||
let tx1 = Transaction::zcash_deserialize(&zebra_test::vectors::ZIP143_1[..])
|
||||
|
|
Loading…
Reference in New Issue