Skip to content

Commit

Permalink
add slashing to PoS state machine test
Browse files Browse the repository at this point in the history
  • Loading branch information
brentstone committed Mar 22, 2023
1 parent dd60d62 commit 69f9a25
Show file tree
Hide file tree
Showing 3 changed files with 517 additions and 11 deletions.
17 changes: 17 additions & 0 deletions core/src/ledger/storage_api/collections/lazy_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,23 @@ where
storage.read(&self.get_data_key(index))
}

/// Read the first element
pub fn front<S>(&self, storage: &S) -> Result<Option<T>>
where
S: StorageRead,
{
self.get(storage, 0)
}

/// Read the last element
pub fn back<S>(&self, storage: &S) -> Result<Option<T>>
where
S: StorageRead,
{
let len = self.len(storage)?;
self.get(storage, len - 1)
}

/// An iterator visiting all elements. The iterator element type is
/// `Result<T>`, because iterator's call to `next` may fail with e.g. out of
/// gas or data decoding error.
Expand Down
12 changes: 6 additions & 6 deletions proof_of_stake/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ use crate::{
bond_tokens, bonds_and_unbonds, consensus_validator_set_handle,
copy_validator_sets_and_positions, find_validator_by_raw_hash,
get_num_consensus_validators, init_genesis,
insert_validator_into_validator_set,
insert_validator_into_validator_set, process_slashes,
read_below_capacity_validator_set_addresses_with_stake,
read_consensus_validator_set_addresses_with_stake, read_total_stake,
read_validator_delta_value, read_validator_stake, staking_token_address,
total_deltas_handle, unbond_handle, unbond_tokens, update_validator_deltas,
update_validator_set, validator_consensus_key_handle,
validator_set_update_tendermint, validator_state_handle, withdraw_tokens,
write_validator_address_raw_hash,
read_validator_delta_value, read_validator_stake, slash,
staking_token_address, total_deltas_handle, unbond_handle, unbond_tokens,
update_validator_deltas, update_validator_set,
validator_consensus_key_handle, validator_set_update_tendermint,
validator_state_handle, withdraw_tokens, write_validator_address_raw_hash,
};

proptest! {
Expand Down
Loading

0 comments on commit 69f9a25

Please sign in to comment.