Skip to content

Commit

Permalink
refactor: add max available executors to error
Browse files Browse the repository at this point in the history
  • Loading branch information
mariocao committed Aug 13, 2024
1 parent 77770ae commit b6c3a80
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions contract/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ pub enum ContractError {
#[error("DataRequestAlreadyExists: Data request already exists")]
DataRequestAlreadyExists,
#[error(
"ReplicationFactorExceedsExecutorCount: The specified replication factor exceeds the available number of executors"
"ReplicationFactorExceedsExecutorCount: The specified replication factor exceeds the available number of executors ({0})"
)]
DataRequestReplicationFactorTooHigh,
DataRequestReplicationFactorTooHigh(usize),
#[error("Invalid payback address")]
InvalidPaybackAddr,
#[error("IneligibleExecutor: Caller is not an eligible data request executor")]
Expand Down
2 changes: 1 addition & 1 deletion contract/src/msgs/data_requests/execute/post_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl ExecuteHandler for execute::post_request::Execute {
.keys(deps.storage, None, None, cosmwasm_std::Order::Ascending)
.count();
if usize::from(self.posted_dr.replication_factor) > stakers_length {
return Err(ContractError::DataRequestReplicationFactorTooHigh);
return Err(ContractError::DataRequestReplicationFactorTooHigh(stakers_length));
}

// TODO: verify the payback non seda address...
Expand Down
2 changes: 1 addition & 1 deletion contract/src/msgs/data_requests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -911,5 +911,5 @@ fn post_data_request_replication_factor_too_high() {
// expect an error when trying to post it again
let dr = test_helpers::calculate_dr_id_and_args(1, 2);
let res = test_info.post_data_request(&sender, dr.clone(), vec![], vec![1, 2, 3], 1);
assert!(res.is_err_and(|x| x == ContractError::DataRequestReplicationFactorTooHigh));
assert!(res.is_err_and(|x| x == ContractError::DataRequestReplicationFactorTooHigh(2)));
}

0 comments on commit b6c3a80

Please sign in to comment.