Skip to content

notification_tests module disabled and fails with AlreadyInitialized #490

Description

@RUKAYAT-CODER

Background

lib.rs disables the notification test module:

// TODO: Fix notification_tests module (pre-existing issue - tests fail with AlreadyInitialized)
// mod notification_tests;

There is also a notification_tests.rs.disabled file at contracts/teachlink/src/notification_tests.rs.disabled containing a full test suite (initialization, notification creation, etc.) that is completely excluded from the build — it doesn't even need uncommenting, it needs renaming back to .rs once fixed. The root cause noted is that repeated calls to NotificationManager::initialize across tests in the same module return AlreadyInitialized instead of each test getting isolated state, which points to shared/leaked storage between test functions rather than a real product bug — but it means the entire notification module currently ships with zero enforced test coverage.

Implementation Plan

  • Rename notification_tests.rs.disabled back to notification_tests.rs and re-add mod notification_tests; in lib.rs.
  • Fix the test isolation problem causing AlreadyInitialized — likely each #[test] needs its own fresh Env/contract context rather than sharing state across tests in the module.
  • Verify NotificationManager::initialize semantics are correct (should it be idempotent, or is the test setup wrong?) and document the decision.
  • Run the full suite and confirm no AlreadyInitialized failures remain.

Acceptance Criteria

  • notification_tests.rs is a live, compiled module (no .disabled extension)
  • mod notification_tests; is active in lib.rs
  • All tests pass without AlreadyInitialized errors, with proper per-test isolation

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions