Skip to content

Commit

Permalink
refactor: rename ambiguous tx error
Browse files Browse the repository at this point in the history
Revert "refactor: rename Cellbase -> CellBase"

This reverts commit 8de3ae7b07e0894bcdeb133b65cbbd1f4ce9af36.
  • Loading branch information
zhangsoledad committed Dec 26, 2018
1 parent ede5108 commit 58cb857
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
6 changes: 4 additions & 2 deletions verification/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,12 @@ pub enum DifficultyError {
#[derive(Debug, PartialEq, Clone, Copy, Eq)]
pub enum TransactionError {
NullInput,
OutOfBound,
/// Occur output's bytes_len exceed capacity
CapacityOverflow,
DuplicateInputs,
Empty,
InvalidCapacity,
/// Sum of all outputs capacity exceed sum of all inputs in the transaction
OutputsSumOverflow,
InvalidScript,
ScriptFailure(ScriptError),
InvalidSignature,
Expand Down
7 changes: 5 additions & 2 deletions verification/src/tests/transaction_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ pub fn test_capacity_outofbound() {
};
let verifier = CapacityVerifier::new(&rtx);

assert_eq!(verifier.verify().err(), Some(TransactionError::OutOfBound));
assert_eq!(
verifier.verify().err(),
Some(TransactionError::CapacityOverflow)
);
}

#[test]
Expand All @@ -69,7 +72,7 @@ pub fn test_capacity_invalid() {

assert_eq!(
verifier.verify().err(),
Some(TransactionError::InvalidCapacity)
Some(TransactionError::OutputsSumOverflow)
);
}

Expand Down
4 changes: 2 additions & 2 deletions verification/src/transaction_verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ impl<'a> CapacityVerifier<'a> {
.fold(0, |acc, output| acc + output.capacity);

if inputs_total < outputs_total {
Err(TransactionError::InvalidCapacity)
Err(TransactionError::OutputsSumOverflow)
} else if self
.resolved_transaction
.transaction
.outputs()
.iter()
.any(|output| output.bytes_len() as Capacity > output.capacity)
{
Err(TransactionError::OutOfBound)
Err(TransactionError::CapacityOverflow)
} else {
Ok(())
}
Expand Down

0 comments on commit 58cb857

Please sign in to comment.