test(gateway): 修复 usage wallet 测试栈溢出

This commit is contained in:
stabey
2026-05-31 03:35:01 +08:00
parent ba4e194cb5
commit de0a880ca6
+30 -2
View File
@@ -11,8 +11,36 @@ use super::{
};
use aether_data::repository::settlement::InMemorySettlementRepository;
#[tokio::test]
async fn gateway_settles_wallet_for_completed_execution_runtime_sync_usage() {
fn run_async_test_on_large_stack<F>(name: &'static str, future: F)
where
F: std::future::Future<Output = ()> + Send + 'static,
{
let handle = std::thread::Builder::new()
.name(name.to_string())
.stack_size(8 * 1024 * 1024)
.spawn(move || {
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("tokio runtime should build")
.block_on(future);
})
.expect("large-stack test thread should spawn");
if let Err(payload) = handle.join() {
std::panic::resume_unwind(payload);
}
}
#[test]
fn gateway_settles_wallet_for_completed_execution_runtime_sync_usage() {
run_async_test_on_large_stack(
"gateway_settles_wallet_for_completed_execution_runtime_sync_usage",
gateway_settles_wallet_for_completed_execution_runtime_sync_usage_impl(),
);
}
async fn gateway_settles_wallet_for_completed_execution_runtime_sync_usage_impl() {
let usage_repository = Arc::new(InMemoryUsageReadRepository::default());
let request_candidate_repository = Arc::new(InMemoryRequestCandidateRepository::default());
let billing_repository = Arc::new(InMemoryBillingReadRepository::seed(vec![