mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-07 18:07:47 +08:00
fix: harden bulk wallet balance adjustment
This commit is contained in:
@@ -492,6 +492,8 @@ pub struct AppState {
|
||||
Arc<StdMutex<HashMap<String, aether_data::repository::wallet::StoredWalletSnapshot>>>,
|
||||
>,
|
||||
#[cfg(test)]
|
||||
pub(crate) auth_wallet_adjustment_error_for_tests: Option<String>,
|
||||
#[cfg(test)]
|
||||
pub(crate) admin_wallet_payment_order_store:
|
||||
Option<Arc<StdMutex<HashMap<String, AdminWalletPaymentOrderRecord>>>>,
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -466,6 +466,8 @@ impl AppState {
|
||||
#[cfg(test)]
|
||||
auth_wallet_store: Some(Arc::new(StdMutex::new(HashMap::new()))),
|
||||
#[cfg(test)]
|
||||
auth_wallet_adjustment_error_for_tests: None,
|
||||
#[cfg(test)]
|
||||
admin_wallet_payment_order_store: Some(Arc::new(StdMutex::new(HashMap::new()))),
|
||||
#[cfg(test)]
|
||||
admin_payment_callback_store: Some(Arc::new(StdMutex::new(HashMap::new()))),
|
||||
|
||||
@@ -18,6 +18,13 @@ impl AppState {
|
||||
)>,
|
||||
GatewayError,
|
||||
> {
|
||||
#[cfg(test)]
|
||||
if self.auth_wallet_adjustment_error_for_tests.as_deref() == Some(wallet_id) {
|
||||
return Err(GatewayError::Internal(
|
||||
"injected test wallet adjustment failure".to_string(),
|
||||
));
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
if let Some(store) = self.auth_wallet_store.as_ref() {
|
||||
let mut guard = store.lock().expect("auth wallet store should lock");
|
||||
|
||||
@@ -472,6 +472,14 @@ impl AppState {
|
||||
self
|
||||
}
|
||||
|
||||
pub(crate) fn fail_auth_wallet_adjustment_for_tests(
|
||||
mut self,
|
||||
wallet_id: impl Into<String>,
|
||||
) -> Self {
|
||||
self.auth_wallet_adjustment_error_for_tests = Some(wallet_id.into());
|
||||
self
|
||||
}
|
||||
|
||||
pub(crate) fn with_admin_wallet_payment_orders_for_tests<I>(mut self, orders: I) -> Self
|
||||
where
|
||||
I: IntoIterator<Item = crate::AdminWalletPaymentOrderRecord>,
|
||||
|
||||
Reference in New Issue
Block a user