Add invalid version byte tests for ZIP212

This commit is contained in:
therealyingtong 2020-08-03 13:51:45 +08:00
parent eba542c95f
commit b34e8b903c
No known key found for this signature in database
GPG Key ID: 179F32A1503D607E
1 changed files with 9 additions and 6 deletions

View File

@ -1036,10 +1036,11 @@ mod tests {
fn decryption_with_invalid_version_byte() { fn decryption_with_invalid_version_byte() {
let mut rng = OsRng; let mut rng = OsRng;
let height_array = [ let height_array = [
consensus::MainNetwork::SAPLING_ACTIVATION_HEIGHT, consensus::MainNetwork::CANOPY_ACTIVATION_HEIGHT - 1,
consensus::MainNetwork::CANOPY_ACTIVATION_HEIGHT, 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() { for (i, height_ref) in height_array.iter().enumerate() {
let height = *height_ref; let height = *height_ref;
@ -1223,10 +1224,11 @@ mod tests {
fn compact_decryption_with_invalid_version_byte() { fn compact_decryption_with_invalid_version_byte() {
let mut rng = OsRng; let mut rng = OsRng;
let height_array = [ let height_array = [
consensus::MainNetwork::SAPLING_ACTIVATION_HEIGHT, consensus::MainNetwork::CANOPY_ACTIVATION_HEIGHT - 1,
consensus::MainNetwork::CANOPY_ACTIVATION_HEIGHT, 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() { for (i, height_ref) in height_array.iter().enumerate() {
let height = *height_ref; let height = *height_ref;
@ -1509,10 +1511,11 @@ mod tests {
fn recovery_with_invalid_version_byte() { fn recovery_with_invalid_version_byte() {
let mut rng = OsRng; let mut rng = OsRng;
let height_array = [ let height_array = [
consensus::MainNetwork::SAPLING_ACTIVATION_HEIGHT, consensus::MainNetwork::CANOPY_ACTIVATION_HEIGHT - 1,
consensus::MainNetwork::CANOPY_ACTIVATION_HEIGHT, 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() { for (i, height_ref) in height_array.iter().enumerate() {
let height = *height_ref; let height = *height_ref;