mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-05 00:47:48 +08:00
test(gateway): 修复 usage wallet 测试栈溢出
This commit is contained in:
@@ -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![
|
||||
|
||||
Reference in New Issue
Block a user