fix(admin): classify bulk wallet adjustment failures

This commit is contained in:
RWDai
2026-09-23 17:27:34 +08:00
parent 30bb0c3130
commit 75471ae4a4
8 changed files with 216 additions and 13 deletions
+2
View File
@@ -494,6 +494,8 @@ pub struct AppState {
#[cfg(test)]
pub(crate) auth_wallet_adjustment_error_for_tests: Option<String>,
#[cfg(test)]
pub(crate) auth_wallet_lookup_error_for_tests: Option<String>,
#[cfg(test)]
pub(crate) admin_wallet_payment_order_store:
Option<Arc<StdMutex<HashMap<String, AdminWalletPaymentOrderRecord>>>>,
#[cfg(test)]
+2
View File
@@ -468,6 +468,8 @@ impl AppState {
#[cfg(test)]
auth_wallet_adjustment_error_for_tests: None,
#[cfg(test)]
auth_wallet_lookup_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()))),
@@ -5,6 +5,19 @@ impl AppState {
&self,
lookup: aether_data::repository::wallet::WalletLookupKey<'_>,
) -> Result<Option<aether_data::repository::wallet::StoredWalletSnapshot>, GatewayError> {
#[cfg(test)]
if let Some(failed_user_id) = self.auth_wallet_lookup_error_for_tests.as_deref() {
let lookup_user_id = match &lookup {
aether_data::repository::wallet::WalletLookupKey::UserId(user_id) => Some(*user_id),
_ => None,
};
if lookup_user_id == Some(failed_user_id) {
return Err(GatewayError::Internal(
"injected test wallet lookup failure".to_string(),
));
}
}
#[cfg(test)]
if let Some(store) = self.auth_wallet_store.as_ref() {
let wallet = {
+5
View File
@@ -480,6 +480,11 @@ impl AppState {
self
}
pub(crate) fn fail_auth_wallet_lookup_for_tests(mut self, user_id: impl Into<String>) -> Self {
self.auth_wallet_lookup_error_for_tests = Some(user_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>,