Skip to content

Commit

Permalink
Revert "refactor(remove spending counter): performance testing"
Browse files Browse the repository at this point in the history
This reverts commit 154824e.
  • Loading branch information
cong-or committed Nov 30, 2023
1 parent 0d58649 commit a4bffcd
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions chain-impl-mockchain/src/accounting/account/account_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ impl<Extra: Clone> AccountState<Extra> {
///
/// Note that this *also* increment the counter, as this function would be usually call
/// for spending.
pub fn sub(&self, _spending: SpendingCounter, v: Value) -> Result<Option<Self>, LedgerError> {
pub fn sub(&self, spending: SpendingCounter, v: Value) -> Result<Option<Self>, LedgerError> {
let new_value = (self.value - v)?;
let mut r = self.clone();

r.spending.next_verify(spending)?;
r.value = new_value;
Ok(Some(r))
}
Expand Down
13 changes: 9 additions & 4 deletions chain-impl-mockchain/src/accounting/account/spending.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,15 @@ impl SpendingCounterIncreasing {
/// a ledger error reported.
///
/// If the counter match succesfully, then the counter at this lane is incremented by one.
pub fn next_verify(&mut self, _counter: SpendingCounter) -> Result<(), LedgerError> {
Ok(())
pub fn next_verify(&mut self, counter: SpendingCounter) -> Result<(), LedgerError> {
let actual_counter = self.nexts[counter.lane()];

if actual_counter != counter {
Err(LedgerError::SpendingCredentialInvalid)
} else {
self.nexts[counter.lane()] = actual_counter.increment();
Ok(())
}
}
}

Expand Down Expand Up @@ -251,7 +258,6 @@ mod tests {
}

#[quickcheck_macros::quickcheck]
#[ignore]
pub fn spending_counter_increasing_increment(mut index: usize) -> TestResult {
let mut sc_increasing = SpendingCounterIncreasing::default();
index %= SpendingCounterIncreasing::LANES;
Expand All @@ -263,7 +269,6 @@ mod tests {
}

#[test]
#[ignore]
pub fn spending_counter_increasing_wrong_counter() {
let mut sc_increasing = SpendingCounterIncreasing::default();
let incorrect_sc = SpendingCounter::new(0, 100);
Expand Down
1 change: 0 additions & 1 deletion chain-impl-mockchain/src/ledger/ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2981,7 +2981,6 @@ mod tests {
}

#[test]
#[ignore]
fn test_internal_apply_transaction_wrong_spending_counter() {
let faucet =
AddressDataValue::account_with_spending_counter(Discrimination::Test, 1, Value(1));
Expand Down
2 changes: 0 additions & 2 deletions chain-impl-mockchain/src/ledger/tests/transaction_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ pub fn transaction_fail_when_validity_too_far() {
}

#[test]
#[ignore]
pub fn duplicated_account_transaction() {
let mut test_ledger = LedgerBuilder::from_config(ConfigBuilder::new())
.faucet_value(Value(1000))
Expand Down Expand Up @@ -160,7 +159,6 @@ pub fn transaction_nonexisting_account_input() {
}

#[test]
#[ignore]
pub fn transaction_with_incorrect_account_spending_counter() {
let faucet =
AddressDataValue::account_with_spending_counter(Discrimination::Test, 1, Value(1000));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use crate::{
};

#[test]
#[ignore]
pub fn ledger_accepts_signature_from_all_lanes() {
let (mut ledger, controller) = prepare_scenario()
.with_config(ConfigBuilder::new().with_fee(LinearFee::new(1, 1, 1)))
Expand Down

0 comments on commit a4bffcd

Please sign in to comment.