Skip to content

[Enhancement] Add env.advance_sequence_and_time() combined helper for ledger epoch simulation #773

Description

@ekelemepraise-code

Summary

Advancing ledger time and sequence number separately requires two calls:

env.advance_time(Duration::days(7));
env.advance_sequence(1000);

In practice, Stellar ledger sequences and timestamps are coupled. A combined helper would make epoch simulation more realistic and concise.

Proposed API

// Advance both time and sequence atomically
env.advance_epoch(Duration::days(7), 1000);

// Or with a named struct for clarity
env.advance_epoch(LedgerEpoch {
    duration: Duration::days(7),
    sequences: 1000,
});

Rationale

Each Stellar ledger closes roughly every 5 seconds, so 7 days ≈ ~120,960 ledgers. The helper could optionally auto-calculate sequence count from duration based on a configurable close time.

Acceptance Criteria

  • advance_epoch(duration, sequences) implemented in contracts/crucible/src/time.rs
  • Optional with_ledger_close_time(seconds) builder method for auto-calculation
  • Exported via prelude
  • Tests added for edge cases (zero duration, zero sequences)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions