Skip to content

Commit

Permalink
Merge pull request #171 from benthecarman/validate-threshold-9
Browse files Browse the repository at this point in the history
Validate OralceInput.threshold != 0
  • Loading branch information
Tibo-lg authored Nov 14, 2023
2 parents b687715 + a32ad2e commit aabb96f
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions dlc-manager/src/contract/contract_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ impl OracleInput {
));
}

if self.threshold == 0 {
return Err(Error::InvalidParameters(
"Threshold cannot be zero.".to_string(),
));
}

Ok(())
}
}
Expand Down Expand Up @@ -184,4 +190,13 @@ mod tests {
.validate()
.expect_err("the contract input to be invalid.");
}

#[test]
fn invalid_oracle_info_threshold_zero() {
let mut input = get_base_input();
input.contract_infos[0].oracles.threshold = 0;
input
.validate()
.expect_err("the contract input to be invalid.");
}
}

0 comments on commit aabb96f

Please sign in to comment.