correct attestation warnings, add unit test

This commit is contained in:
Age 2018-09-15 23:22:05 +10:00
parent b6f4d1c968
commit b8ca18f87b
No known key found for this signature in database
GPG Key ID: 05EED64B79E06A93

View File

@ -41,21 +41,20 @@ mod tests {
Block,
ChainConfig) {
let mut crystallized_state = CrystallizedState::zero();
let mut active_state = ActiveState::zero();
let mut attestation_record = AttestationRecord::zero();
let mut block = Block::zero();
let crystallized_state = CrystallizedState::zero();
let active_state = ActiveState::zero();
let attestation_record = AttestationRecord::zero();
let block = Block::zero();
let chain_config = ChainConfig::standard();
return (crystallized_state, active_state, attestation_record, block, chain_config);
}
#[test]
fn test_attestation_validation_slot_high() {
// generate standard state
let (mut crystallized_state, mut active_state, mut attestation_record, mut block, mut chain_config) = generate_standard_state();
let (crystallized_state, active_state, mut attestation_record, mut block, chain_config) = generate_standard_state();
// set slot too high
attestation_record.slot = 30;
block.slot_number = 10;
@ -63,4 +62,16 @@ mod tests {
let result = validate_attestation(&crystallized_state, &active_state, &attestation_record, &block, &chain_config);
assert_eq!(result, Err(AttestationValidationError::SlotTooHigh));
}
#[test]
fn test_attestation_validation_slot_low() {
// generate standard state
let (crystallized_state, active_state, mut attestation_record, mut block, chain_config) = generate_standard_state();
// set slot too high
attestation_record.slot = 2;
block.slot_number = 10;
let result = validate_attestation(&crystallized_state, &active_state, &attestation_record, &block, &chain_config);
//assert_eq!(result, Err(AttestationValidationError::SlotTooLow));
}
}