Extend testcase timeout to prevent panic, seperate anvil feature for testcase. (#28)

* chore: update unit test timeout to avoid panic, seperate anvil feature for testcase use foundry's anvil

* chore: add constant for the timeout number
This commit is contained in:
Vinh Trịnh
2025-08-18 16:09:19 +07:00
committed by GitHub
parent 11b06a440d
commit 1d44d60df2
6 changed files with 24 additions and 11 deletions

View File

@@ -32,6 +32,9 @@ mod proof_service_tests {
const TX_HASH_1: [u8; 32] = [0x011; 32];
const TX_HASH_1_2: [u8; 32] = [0x12; 32];
// Set to 10 seconds as 5 seconds can cause failures on Mac M1 machines.
const PROOF_VERIFY_TEST_TIMEOUT: u64 = 10;
#[derive(thiserror::Error, Debug)]
enum AppErrorExt {
#[error("AppError: {0}")]
@@ -87,10 +90,12 @@ mod proof_service_tests {
debug!("Starting broadcast receiver...");
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
let res =
tokio::time::timeout(std::time::Duration::from_secs(5), broadcast_receiver.recv())
.await
.map_err(|_e| AppErrorExt::Elapsed)?;
let res = tokio::time::timeout(
std::time::Duration::from_secs(PROOF_VERIFY_TEST_TIMEOUT),
broadcast_receiver.recv(),
)
.await
.map_err(|_e| AppErrorExt::Elapsed)?;
debug!("res: {:?}", res);
let res = res.unwrap();
@@ -190,10 +195,12 @@ mod proof_service_tests {
let mut proof_values_store = vec![];
loop {
let res =
tokio::time::timeout(std::time::Duration::from_secs(5), broadcast_receiver.recv())
.await
.map_err(|_e| AppErrorExt::Elapsed)?;
let res = tokio::time::timeout(
std::time::Duration::from_secs(PROOF_VERIFY_TEST_TIMEOUT),
broadcast_receiver.recv(),
)
.await
.map_err(|_e| AppErrorExt::Elapsed)?;
let res = res.unwrap();
let res = res?;
@@ -337,7 +344,7 @@ mod proof_service_tests {
assert_eq!(secret_hash, user_addr_1.secret_hash);
}
_ => {
panic!("Unexpected result");
panic!("Expected to RecoveredSecret, got: {res:?}");
}
}
}