Replace stringly-typed patterns with enums and consolidate tests #8

Merged
mahmoud merged 2 commits from development_enhancements into development 2026-03-01 10:25:22 +00:00
Owner

Description

Comprehensive refactoring to eliminate DRY violations, replace error-prone string comparisons with type-safe enums, and remove dead code. All changes are pure refactoring — no behavioral changes.

Changes

  • Add TxStatus enum in tx_store.rs, update get_status() return type and all match sites in bridge.rs and cli.rs
  • Add EventType enum in chain/mod.rs, replace String field on ChainEvent and all handler matches() methods
  • Add HandlerResult enum in handlers/mod.rs, replace Result<String> return type on EventHandler::handle() and strip_prefix detection in bridge
  • Add Config::test_default() behind #[cfg(test)], replace 5 duplicate test_config() functions with struct-update syntax
  • Extract shared MockSigner into src/testing.rs, remove duplicates from handler test modules
  • Make TftToSporeHandler::new() and NodeRegisterHandler::new() synchronous
  • Remove dead code: is_processed(), has_valid_near_account_memo(), get_transfer_by_hash(), unused getters, Result<T> alias
### Description Comprehensive refactoring to eliminate DRY violations, replace error-prone string comparisons with type-safe enums, and remove dead code. All changes are pure refactoring — no behavioral changes. ### Changes - Add `TxStatus` enum in `tx_store.rs`, update `get_status()` return type and all match sites in `bridge.rs` and `cli.rs` - Add `EventType` enum in `chain/mod.rs`, replace `String` field on `ChainEvent` and all handler `matches()` methods - Add `HandlerResult` enum in `handlers/mod.rs`, replace `Result<String>` return type on `EventHandler::handle()` and `strip_prefix` detection in bridge - Add `Config::test_default()` behind `#[cfg(test)]`, replace 5 duplicate `test_config()` functions with struct-update syntax - Extract shared `MockSigner` into `src/testing.rs`, remove duplicates from handler test modules - Make `TftToSporeHandler::new()` and `NodeRegisterHandler::new()` synchronous - Remove dead code: `is_processed()`, `has_valid_near_account_memo()`, `get_transfer_by_hash()`, unused getters, `Result<T>` alias ### Related Issues - https://forge.ourworld.tf/lhumina_code/hero_tfspores/issues/7
refactor: replace stringly-typed patterns with enums and consolidate test utilities
Some checks failed
Test / test (push) Failing after 3m18s
Test / test (pull_request) Failing after 3m24s
ac8faea318
- Add TxStatus enum replacing raw status string comparisons in bridge/cli/store
- Add EventType enum replacing raw event_type string comparisons in handlers
- Add HandlerResult enum replacing "refund:" string prefix protocol
- Consolidate 5 duplicated test_config() into Config::test_default()
- Extract shared MockSigner into src/testing.rs
- Make handler constructors synchronous (no async ops)
- Remove dead code: is_processed(), get_transfer_by_hash(), unused Result alias
style: fix cargo fmt formatting
All checks were successful
Test / test (pull_request) Successful in 3m19s
Test / test (push) Successful in 3m26s
3d40a4c165
mahmoud merged commit 0383a3be81 into development 2026-03-01 10:25:22 +00:00
mahmoud deleted branch development_enhancements 2026-03-01 10:25:28 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_tfspores!8
No description provided.