Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
QuantumExplorer committed Sep 29, 2024
1 parent 802811c commit 385b78f
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use drive::grovedb::TransactionArg;

use dpp::system_data_contracts::withdrawals_contract;
use dpp::system_data_contracts::withdrawals_contract::v1::document_types::withdrawal;
use drive::config::DEFAULT_QUERY_LIMIT;

use crate::platform_types::platform_state::v0::PlatformStateV0Methods;
use crate::platform_types::platform_state::PlatformState;
Expand Down Expand Up @@ -186,6 +185,7 @@ mod tests {
use dpp::platform_value::platform_value;
use dpp::system_data_contracts::load_system_data_contract;
use dpp::version::PlatformVersion;
use drive::config::DEFAULT_QUERY_LIMIT;

#[test]
fn test_pooling() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use drive::grovedb::TransactionArg;

use dpp::system_data_contracts::withdrawals_contract;
use dpp::system_data_contracts::withdrawals_contract::v1::document_types::withdrawal;
use drive::config::DEFAULT_QUERY_LIMIT;

use crate::{
error::{execution::ExecutionError, Error},
Expand Down Expand Up @@ -168,6 +167,7 @@ mod tests {
use dpp::platform_value::platform_value;
use dpp::system_data_contracts::load_system_data_contract;
use dpp::version::PlatformVersion;
use drive::config::DEFAULT_QUERY_LIMIT;

#[test]
fn test_pooling() {
Expand Down
11 changes: 11 additions & 0 deletions packages/rs-drive-abci/tests/strategy_tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ mod tests {
use crate::execution::{continue_chain_for_strategy, run_chain_for_strategy};
use crate::query::QueryStrategy;
use crate::strategy::{FailureStrategy, MasternodeListChangesStrategy};
use assert_matches::assert_matches;
use dashcore_rpc::dashcore::hashes::Hash;
use dashcore_rpc::dashcore::BlockHash;
use dashcore_rpc::json::QuorumType;
Expand Down Expand Up @@ -1248,6 +1249,16 @@ mod tests {

let outcome = run_chain_for_strategy(&mut platform, 1, strategy, config, 15, &mut None);

for tx_results_per_block in outcome.state_transition_results_per_block.values() {
for (state_transition, result) in tx_results_per_block {
assert_eq!(
result.code, 0,
"state transition got code {} : {:?}",
result.code, state_transition
);
}
}

outcome
.abci_app
.platform
Expand Down
247 changes: 116 additions & 131 deletions packages/rs-drive-abci/tests/strategy_tests/withdrawal_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1809,153 +1809,138 @@ mod tests {
outcome
};

let ChainExecutionOutcome {
let outcome = continue_chain_for_strategy(
abci_app,
proposers,
validator_quorums: quorums,
current_validator_quorum_hash: current_quorum_hash,
current_proposer_versions,
end_time_ms,
identity_nonce_counter,
identity_contract_nonce_counter,
instant_lock_quorums,
identities,
..
} = {
let outcome = continue_chain_for_strategy(
abci_app,
ChainExecutionParameters {
block_start: 71,
core_height_start: 1,
block_count: 250,
proposers,
validator_quorums: quorums,
current_validator_quorum_hash: current_quorum_hash,
current_proposer_versions: Some(current_proposer_versions),
current_identity_nonce_counter: identity_nonce_counter,
current_identity_contract_nonce_counter: identity_contract_nonce_counter,
current_votes: BTreeMap::default(),
start_time_ms: GENESIS_TIME_MS,
current_time_ms: end_time_ms + 1000,
instant_lock_quorums,
current_identities: identities,
},
continue_strategy_no_operations.clone(),
PlatformConfig {
validator_set: ValidatorSetConfig::default_100_67(),
chain_lock: ChainLockConfig::default_100_67(),
instant_lock: InstantLockConfig::default_100_67(),
execution: ExecutionConfig {
verify_sum_trees: true,
ChainExecutionParameters {
block_start: 71,
core_height_start: 1,
block_count: 250,
proposers,
validator_quorums: quorums,
current_validator_quorum_hash: current_quorum_hash,
current_proposer_versions: Some(current_proposer_versions),
current_identity_nonce_counter: identity_nonce_counter,
current_identity_contract_nonce_counter: identity_contract_nonce_counter,
current_votes: BTreeMap::default(),
start_time_ms: GENESIS_TIME_MS,
current_time_ms: end_time_ms + 1000,
instant_lock_quorums,
current_identities: identities,
},
continue_strategy_no_operations.clone(),
PlatformConfig {
validator_set: ValidatorSetConfig::default_100_67(),
chain_lock: ChainLockConfig::default_100_67(),
instant_lock: InstantLockConfig::default_100_67(),
execution: ExecutionConfig {
verify_sum_trees: true,

..Default::default()
},
block_spacing_ms: hour_in_ms,
initial_protocol_version: TEST_PLATFORM_V3.protocol_version,
testing_configs: PlatformTestConfig::default_minimal_verifications(),
..Default::default()
},
StrategyRandomness::SeedEntropy(9),
);
block_spacing_ms: hour_in_ms,
initial_protocol_version: TEST_PLATFORM_V3.protocol_version,
testing_configs: PlatformTestConfig::default_minimal_verifications(),
..Default::default()
},
StrategyRandomness::SeedEntropy(9),
);

// We should have unlocked the amounts by now
let locked_amount = outcome
.abci_app
.platform
.drive
.grove_get_sum_tree_total_value(
(&get_withdrawal_root_path()).into(),
&WITHDRAWAL_TRANSACTIONS_SUM_AMOUNT_TREE_KEY,
DirectQueryType::StatefulDirectQuery,
None,
&mut vec![],
&platform_version.drive,
)
.expect("expected to get locked amount");
// We should have unlocked the amounts by now
let locked_amount = outcome
.abci_app
.platform
.drive
.grove_get_sum_tree_total_value(
(&get_withdrawal_root_path()).into(),
&WITHDRAWAL_TRANSACTIONS_SUM_AMOUNT_TREE_KEY,
DirectQueryType::StatefulDirectQuery,
None,
&mut vec![],
&platform_version.drive,
)
.expect("expected to get locked amount");

// We have nothing locked left
assert_eq!(locked_amount, 0);
// We have nothing locked left
assert_eq!(locked_amount, 0);

// Withdrawal documents with pooled status should not exist.
let withdrawal_documents_pooled = outcome
.abci_app
.platform
.drive
.fetch_oldest_withdrawal_documents_by_status(
withdrawals_contract::WithdrawalStatus::POOLED.into(),
DEFAULT_QUERY_LIMIT,
None,
platform_version,
)
.unwrap();
// Withdrawal documents with pooled status should not exist.
let withdrawal_documents_pooled = outcome
.abci_app
.platform
.drive
.fetch_oldest_withdrawal_documents_by_status(
withdrawals_contract::WithdrawalStatus::POOLED.into(),
DEFAULT_QUERY_LIMIT,
None,
platform_version,
)
.unwrap();

// None are currently pooled since we have no more room
assert!(withdrawal_documents_pooled.is_empty());
// None are currently pooled since we have no more room
assert!(withdrawal_documents_pooled.is_empty());

// Withdrawal documents with queued status should exist.
let withdrawal_documents_queued = outcome
.abci_app
.platform
.drive
.fetch_oldest_withdrawal_documents_by_status(
withdrawals_contract::WithdrawalStatus::QUEUED.into(),
DEFAULT_QUERY_LIMIT,
None,
platform_version,
)
.unwrap();
// Withdrawal documents with queued status should exist.
let withdrawal_documents_queued = outcome
.abci_app
.platform
.drive
.fetch_oldest_withdrawal_documents_by_status(
withdrawals_contract::WithdrawalStatus::QUEUED.into(),
DEFAULT_QUERY_LIMIT,
None,
platform_version,
)
.unwrap();

// Nothing is left in the queue
assert_eq!(withdrawal_documents_queued.len(), 0);
// Nothing is left in the queue
assert_eq!(withdrawal_documents_queued.len(), 0);

// Withdrawal documents with queued status should exist.
let withdrawal_documents_completed = outcome
.abci_app
.platform
.drive
.fetch_oldest_withdrawal_documents_by_status(
withdrawals_contract::WithdrawalStatus::COMPLETE.into(),
DEFAULT_QUERY_LIMIT,
None,
platform_version,
)
.unwrap();
// Withdrawal documents with queued status should exist.
let withdrawal_documents_completed = outcome
.abci_app
.platform
.drive
.fetch_oldest_withdrawal_documents_by_status(
withdrawals_contract::WithdrawalStatus::COMPLETE.into(),
DEFAULT_QUERY_LIMIT,
None,
platform_version,
)
.unwrap();

// None have completed because core didn't acknowledge them
assert_eq!(withdrawal_documents_completed.len(), 0);
// None have completed because core didn't acknowledge them
assert_eq!(withdrawal_documents_completed.len(), 0);

// Withdrawal documents with EXPIRED status should not exist yet.
let withdrawal_documents_expired = outcome
.abci_app
.platform
.drive
.fetch_oldest_withdrawal_documents_by_status(
withdrawals_contract::WithdrawalStatus::EXPIRED.into(),
DEFAULT_QUERY_LIMIT,
None,
platform_version,
)
.unwrap();
// Withdrawal documents with EXPIRED status should not exist yet.
let withdrawal_documents_expired = outcome
.abci_app
.platform
.drive
.fetch_oldest_withdrawal_documents_by_status(
withdrawals_contract::WithdrawalStatus::EXPIRED.into(),
DEFAULT_QUERY_LIMIT,
None,
platform_version,
)
.unwrap();

// We have none expired yet, because the core height never went up
assert_eq!(withdrawal_documents_expired.len(), 0);
// We have none expired yet, because the core height never went up
assert_eq!(withdrawal_documents_expired.len(), 0);

// Withdrawal documents with broadcasted status should exist.
let withdrawal_documents_broadcasted = outcome
.abci_app
.platform
.drive
.fetch_oldest_withdrawal_documents_by_status(
withdrawals_contract::WithdrawalStatus::BROADCASTED.into(),
DEFAULT_QUERY_LIMIT,
None,
platform_version,
)
.unwrap();
// Withdrawal documents with broadcasted status should exist.
let withdrawal_documents_broadcasted = outcome
.abci_app
.platform
.drive
.fetch_oldest_withdrawal_documents_by_status(
withdrawals_contract::WithdrawalStatus::BROADCASTED.into(),
DEFAULT_QUERY_LIMIT,
None,
platform_version,
)
.unwrap();

assert_eq!(withdrawal_documents_broadcasted.len(), 80);
outcome
};
assert_eq!(withdrawal_documents_broadcasted.len(), 80);
}

#[test]
Expand Down
1 change: 0 additions & 1 deletion packages/rs-drive-proof-verifier/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use std::collections::{BTreeMap, BTreeSet};

use dpp::block::block_info::BlockInfo;
use dpp::core_types::validator_set::ValidatorSet;
use dpp::dashcore::QuorumHash;
use dpp::voting::vote_info_storage::contested_document_vote_poll_winner_info::ContestedDocumentVotePollWinnerInfo;
use drive::grovedb::query_result_type::Path;
#[cfg(feature = "mocks")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use crate::util::grove_operations::BatchDeleteApplyType;
use dpp::version::drive_versions::DriveVersion;

use grovedb::{PathQuery, TransactionArg};
use grovedb_path::SubtreePath;

impl Drive {
/// Pushes multiple "delete element" operations for items in a given path based on a `PathQuery` to `drive_operations`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use grovedb::batch::key_info::KeyInfo;
use grovedb::batch::KeyInfoPath;
use grovedb::operations::delete::DeleteOptions;
use grovedb::query_result_type::QueryResultType;
use grovedb::{Element, GroveDb, PathQuery, TransactionArg};
use grovedb::{GroveDb, PathQuery, TransactionArg};
use grovedb_storage::rocksdb_storage::RocksDbStorage;
use platform_version::version::drive_versions::DriveVersion;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::fees::op::LowLevelDriveOperation;
use crate::util::object_size_info::PathKeyElementInfo;

use dpp::version::drive_versions::DriveVersion;
use grovedb::{Element, TransactionArg};
use grovedb::TransactionArg;

impl Drive {
/// Pushes an "insert sum item or add to it if the item already exists" operation to `drive_operations`.
Expand Down
Loading

0 comments on commit 385b78f

Please sign in to comment.