Skip to content

project_registry: test_score_history_multiple_updates_ordered asserts strictly-increasing timestamps that can never differ #514

Closed

Description

@abayomicornelius

Overview

project_registry/src/test.rs's test_score_history_multiple_updates_ordered calls update_impact_score three times back-to-back with no ledger-time advance in between, then asserts the resulting ScoreHistoryEntry.timestamp values are strictly increasing:

fn test_score_history_multiple_updates_ordered() {
    let (env, _admin, _whitelister, client) = setup();
    ...
    client.update_impact_score(&id, &10u32, &20u32);
    client.update_impact_score(&id, &30u32, &40u32);
    client.update_impact_score(&id, &50u32, &60u32);

    let history = client.get_score_history(&id);
    ...
    assert!(history.get(0).unwrap().timestamp < history.get(1).unwrap().timestamp);
    assert!(history.get(1).unwrap().timestamp < history.get(2).unwrap().timestamp);
}

setup() (project_registry/src/test.rs:18-26) builds env via Env::default() and never initializes env.ledger().timestamp, and nothing in this test advances it between the three update_impact_score calls. Every history entry is therefore recorded with the identical timestamp, so < (strict) fails: assertion failed: history.get(0).unwrap().timestamp < history.get(1).unwrap().timestamp.

Why it matters

This test has never passed as written — once the workspace's compile-blocking issues (filed separately) are fixed and cargo test -p project-registry can actually run, this is one of two failures in that crate's test suite. It's meant to lock in that get_score_history preserves chronological order, but as written it can't prove anything about timestamps specifically (only that the credit_quality/entry order matches insertion order, which the separate assertions above it already cover) — it would fail on any correct implementation given three same-ledger calls.

Suggested fix

Advance the ledger timestamp between each update_impact_score call, matching the pattern used elsewhere in this codebase for time-dependent assertions:

client.update_impact_score(&id, &10u32, &20u32);
env.ledger().with_mut(|li| li.timestamp += 1);
client.update_impact_score(&id, &30u32, &40u32);
env.ledger().with_mut(|li| li.timestamp += 1);
client.update_impact_score(&id, &50u32, &60u32);

More generally, setup() initializing a realistic non-zero starting timestamp (as suggested in the sibling issue about investment_vault's setup()) would make this class of mistake harder to write in the first place, though it wouldn't fully fix this particular test since the timestamp still wouldn't change between the three calls without an explicit advance.

Activity

  1. added
    bug
    testing
    contract
    on Sep 22, 2026
  2. added
    Stellar Wave
    on Sep 30, 2026
  3. Vivianndev commented on Sep 30, 2026

    @Vivianndev

    @Vivianndev has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    Hi, I'd genuinely love to resolve this issue. Plss assign to me thanks

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Vivianndev to this issue.

  4. Isaacayomide28 commented on Sep 30, 2026

    @Isaacayomide28

    @Isaacayomide28 has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    Hello maintainer, i would like to work on this issue

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Isaacayomide28 to this issue.

  5. rhemy-arc commented on Sep 30, 2026

    @rhemy-arc

    @rhemy-arc has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    Can I work on this task?

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @rhemy-arc to this issue.

  6. bluegate916 commented on Sep 30, 2026

    @bluegate916

    @bluegate916 has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    Hi maintainer,
    I'm interested in solving this issue, please assign it to me
    I will open a PR instantly

    Thank you

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @bluegate916 to this issue.

  7. madisonsc52-del commented on Sep 30, 2026

    @madisonsc52-del

    @madisonsc52-del has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    Hi maintainer i can work on this, I'll make sure to work on the issue asap

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @madisonsc52-del to this issue.

  8. Stanley-Owoh commented on Sep 30, 2026

    @Stanley-Owoh

    @Stanley-Owoh has applied to work on this issue as part of the Stellar Wave Program's 9th wave.

    Good day maintainer please i would like to work on this issue
    I can work on this immediately with positive results please assign it to me. Thank you

    ℹ️ Repo Maintainers: To accept this application, review their application or assign @Stanley-Owoh to this issue.

  9. drips-wave commented on Sep 30, 2026

    @drips-wave

    Congratulations, @rhemy-arc! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on September 30, 2026.

    🧑‍💻 @rhemy-arc: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.

    Warning

    When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.

    🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.

    🌊 Happy Wave 🌊

  10. drips-wave commented on Sep 30, 2026

    @drips-wave

    This issue has been completed by @rhemy-arc as part of the Stellar Wave Program's 9th Wave 🥳

    😎 @rhemy-arc: You earned 200 Points for completing this issue! After the current Wave ends, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.

    🧑‍💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.

  11. removed
    Stellar Wave
    on Oct 15, 2026
  12. added
    Stellar Wave
    on Oct 15, 2026
  13. removed
    Stellar Wave
    on Oct 15, 2026
  14. added
    Stellar Wave
    on Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar Wavebugcontracttesting

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions