mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-09 18:59:50 +08:00
test(gateway): run wallet usage settlement test on larger stack
Wrap the wallet settlement usage test with the large-stack async test helper to avoid stack overflow in the default test thread.
This commit is contained in:
@@ -11,8 +11,36 @@ use super::{
|
|||||||
};
|
};
|
||||||
use aether_data::repository::settlement::InMemorySettlementRepository;
|
use aether_data::repository::settlement::InMemorySettlementRepository;
|
||||||
|
|
||||||
#[tokio::test]
|
fn run_async_test_on_large_stack<F>(name: &'static str, future: F)
|
||||||
async fn gateway_settles_wallet_for_completed_execution_runtime_sync_usage() {
|
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 usage_repository = Arc::new(InMemoryUsageReadRepository::default());
|
||||||
let request_candidate_repository = Arc::new(InMemoryRequestCandidateRepository::default());
|
let request_candidate_repository = Arc::new(InMemoryRequestCandidateRepository::default());
|
||||||
let billing_repository = Arc::new(InMemoryBillingReadRepository::seed(vec![
|
let billing_repository = Arc::new(InMemoryBillingReadRepository::seed(vec![
|
||||||
|
|||||||
Reference in New Issue
Block a user