test: verify each HostError maps to the correct severity level (#227)#238
test: verify each HostError maps to the correct severity level (#227)#238Faithy5 wants to merge 4 commits into
Conversation
…-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
test: verify host error severity mappings (Toolbox-Lab#227)
…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
left a comment
There was a problem hiding this comment.
@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
Summary
Closes #227
Adds unit tests that assert the correct
Severityfor 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: AddedNearExpiry(code 4,Severity::Warning) — a ledger entry approaching TTL expiry is a real Soroban concept and the canonical Warning-level casestorage.toml: Matching taxonomy entry withseverity = "Warning"New tests in
severity_tests.rsstorage_near_expiry_maps_to_warningbuild_report_storage_near_expiry_is_warningbuild_report)taxonomy_warning_severity_is_correctly_parsedall_storage_entries_have_valid_severityExisting tests already covered Fatal and Error. All three severity levels are now covered by real mapping entries and
build_reportround-trips — any regression in severity mapping will cause a clear test failure.