Skip to content

Commit

Permalink
fix testing
Browse files Browse the repository at this point in the history
  • Loading branch information
brentstone committed Mar 3, 2024
1 parent fd00b09 commit bc55bd6
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 15 deletions.
12 changes: 9 additions & 3 deletions crates/apps/src/lib/node/ledger/shell/finalize_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3953,6 +3953,7 @@ mod test_finalize_block {
let enqueued_slash = enqueued_slashes_handle()
.at(&processing_epoch)
.at(&val1.address)
.at(&height.0)
.front(&shell.state)
.unwrap()
.unwrap();
Expand Down Expand Up @@ -3990,7 +3991,7 @@ mod test_finalize_block {
address: pkh1,
power: Default::default(),
},
height: height.try_into().unwrap(),
height: height.next_height().try_into().unwrap(),
time: tendermint::Time::unix_epoch(),
total_voting_power: Default::default(),
},
Expand Down Expand Up @@ -4023,8 +4024,13 @@ mod test_finalize_block {
.at(&processing_epoch.next())
.at(&val1.address);

assert_eq!(enqueued_slashes_8.len(&shell.state).unwrap(), 2_u64);
assert_eq!(enqueued_slashes_9.len(&shell.state).unwrap(), 1_u64);
let num_enqueued_8 =
enqueued_slashes_8.iter(&shell.state).unwrap().count();
let num_enqueued_9 =
enqueued_slashes_9.iter(&shell.state).unwrap().count();

assert_eq!(num_enqueued_8, 2);
assert_eq!(num_enqueued_9, 1);
let last_slash =
namada_proof_of_stake::storage::read_validator_last_slash_epoch(
&shell.state,
Expand Down
19 changes: 13 additions & 6 deletions crates/proof_of_stake/src/tests/state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@ impl StateMachineTest for ConcretePosState {
&params,
current_epoch,
infraction_epoch,
height,
slash_type,
&address,
);
Expand Down Expand Up @@ -1355,6 +1356,7 @@ impl ConcretePosState {
params: &PosParams,
current_epoch: Epoch,
infraction_epoch: Epoch,
infraction_height: u64,
slash_type: SlashType,
validator: &Address,
) {
Expand Down Expand Up @@ -1391,6 +1393,7 @@ impl ConcretePosState {
let slash = enqueued_slashes_handle()
.at(&processing_epoch)
.at(validator)
.at(&infraction_height)
.back(&self.s)
.unwrap();
if let Some(slash) = slash {
Expand Down Expand Up @@ -5211,12 +5214,16 @@ fn arb_slash(state: &AbstractPosState) -> impl Strategy<Value = Transition> {
.checked_sub(state.params.unbonding_len)
.unwrap_or_default()..=current_epoch)
.prop_map(Epoch::from);
(arb_validator, arb_type, arb_epoch).prop_map(
|(validator, slash_type, infraction_epoch)| Transition::Misbehavior {
address: validator,
slash_type,
infraction_epoch,
height: 0,
let arb_height = 0_u64..10_000_u64;

(arb_validator, arb_type, arb_epoch, arb_height).prop_map(
|(validator, slash_type, infraction_epoch, height)| {
Transition::Misbehavior {
address: validator,
slash_type,
infraction_epoch,
height,
}
},
)
}
19 changes: 13 additions & 6 deletions crates/proof_of_stake/src/tests/state_machine_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2690,6 +2690,7 @@ impl StateMachineTest for ConcretePosState {
&params,
current_epoch,
infraction_epoch,
height,
slash_type,
&address,
);
Expand Down Expand Up @@ -3057,6 +3058,7 @@ impl ConcretePosState {
params: &PosParams,
current_epoch: Epoch,
infraction_epoch: Epoch,
infraction_height: u64,
slash_type: SlashType,
validator: &Address,
) {
Expand Down Expand Up @@ -3101,6 +3103,7 @@ impl ConcretePosState {
let slash = enqueued_slashes_handle()
.at(&processing_epoch)
.at(validator)
.at(&infraction_height)
.back(&self.s)
.unwrap();
if let Some(slash) = slash {
Expand Down Expand Up @@ -4588,12 +4591,16 @@ fn arb_slash(state: &AbstractPosState) -> impl Strategy<Value = Transition> {
.checked_sub(state.params.unbonding_len)
.unwrap_or_default()..=current_epoch)
.prop_map(Epoch::from);
(arb_validator, arb_type, arb_epoch).prop_map(
|(validator, slash_type, infraction_epoch)| Transition::Misbehavior {
address: validator,
slash_type,
infraction_epoch,
height: 0,
let arb_height = 0_u64..10_000_u64;

(arb_validator, arb_type, arb_epoch, arb_height).prop_map(
|(validator, slash_type, infraction_epoch, height)| {
Transition::Misbehavior {
address: validator,
slash_type,
infraction_epoch,
height,
}
},
)
}

0 comments on commit bc55bd6

Please sign in to comment.