Skip to content

Commit

Permalink
more fixes and added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumExplorer committed Sep 14, 2024
1 parent 8d6929a commit e8e9f8c
Show file tree
Hide file tree
Showing 40 changed files with 4,893 additions and 1,224 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::error::execution::ExecutionError;
use crate::error::Error;
use crate::platform_types::epoch_info::EpochInfo;
use crate::platform_types::platform::Platform;
use crate::platform_types::platform_state::PlatformState;
use crate::rpc::core::CoreRPCLike;
Expand All @@ -16,6 +17,7 @@ where
/// Checks for ended vote polls
pub(in crate::execution) fn check_for_ended_vote_polls(
&self,
last_committed_platform_state: &PlatformState,
block_platform_state: &PlatformState,
block_info: &BlockInfo,
transaction: TransactionArg,
Expand All @@ -28,6 +30,7 @@ where
.check_for_ended_vote_polls
{
0 => self.check_for_ended_vote_polls_v0(
last_committed_platform_state,
block_platform_state,
block_info,
transaction,
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ where
&TimestampMillis,
&BTreeMap<ResourceVoteChoice, Vec<Identifier>>,
)>,
clean_up_testnet_corrupted_reference_issue: bool,
transaction: TransactionArg,
platform_version: &PlatformVersion,
) -> Result<(), Error> {
Expand All @@ -35,6 +36,7 @@ where
{
0 => self.clean_up_after_contested_resources_vote_polls_end_v0(
vote_polls,
clean_up_testnet_corrupted_reference_issue,
transaction,
platform_version,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ where
&TimestampMillis,
&BTreeMap<ResourceVoteChoice, Vec<Identifier>>,
)>,
clean_up_testnet_corrupted_reference_issue: bool,
transaction: TransactionArg,
platform_version: &PlatformVersion,
) -> Result<(), Error> {
Expand Down Expand Up @@ -52,6 +53,7 @@ where
self.drive
.remove_contested_resource_vote_poll_documents_operations(
vote_polls.as_slice(),
clean_up_testnet_corrupted_reference_issue,
&mut operations,
transaction,
platform_version,
Expand Down Expand Up @@ -109,6 +111,23 @@ where
)?;
}

if clean_up_testnet_corrupted_reference_issue {
self.drive.remove_contested_resource_info_operations(
vote_polls.as_slice(),
&mut operations,
transaction,
platform_version,
)?;
// We remove the last index
self.drive
.remove_contested_resource_top_level_index_operations(
vote_polls.as_slice(),
&mut operations,
transaction,
platform_version,
)?;
}

if !operations.is_empty() {
self.drive.apply_batch_low_level_drive_operations(
None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ where
pub(in crate::execution) fn clean_up_after_vote_polls_end(
&self,
vote_polls: &BTreeMap<TimestampMillis, Vec<ResolvedVotePollWithVotes>>,
clean_up_testnet_corrupted_reference_issue: bool,
transaction: TransactionArg,
platform_version: &PlatformVersion,
) -> Result<(), Error> {
Expand All @@ -27,7 +28,12 @@ where
.voting
.clean_up_after_vote_poll_end
{
0 => self.clean_up_after_vote_polls_end_v0(vote_polls, transaction, platform_version),
0 => self.clean_up_after_vote_polls_end_v0(
vote_polls,
clean_up_testnet_corrupted_reference_issue,
transaction,
platform_version,
),
version => Err(Error::Execution(ExecutionError::UnknownVersionMismatch {
method: "clean_up_after_vote_polls_end".to_string(),
known_versions: vec![0],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ where
pub(super) fn clean_up_after_vote_polls_end_v0(
&self,
vote_polls: &BTreeMap<TimestampMillis, Vec<ResolvedVotePollWithVotes>>,
clean_up_testnet_corrupted_reference_issue: bool,
transaction: TransactionArg,
platform_version: &PlatformVersion,
) -> Result<(), Error> {
Expand All @@ -44,6 +45,7 @@ where
// Call the function to clean up contested document resource vote polls
self.clean_up_after_contested_resources_vote_polls_end(
contested_polls,
clean_up_testnet_corrupted_reference_issue,
transaction,
platform_version,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ where
// Check for any vote polls that might have ended

self.check_for_ended_vote_polls(
last_committed_platform_state,
block_platform_state,
block_info,
transaction,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1718,6 +1718,7 @@ mod tests {
],
"quantum",
10,
None,
platform_version,
);

Expand Down Expand Up @@ -1877,6 +1878,7 @@ mod tests {
],
"quantum",
10,
None,
platform_version,
);

Expand All @@ -1901,6 +1903,7 @@ mod tests {

platform
.check_for_ended_vote_polls(
&platform_state,
&platform_state,
&BlockInfo {
time_ms: 2_000_000_000,
Expand Down
Loading

0 comments on commit e8e9f8c

Please sign in to comment.