Skip to content

fix(tests): replace panic-prone unwrap/expect/todo!/panic! with typed…#685

Open
essiend03-glitch wants to merge 1 commit into
kellymusk:masterfrom
essiend03-glitch:fix/replace-panic-prone-unwrap-in-tests
Open

fix(tests): replace panic-prone unwrap/expect/todo!/panic! with typed…#685
essiend03-glitch wants to merge 1 commit into
kellymusk:masterfrom
essiend03-glitch:fix/replace-panic-prone-unwrap-in-tests

Conversation

@essiend03-glitch

Copy link
Copy Markdown
Contributor

closes #579
closes #582
closes #584

… error propagation

Addresses issues in three test files that contained a combined 74 panic-prone calls (unwrap, expect, panic!, todo!):

  • tests/commission_engine_test.rs (23 occurrences)

    • make_structure() now returns Result<CommissionStructure, Box> using .transpose()? instead of .unwrap() on BigDecimal::from_str
    • All unit test fns return Result<(), Box>, propagating errors from compute_commission() with ? instead of .unwrap()
    • Integration test pool() returns Result<PgPool, sqlx::Error>; all DB calls propagate with ? instead of .unwrap()
  • src/crypto/tests.rs (25 occurrences)

    • All test fns return Result<(), Box>
    • Crypto operations (aes_gcm_encrypt, aes_gcm_decrypt, PlatformKeyVersion::generate, KeyStore::new, ecdh_derive_kek, aes_kw_wrap, kv.unwrap_session_key, decode_nonce, URL_SAFE_NO_PAD.decode, PublicKey::from_sec1_bytes) now propagate with ? instead of .unwrap()
  • src/security/tests.rs (26 occurrences)

    • create_test_pool() replaced todo!() with proper Result-returning DB connect; tests that cannot connect will fail with a descriptive error rather than a compile-time unimplemented panic
    • All async test fns return Result<(), Box>, propagating service call errors with ?
    • panic!("Expected SystemHalted error") in match arm replaced with typed Err(format!(...).into()) for proper error propagation

No logic changes — assertions and test intent are preserved.

… error propagation

Addresses issues in three test files that contained a combined 74 panic-prone
calls (unwrap, expect, panic!, todo!):

- tests/commission_engine_test.rs (23 occurrences)
  - make_structure() now returns Result<CommissionStructure, Box<dyn Error>>
    using .transpose()? instead of .unwrap() on BigDecimal::from_str
  - All unit test fns return Result<(), Box<dyn Error>>, propagating errors
    from compute_commission() with ? instead of .unwrap()
  - Integration test pool() returns Result<PgPool, sqlx::Error>; all DB
    calls propagate with ? instead of .unwrap()

- src/crypto/tests.rs (25 occurrences)
  - All test fns return Result<(), Box<dyn Error>>
  - Crypto operations (aes_gcm_encrypt, aes_gcm_decrypt, PlatformKeyVersion::generate,
    KeyStore::new, ecdh_derive_kek, aes_kw_wrap, kv.unwrap_session_key,
    decode_nonce, URL_SAFE_NO_PAD.decode, PublicKey::from_sec1_bytes) now
    propagate with ? instead of .unwrap()

- src/security/tests.rs (26 occurrences)
  - create_test_pool() replaced todo!() with proper Result-returning DB
    connect; tests that cannot connect will fail with a descriptive error
    rather than a compile-time unimplemented panic
  - All async test fns return Result<(), Box<dyn Error>>, propagating
    service call errors with ?
  - panic!("Expected SystemHalted error") in match arm replaced with
    typed Err(format!(...).into()) for proper error propagation

No logic changes — assertions and test intent are preserved.
@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@essiend03-glitch Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant