Skip to content

fix: remove duplicate display code and ensure proper vault tests#69

Open
AugistineCreates wants to merge 1 commit into
OrbitChainLabs:mainfrom
AugistineCreates:fix/secure-vault-tests
Open

fix: remove duplicate display code and ensure proper vault tests#69
AugistineCreates wants to merge 1 commit into
OrbitChainLabs:mainfrom
AugistineCreates:fix/secure-vault-tests

Conversation

@AugistineCreates

Copy link
Copy Markdown

This pr closes #43

Summary

This PR resolves the issue where a tautological assert! was introduced in the test suite of secure_vault.rs, causing CI to always pass regardless of the actual environment configuration. The fix includes cleaning up duplicated display logic, improving key validation, and expanding the test coverage.

Changes

  1. Removed duplicate secret‑key display block

    • Eliminated the mistakenly duplicated display_safe implementation that appeared after impl Default.
    • Ensured display_safe prints each key (admin public/secret and issuing public/secret) only once.
  2. Improved key shape checks

    • Updated test_vault_from_env to verify that any loaded admin secret starts with 'S' and any admin public key starts with 'G' (or is empty).
  3. Added comprehensive tests

    • Positive test for testnet validation – verifies that empty keys or correctly prefixed keys pass.
    • Negative test for testnet – ensures a secret not starting with 'S' fails validation.
    • Positive test for mainnet validation – confirms that required admin keys with correct prefixes succeed.
    • Negative test for mainnet – checks that missing admin keys cause validation to fail.
    • Display safety test – confirms display_safe runs without panicking.
  4. Documentation

Why

  • The previous tautological assert (vault.admin_secret_key.is_none() || vault.admin_secret_key.is_some()) hid real configuration problems and could let CI pass erroneously.
  • The duplicated display code added noise and could cause confusion.
  • Expanded test coverage ensures future changes will be caught early and maintain correct behavior for both testnet and mainnet setups.

Testing

Running cargo test now passes all tests, confirming correct validation logic and safe display functionality.


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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[LOW] Second tautological assert in secure_vault.rs::tests::test_vault_from_env (validator passes anything)

1 participant