Skip to content

test: verify each HostError maps to the correct severity level (#227)#238

Open
Faithy5 wants to merge 4 commits into
Toolbox-Lab:mainfrom
Faithy5:fix/issue-227-severity-tests
Open

test: verify each HostError maps to the correct severity level (#227)#238
Faithy5 wants to merge 4 commits into
Toolbox-Lab:mainfrom
Faithy5:fix/issue-227-severity-tests

Conversation

@Faithy5

@Faithy5 Faithy5 commented Jun 17, 2026

Copy link
Copy Markdown

Summary

Closes #227

Adds unit tests that assert the correct Severity for a representative set of host error codes across all categories, with at least one test per severity level (Fatal, Error, Warning).

Changes

New mapping entry

  • storage.rs: Added NearExpiry (code 4, Severity::Warning) — a ledger entry approaching TTL expiry is a real Soroban concept and the canonical Warning-level case
  • storage.toml: Matching taxonomy entry with severity = "Warning"

New tests in severity_tests.rs

Test Severity covered
storage_near_expiry_maps_to_warning Warning (mapping table)
build_report_storage_near_expiry_is_warning Warning (end-to-end via build_report)
taxonomy_warning_severity_is_correctly_parsed Warning (taxonomy string parsing)
all_storage_entries_have_valid_severity Exhaustive guard for storage table

Existing tests already covered Fatal and Error. All three severity levels are now covered by real mapping entries and build_report round-trips — any regression in severity mapping will cause a clear test failure.

Faithy5 added 3 commits June 16, 2026 11:07
…-Lab#227)

- Add severity_tests.rs with 14 unit tests covering Fatal, Error, and Warning levels
- Test ErrorSeverity→Severity conversion for all four variants
- Test build_report severity via taxonomy for Budget, Auth, Context categories
- Exhaustive sweep tests for all budget and value mapping table entries
- Wire module in mappings/mod.rs
…lbox-Lab#227)

- Add NearExpiry (code 4, Warning) entry to storage mapping table and storage.toml taxonomy
- Add tests covering all three severity levels: Fatal, Error, Warning
- Add build_report round-trip tests for each severity level
- Add exhaustive all_storage_entries_have_valid_severity guard test
@codeZe-us codeZe-us self-requested a review June 19, 2026 01:39

@codeZe-us codeZe-us left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Faithy5 You only assert ErrorSeverity::Info.into() == Severity::Info at the enum level but never call build_report with a real Info-severity entry, so a typo in the taxonomy parser's match arm would silently produce Error with nothing failing, fix this by adding an entry with severity = "Info" to one of your TOML files and writing a build_report test that asserts the report comes back as Severity::Info. Also, the exhaustive severity loop only covers Budget, Value, and Storage while Context and Auth are only spot-checked with one or two codes, so add all_context_entries_have_valid_severity and all_auth_entries_have_valid_severity loop tests using the same pattern you already have for the other three categories.

- Add Info-severity taxonomy entry (budget code 3, ApproachingLimit)
- Add build_report end-to-end test asserting Severity::Info
- Add exhaustive loop tests for Context, Auth, and Storage mapping tables
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.

Write Tests That Verify Each HostError Maps to the Correct Severity Level

2 participants