Skip to content

Commit

Permalink
:wRevert "Revert "refactor(remove spending counter): performance test…
Browse files Browse the repository at this point in the history
…ing""

This reverts commit a4bffcd.
  • Loading branch information
cong-or committed Dec 1, 2023
1 parent a4bffcd commit 6782a34
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 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: 4 additions & 9 deletions chain-impl-mockchain/src/accounting/account/spending.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,8 @@ 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> {
let actual_counter = self.nexts[counter.lane()];

if actual_counter != counter {
Err(LedgerError::SpendingCredentialInvalid)
} else {
self.nexts[counter.lane()] = actual_counter.increment();
Ok(())
}
pub fn next_verify(&mut self, _counter: SpendingCounter) -> Result<(), LedgerError> {
Ok(())
}
}

Expand Down Expand Up @@ -258,6 +251,7 @@ 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 @@ -269,6 +263,7 @@ 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: 1 addition & 0 deletions chain-impl-mockchain/src/ledger/ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2981,6 +2981,7 @@ 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: 2 additions & 0 deletions chain-impl-mockchain/src/ledger/tests/transaction_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ 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 @@ -159,6 +160,7 @@ 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,6 +9,7 @@ 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 6782a34

Please sign in to comment.