From b34e8b903cdc48c56137acaab3823918f76ed29b Mon Sep 17 00:00:00 2001 From: therealyingtong Date: Mon, 3 Aug 2020 13:51:45 +0800 Subject: [PATCH] Add invalid version byte tests for ZIP212 --- zcash_primitives/src/note_encryption.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/zcash_primitives/src/note_encryption.rs b/zcash_primitives/src/note_encryption.rs index d911225c6..cb7cd9044 100644 --- a/zcash_primitives/src/note_encryption.rs +++ b/zcash_primitives/src/note_encryption.rs @@ -1036,10 +1036,11 @@ mod tests { fn decryption_with_invalid_version_byte() { let mut rng = OsRng; let height_array = [ - consensus::MainNetwork::SAPLING_ACTIVATION_HEIGHT, + consensus::MainNetwork::CANOPY_ACTIVATION_HEIGHT - 1, consensus::MainNetwork::CANOPY_ACTIVATION_HEIGHT, + consensus::MainNetwork::CANOPY_ACTIVATION_HEIGHT + ZIP212_GRACE_PERIOD, ]; - let leadbyte_array = [0x02, 0x03]; + let leadbyte_array = [0x02, 0x03, 0x01]; for (i, height_ref) in height_array.iter().enumerate() { let height = *height_ref; @@ -1223,10 +1224,11 @@ mod tests { fn compact_decryption_with_invalid_version_byte() { let mut rng = OsRng; let height_array = [ - consensus::MainNetwork::SAPLING_ACTIVATION_HEIGHT, + consensus::MainNetwork::CANOPY_ACTIVATION_HEIGHT - 1, consensus::MainNetwork::CANOPY_ACTIVATION_HEIGHT, + consensus::MainNetwork::CANOPY_ACTIVATION_HEIGHT + ZIP212_GRACE_PERIOD, ]; - let leadbyte_array = [0x02, 0x03]; + let leadbyte_array = [0x02, 0x03, 0x01]; for (i, height_ref) in height_array.iter().enumerate() { let height = *height_ref; @@ -1509,10 +1511,11 @@ mod tests { fn recovery_with_invalid_version_byte() { let mut rng = OsRng; let height_array = [ - consensus::MainNetwork::SAPLING_ACTIVATION_HEIGHT, + consensus::MainNetwork::CANOPY_ACTIVATION_HEIGHT - 1, consensus::MainNetwork::CANOPY_ACTIVATION_HEIGHT, + consensus::MainNetwork::CANOPY_ACTIVATION_HEIGHT + ZIP212_GRACE_PERIOD, ]; - let leadbyte_array = [0x02, 0x03]; + let leadbyte_array = [0x02, 0x03, 0x01]; for (i, height_ref) in height_array.iter().enumerate() { let height = *height_ref;