Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: missing error variant in GroveDB #2408

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,9 @@ mod tests {

assert!(matches!(
result,
Err(DriveError::GroveDB(
grovedb::Error::PathParentLayerNotFound(_)
))
Err(DriveError::GroveDB(grovedb::Error::InvalidParentLayerPath(
_
)))
));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl Drive {
}
Err(Error::GroveDB(grovedb::Error::PathKeyNotFound(_)))
| Err(Error::GroveDB(grovedb::Error::PathNotFound(_)))
| Err(Error::GroveDB(grovedb::Error::PathParentLayerNotFound(_))) => {
| Err(Error::GroveDB(grovedb::Error::InvalidParentLayerPath(_))) => {
// keep already_exists at false
}
Err(e) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl Drive {
match value {
Ok(Element::Item(stored_contract_bytes, element_flag)) => {
let contract = cost_return_on_error_no_add!(
&cost,
cost,
DataContract::versioned_deserialize(
&stored_contract_bytes,
false,
Expand All @@ -88,7 +88,7 @@ impl Drive {
let drive_operation = CalculatedCostOperation(cost.clone());
let fee = if let Some(epoch) = epoch {
Some(cost_return_on_error_no_add!(
&cost,
cost,
Drive::calculate_fee(
None,
Some(vec![drive_operation]),
Expand All @@ -103,7 +103,7 @@ impl Drive {
};

let storage_flags = cost_return_on_error_no_add!(
&cost,
cost,
StorageFlags::map_some_element_flags_ref(&element_flag)
.map_err(Error::StorageFlags)
);
Expand Down Expand Up @@ -134,7 +134,7 @@ impl Drive {
match value {
Ok(Element::Item(stored_contract_bytes, element_flag)) => {
let contract = cost_return_on_error_no_add!(
&cost,
cost,
DataContract::versioned_deserialize(
&stored_contract_bytes,
false,
Expand All @@ -145,7 +145,7 @@ impl Drive {
let drive_operation = CalculatedCostOperation(cost.clone());
let fee = if let Some(epoch) = epoch {
Some(cost_return_on_error_no_add!(
&cost,
cost,
Drive::calculate_fee(
None,
Some(vec![drive_operation]),
Expand All @@ -160,7 +160,7 @@ impl Drive {
};

let storage_flags = cost_return_on_error_no_add!(
&cost,
cost,
StorageFlags::map_some_element_flags_ref(&element_flag)
.map_err(Error::StorageFlags)
);
Expand All @@ -180,7 +180,7 @@ impl Drive {
.wrap_with_cost(cost),
Err(
grovedb::Error::PathKeyNotFound(_)
| grovedb::Error::PathParentLayerNotFound(_)
| grovedb::Error::InvalidParentLayerPath(_)
| grovedb::Error::PathNotFound(_),
) => Ok(None).wrap_with_cost(cost),
Err(e) => Err(Error::GroveDB(e)).wrap_with_cost(cost),
Expand All @@ -192,7 +192,7 @@ impl Drive {
.wrap_with_cost(cost),
Err(
grovedb::Error::PathKeyNotFound(_)
| grovedb::Error::PathParentLayerNotFound(_)
| grovedb::Error::InvalidParentLayerPath(_)
| grovedb::Error::PathNotFound(_),
) => Ok(None).wrap_with_cost(cost),
Err(e) => Err(Error::GroveDB(e)).wrap_with_cost(cost),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ mod tests {

assert!(matches!(
result,
Err(Error::GroveDB(grovedb::Error::PathParentLayerNotFound(_)))
Err(Error::GroveDB(grovedb::Error::InvalidParentLayerPath(_)))
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ mod tests {

assert!(matches!(
result,
Err(Error::GroveDB(grovedb::Error::PathParentLayerNotFound(_)))
Err(Error::GroveDB(grovedb::Error::InvalidParentLayerPath(_)))
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ mod tests {

assert!(matches!(
result,
Err(Error::GroveDB(grovedb::Error::PathParentLayerNotFound(_)))
Err(Error::GroveDB(grovedb::Error::InvalidParentLayerPath(_)))
));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl Drive {
.unwrap()
{
Ok(result) => Ok(result),
Err(grovedb::Error::PathNotFound(_) | grovedb::Error::PathParentLayerNotFound(_)) => {
Err(grovedb::Error::PathNotFound(_) | grovedb::Error::InvalidParentLayerPath(_)) => {
Ok(true)
}
Err(_) => Err(Error::Drive(DriveError::CorruptedCodeExecution(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ mod tests {

assert!(matches!(
result,
Err(Error::GroveDB(grovedb::Error::PathParentLayerNotFound(_)))
Err(Error::GroveDB(grovedb::Error::InvalidParentLayerPath(_)))
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ mod tests {

assert!(matches!(
result,
Err(Error::GroveDB(grovedb::Error::PathParentLayerNotFound(_)))
Err(Error::GroveDB(grovedb::Error::InvalidParentLayerPath(_)))
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ mod tests {

assert!(matches!(
result,
Err(Error::GroveDB(grovedb::Error::PathParentLayerNotFound(_)))
Err(Error::GroveDB(grovedb::Error::InvalidParentLayerPath(_)))
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ mod tests {

assert!(matches!(
result,
Err(Error::GroveDB(grovedb::Error::PathParentLayerNotFound(_)))
Err(Error::GroveDB(grovedb::Error::InvalidParentLayerPath(_)))
));
}

Expand Down
2 changes: 1 addition & 1 deletion packages/rs-drive/src/drive/system/genesis_time/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl Drive {
Ok(Some(genesis_time_ms))
}
Err(Error::GroveDB(
grovedb::Error::PathParentLayerNotFound(_) | grovedb::Error::PathKeyNotFound(_),
grovedb::Error::InvalidParentLayerPath(_) | grovedb::Error::PathKeyNotFound(_),
)) => Ok(None),
Err(e) => Err(e),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl ContestedResourceVotesGivenByIdentityQuery {
match query_result {
Err(Error::GroveDB(GroveError::PathKeyNotFound(_)))
| Err(Error::GroveDB(GroveError::PathNotFound(_)))
| Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => Ok(BTreeMap::new()),
| Err(Error::GroveDB(GroveError::InvalidParentLayerPath(_))) => Ok(BTreeMap::new()),
Err(e) => Err(e),
Ok((query_result_elements, _)) => {
let voters =
Expand Down Expand Up @@ -209,7 +209,7 @@ impl ContestedResourceVotesGivenByIdentityQuery {
match query_result {
Err(Error::GroveDB(GroveError::PathKeyNotFound(_)))
| Err(Error::GroveDB(GroveError::PathNotFound(_)))
| Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => {
| Err(Error::GroveDB(GroveError::InvalidParentLayerPath(_))) => {
Ok((QueryResultElements::new(), 0))
}
_ => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl<'a> DriveContestedDocumentQuery<'a> {
match query_result {
Err(Error::GroveDB(GroveError::PathKeyNotFound(_)))
| Err(Error::GroveDB(GroveError::PathNotFound(_)))
| Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => Ok((Vec::new(), 0)),
| Err(Error::GroveDB(GroveError::InvalidParentLayerPath(_))) => Ok((Vec::new(), 0)),
_ => {
let (data, skipped) = query_result?;
{
Expand Down
10 changes: 4 additions & 6 deletions packages/rs-drive/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ impl<'a> DriveDocumentQuery<'a> {
.map_err(|e| match e {
Error::GroveDB(GroveError::PathKeyNotFound(_))
| Error::GroveDB(GroveError::PathNotFound(_))
| Error::GroveDB(GroveError::PathParentLayerNotFound(_)) => {
| Error::GroveDB(GroveError::InvalidParentLayerPath(_)) => {
let error_message = if self.start_at_included {
"startAt document not found"
} else {
Expand Down Expand Up @@ -1875,7 +1875,7 @@ impl<'a> DriveDocumentQuery<'a> {
match query_result {
Err(Error::GroveDB(GroveError::PathKeyNotFound(_)))
| Err(Error::GroveDB(GroveError::PathNotFound(_)))
| Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => Ok((Vec::new(), 0)),
| Err(Error::GroveDB(GroveError::InvalidParentLayerPath(_))) => Ok((Vec::new(), 0)),
_ => {
let (data, skipped) = query_result?;
{
Expand Down Expand Up @@ -1912,7 +1912,7 @@ impl<'a> DriveDocumentQuery<'a> {
match query_result {
Err(Error::GroveDB(GroveError::PathKeyNotFound(_)))
| Err(Error::GroveDB(GroveError::PathNotFound(_)))
| Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => {
| Err(Error::GroveDB(GroveError::InvalidParentLayerPath(_))) => {
Ok((QueryResultElements::new(), 0))
}
_ => {
Expand Down Expand Up @@ -2014,9 +2014,7 @@ mod tests {
use serde_json::Value::Null;

use crate::config::DriveConfig;
use crate::util::test_helpers::setup::{
setup_drive_with_initial_state_structure, setup_system_data_contract,
};
use crate::util::test_helpers::setup::setup_drive_with_initial_state_structure;
use dpp::block::block_info::BlockInfo;
use dpp::data_contract::accessors::v0::DataContractV0Getters;
use dpp::data_contracts::SystemDataContract;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ impl ContestedDocumentVotePollVotesDriveQuery {
match query_result {
Err(Error::GroveDB(GroveError::PathKeyNotFound(_)))
| Err(Error::GroveDB(GroveError::PathNotFound(_)))
| Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => Ok(vec![]),
| Err(Error::GroveDB(GroveError::InvalidParentLayerPath(_))) => Ok(vec![]),
Err(e) => Err(e),
Ok((query_result_elements, _skipped)) => {
let voters = query_result_elements
Expand Down Expand Up @@ -252,7 +252,7 @@ impl ContestedDocumentVotePollVotesDriveQuery {
match query_result {
Err(Error::GroveDB(GroveError::PathKeyNotFound(_)))
| Err(Error::GroveDB(GroveError::PathNotFound(_)))
| Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => {
| Err(Error::GroveDB(GroveError::InvalidParentLayerPath(_))) => {
Ok((QueryResultElements::new(), 0))
}
_ => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ impl<'a> ResolvedContestedDocumentVotePollDriveQuery<'a> {
match query_result {
Err(Error::GroveDB(GroveError::PathKeyNotFound(_)))
| Err(Error::GroveDB(GroveError::PathNotFound(_)))
| Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => {
| Err(Error::GroveDB(GroveError::InvalidParentLayerPath(_))) => {
Ok(ContestedDocumentVotePollDriveQueryExecutionResult::default())
}
Err(e) => Err(e),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ impl<'a> ResolvedVotePollsByDocumentTypeQuery<'a> {
match query_result {
Err(Error::GroveDB(GroveError::PathKeyNotFound(_)))
| Err(Error::GroveDB(GroveError::PathNotFound(_)))
| Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => Ok(vec![]),
| Err(Error::GroveDB(GroveError::InvalidParentLayerPath(_))) => Ok(vec![]),
Err(e) => Err(e),
Ok((query_result_elements, _)) => {
let result_is_in_key = self.result_is_in_key();
Expand Down
10 changes: 5 additions & 5 deletions packages/rs-drive/src/query/vote_polls_by_end_date_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl VotePollsByEndDateDriveQuery {
match query_result {
Err(Error::GroveDB(GroveError::PathKeyNotFound(_)))
| Err(Error::GroveDB(GroveError::PathNotFound(_)))
| Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => Ok(BTreeMap::new()),
| Err(Error::GroveDB(GroveError::InvalidParentLayerPath(_))) => Ok(BTreeMap::new()),
Err(e) => Err(e),
Ok((query_result_elements, _)) => {
let vote_polls_by_end_date = query_result_elements
Expand Down Expand Up @@ -174,7 +174,7 @@ impl VotePollsByEndDateDriveQuery {
match query_result {
Err(Error::GroveDB(GroveError::PathKeyNotFound(_)))
| Err(Error::GroveDB(GroveError::PathNotFound(_)))
| Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => Ok(vec![]),
| Err(Error::GroveDB(GroveError::InvalidParentLayerPath(_))) => Ok(vec![]),
Err(e) => Err(e),
Ok((query_result_elements, _)) => {
// Process the query result elements and collect VotePolls
Expand Down Expand Up @@ -348,7 +348,7 @@ impl VotePollsByEndDateDriveQuery {
match query_result {
Err(Error::GroveDB(GroveError::PathKeyNotFound(_)))
| Err(Error::GroveDB(GroveError::PathNotFound(_)))
| Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => Ok(BTreeMap::new()),
| Err(Error::GroveDB(GroveError::InvalidParentLayerPath(_))) => Ok(BTreeMap::new()),
Err(e) => Err(e),
Ok((query_result_elements, _)) => {
let vote_polls_by_end_date = query_result_elements
Expand Down Expand Up @@ -402,7 +402,7 @@ impl VotePollsByEndDateDriveQuery {
match query_result {
Err(Error::GroveDB(GroveError::PathKeyNotFound(_)))
| Err(Error::GroveDB(GroveError::PathNotFound(_)))
| Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => Ok(BTreeMap::new()),
| Err(Error::GroveDB(GroveError::InvalidParentLayerPath(_))) => Ok(BTreeMap::new()),
Err(e) => Err(e),
Ok((query_result_elements, _)) => {
let vote_polls_by_end_date = query_result_elements
Expand Down Expand Up @@ -456,7 +456,7 @@ impl VotePollsByEndDateDriveQuery {
match query_result {
Err(Error::GroveDB(GroveError::PathKeyNotFound(_)))
| Err(Error::GroveDB(GroveError::PathNotFound(_)))
| Err(Error::GroveDB(GroveError::PathParentLayerNotFound(_))) => {
| Err(Error::GroveDB(GroveError::InvalidParentLayerPath(_))) => {
Ok(QueryResultElements::new())
}
_ => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ mod tests {
// Assert failure due to missing intermediate path
assert_matches!(
result,
Err(Error::GroveDB(grovedb::Error::PathParentLayerNotFound(_)))
Err(Error::GroveDB(grovedb::Error::InvalidParentLayerPath(_)))
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl Drive {
.map(|r| match r {
Err(GroveError::PathKeyNotFound(_))
| Err(GroveError::PathNotFound(_))
| Err(GroveError::PathParentLayerNotFound(_)) => Ok(false),
| Err(GroveError::InvalidParentLayerPath(_)) => Ok(false),
Err(e) => Err(e),
Ok(_) => Ok(true),
})
Expand Down
Loading