Skip to content

Commit 8c03c73

Browse files
committed
Minor cleanup
1 parent 461b8fa commit 8c03c73

File tree

10 files changed

+16
-76
lines changed

10 files changed

+16
-76
lines changed

chainstate/src/detail/ban_score.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl BanScore for ConnectTransactionError {
143143
ConnectTransactionError::InputCheck(e) => e.ban_score(),
144144
ConnectTransactionError::OrdersAccountingError(err) => err.ban_score(),
145145
ConnectTransactionError::AttemptToCreateOrderFromAccounts => 100,
146-
ConnectTransactionError::ConcludeInputAmountsDoesntMatch(_, _) => 100,
146+
ConnectTransactionError::ConcludeInputAmountsDontMatch(_, _) => 100,
147147
}
148148
}
149149
}

chainstate/src/detail/error_classification.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ impl BlockProcessingErrorClassification for ConnectTransactionError {
302302
| ConnectTransactionError::TotalFeeRequiredOverflow
303303
| ConnectTransactionError::InsufficientCoinsFee(_, _)
304304
| ConnectTransactionError::AttemptToSpendFrozenToken(_)
305-
| ConnectTransactionError::ConcludeInputAmountsDoesntMatch(_, _) => {
305+
| ConnectTransactionError::ConcludeInputAmountsDontMatch(_, _) => {
306306
BlockProcessingErrorClass::BadBlock
307307
}
308308

chainstate/tx-verifier/src/transaction_verifier/error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ pub enum ConnectTransactionError {
123123
OrdersAccountingError(#[from] orders_accounting::Error),
124124
#[error(transparent)]
125125
InputCheck(#[from] InputCheckError),
126-
#[error("Transaction {0} has conclude order input {1} with amounts that doesn't match the db")]
127-
ConcludeInputAmountsDoesntMatch(Id<Transaction>, OrderId),
126+
#[error("Transaction {0} has conclude order input {1} with amounts that don't match the db")]
127+
ConcludeInputAmountsDontMatch(Id<Transaction>, OrderId),
128128
}
129129

130130
impl From<std::convert::Infallible> for ConnectTransactionError {

chainstate/tx-verifier/src/transaction_verifier/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -852,18 +852,18 @@ where
852852
};
853853
let current_ask_balance = view.get_ask_balance(&order_id)?;
854854
let expected_filled_amount = (original_ask_balance - current_ask_balance).ok_or(
855-
ConnectTransactionError::ConcludeInputAmountsDoesntMatch(tx_id, order_id),
855+
ConnectTransactionError::ConcludeInputAmountsDontMatch(tx_id, order_id),
856856
)?;
857857

858858
ensure!(
859859
filled_amount == expected_filled_amount,
860-
ConnectTransactionError::ConcludeInputAmountsDoesntMatch(tx_id, order_id)
860+
ConnectTransactionError::ConcludeInputAmountsDontMatch(tx_id, order_id)
861861
);
862862

863863
let current_give_balance = view.get_give_balance(&order_id)?;
864864
ensure!(
865865
current_give_balance == remaining_give_amount,
866-
ConnectTransactionError::ConcludeInputAmountsDoesntMatch(tx_id, order_id)
866+
ConnectTransactionError::ConcludeInputAmountsDontMatch(tx_id, order_id)
867867
);
868868

869869
Ok(())

common/src/chain/upgrades/chainstate_upgrade.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pub enum FrozenTokensValidationVersion {
7373
pub enum OrdersVersion {
7474
/// Initial orders implementation
7575
V0,
76-
/// Calculate fill amount based on original balances; ignore nonce for fill operations
76+
/// Calculate fill amount based on original balances; ignore nonce for order operations
7777
V1,
7878
}
7979

mempool/src/error/ban_score.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl MempoolBanScore for ConnectTransactionError {
167167
ConnectTransactionError::MissingTxUndo(_) => 0,
168168
ConnectTransactionError::MissingTransactionNonce(_) => 0,
169169
ConnectTransactionError::FailedToIncrementAccountNonce => 0,
170-
ConnectTransactionError::ConcludeInputAmountsDoesntMatch(_, _) => 0,
170+
ConnectTransactionError::ConcludeInputAmountsDontMatch(_, _) => 0,
171171
}
172172
}
173173
}

mempool/src/pool/orphans/detect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl OrphanType {
7878
| CTE::CheckTransactionError(_)
7979
| CTE::OrdersAccountingError(_)
8080
| CTE::AttemptToCreateOrderFromAccounts
81-
| CTE::ConcludeInputAmountsDoesntMatch(_, _)
81+
| CTE::ConcludeInputAmountsDontMatch(_, _)
8282
| CTE::IOPolicyError(_, _) => Err(err),
8383
}
8484
}

orders-accounting/src/tests/operations.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ fn fill_order_must_converge(#[case] seed: Seed, #[case] version: OrdersVersion)
580580
let expected_give_balance = match version {
581581
OrdersVersion::V0 => BTreeMap::new(),
582582
OrdersVersion::V1 => {
583-
let tolerance: f64 = 1e-7;
583+
let tolerance: f64 = 1e-6;
584584
if remainder < tolerance {
585585
BTreeMap::new()
586586
} else {

wallet/src/account/output_cache/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,6 @@ impl OutputCache {
832832
})
833833
}
834834
},
835-
TxInput::Account(_) => false,
836835
TxInput::OrderAccountCommand(cmd) => match cmd {
837836
OrderAccountCommand::FillOrder(order_id, _, _)
838837
| OrderAccountCommand::ConcludeOrder {
@@ -846,6 +845,7 @@ impl OutputCache {
846845
})
847846
}),
848847
},
848+
TxInput::Account(_) => false,
849849
})
850850
}
851851

wallet/src/wallet/tests.rs

+4-64
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ use common::{
2626
address::pubkeyhash::PublicKeyHash,
2727
chain::{
2828
block::{consensus_data::PoSData, timestamp::BlockTimestamp, BlockReward, ConsensusData},
29-
config::{
30-
create_mainnet, create_regtest, create_unit_test_config,
31-
create_unit_test_config_builder, Builder, ChainType,
32-
},
29+
config::{create_mainnet, create_regtest, create_unit_test_config, Builder, ChainType},
3330
output_value::{OutputValue, RpcOutputValue},
3431
signature::inputsig::InputWitness,
3532
stakelock::StakePoolData,
@@ -5666,26 +5663,7 @@ fn create_order(#[case] seed: Seed) {
56665663
#[case(Seed::from_entropy())]
56675664
fn create_order_and_conclude(#[case] seed: Seed) {
56685665
let mut rng = make_seedable_rng(seed);
5669-
let chain_config = create_unit_test_config_builder()
5670-
.chainstate_upgrades(
5671-
common::chain::NetUpgrades::initialize(vec![(
5672-
BlockHeight::zero(),
5673-
common::chain::ChainstateUpgrade::new(
5674-
common::chain::TokenIssuanceVersion::V1,
5675-
common::chain::RewardDistributionVersion::V1,
5676-
common::chain::TokensFeeVersion::V1,
5677-
common::chain::DataDepositFeeVersion::V1,
5678-
common::chain::ChangeTokenMetadataUriActivated::Yes,
5679-
common::chain::FrozenTokensValidationVersion::V1,
5680-
common::chain::HtlcActivated::Yes,
5681-
common::chain::OrdersActivated::Yes,
5682-
common::chain::OrdersVersion::V0,
5683-
),
5684-
)])
5685-
.expect("cannot fail"),
5686-
)
5687-
.build();
5688-
let chain_config = Arc::new(chain_config);
5666+
let chain_config = Arc::new(create_unit_test_config());
56895667

56905668
let mut wallet = create_wallet(chain_config.clone());
56915669

@@ -5858,26 +5836,7 @@ fn create_order_and_conclude(#[case] seed: Seed) {
58585836
#[case(Seed::from_entropy())]
58595837
fn create_order_fill_completely_conclude(#[case] seed: Seed) {
58605838
let mut rng = make_seedable_rng(seed);
5861-
let chain_config = create_unit_test_config_builder()
5862-
.chainstate_upgrades(
5863-
common::chain::NetUpgrades::initialize(vec![(
5864-
BlockHeight::zero(),
5865-
common::chain::ChainstateUpgrade::new(
5866-
common::chain::TokenIssuanceVersion::V1,
5867-
common::chain::RewardDistributionVersion::V1,
5868-
common::chain::TokensFeeVersion::V1,
5869-
common::chain::DataDepositFeeVersion::V1,
5870-
common::chain::ChangeTokenMetadataUriActivated::Yes,
5871-
common::chain::FrozenTokensValidationVersion::V1,
5872-
common::chain::HtlcActivated::Yes,
5873-
common::chain::OrdersActivated::Yes,
5874-
common::chain::OrdersVersion::V0,
5875-
),
5876-
)])
5877-
.expect("cannot fail"),
5878-
)
5879-
.build();
5880-
let chain_config = Arc::new(chain_config);
5839+
let chain_config = Arc::new(create_unit_test_config());
58815840

58825841
let mut wallet1 = create_wallet_with_mnemonic(chain_config.clone(), MNEMONIC);
58835842
let mut wallet2 = create_wallet_with_mnemonic(chain_config.clone(), MNEMONIC2);
@@ -6214,26 +6173,7 @@ fn create_order_fill_completely_conclude(#[case] seed: Seed) {
62146173
#[case(Seed::from_entropy())]
62156174
fn create_order_fill_partially_conclude(#[case] seed: Seed) {
62166175
let mut rng = make_seedable_rng(seed);
6217-
let chain_config = create_unit_test_config_builder()
6218-
.chainstate_upgrades(
6219-
common::chain::NetUpgrades::initialize(vec![(
6220-
BlockHeight::zero(),
6221-
common::chain::ChainstateUpgrade::new(
6222-
common::chain::TokenIssuanceVersion::V1,
6223-
common::chain::RewardDistributionVersion::V1,
6224-
common::chain::TokensFeeVersion::V1,
6225-
common::chain::DataDepositFeeVersion::V1,
6226-
common::chain::ChangeTokenMetadataUriActivated::Yes,
6227-
common::chain::FrozenTokensValidationVersion::V1,
6228-
common::chain::HtlcActivated::Yes,
6229-
common::chain::OrdersActivated::Yes,
6230-
common::chain::OrdersVersion::V0,
6231-
),
6232-
)])
6233-
.expect("cannot fail"),
6234-
)
6235-
.build();
6236-
let chain_config = Arc::new(chain_config);
6176+
let chain_config = Arc::new(create_unit_test_config());
62376177

62386178
let mut wallet1 = create_wallet_with_mnemonic(chain_config.clone(), MNEMONIC);
62396179
let mut wallet2 = create_wallet_with_mnemonic(chain_config.clone(), MNEMONIC2);

0 commit comments

Comments
 (0)