Skip to content

Fix broken unit tests in progress_tests.rs — non-compiling references and wrong panic strings #174

Description

@DeFiVC

What

Two test functions in tests/unit/progress_tests.rs reference non-existent helper functions and expect panic messages that don't match the actual contract code. These tests will not compile.

Why

The tests test_complete_module_non_existent_module_panics and test_submit_quiz_score_without_enrollment_panics call setup_tracker(&env) and create_test_course(&env, &client, &course_id) which don't exist. The actual functions are setup_contract(&env) and create_test_course(&env, &client). Additionally, the expected panic strings don't match:

  • Test expects "module does not belong to course" but contract panics with "module not found in course"
  • Test expects "learner is not enrolled in course" but contract panics with "not enrolled"

Scope

  • Fix function references to use existing helper functions
  • Update #[should_panic(expected = "...")] attributes to match actual contract panic strings
  • Verify tests compile and pass

Technical Context

  • File: tests/unit/progress_tests.rs (lines ~673-699)
  • Contract panic strings: progress-tracker/src/lib.rs (lines ~260, ~349)
  • Actual helpers: setup_contract(&env), create_test_course(&env, &client) (2 args, no course_id)

Acceptance Criteria

  • Both test functions compile successfully
  • #[should_panic(expected = "...")] matches actual contract panic strings
  • Tests pass with cargo test

Metadata

Metadata

Assignees

No one assigned

    Labels

    criticalSecurity vulnerability, data loss, broken core flow, production crash

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions