Skip to content

[Enhancement] Implement SimulatedTx::assert_fee_below() and assert_instructions_below() helper methods #771

Description

@ekelemepraise-code

Summary

Currently users must manually extract and compare values from SimulatedTx:

let sim = env.simulate(|| client.call());
assert!(sim.fee() < 5000, "fee too high: {}", sim.fee());
assert!(sim.instructions() < 1_000_000, "too many instructions: {}", sim.instructions());

This is verbose and produces unhelpful panic messages. We should add fluent assertion methods directly on SimulatedTx<T>.

Proposed API

env.simulate(|| client.call())
   .assert_fee_below(5_000)           // fails with detailed message if fee >= 5000
   .assert_instructions_below(1_000_000)  // fails with detailed message if instructions >= threshold
   .commit();

Implementation Notes

  • Methods should be chainable (return &Self or Self)
  • Panic messages must include actual vs expected values
  • Add corresponding assert_fee_above() / assert_instructions_above() for regression lower-bounds

Acceptance Criteria

  • Both assertion methods implemented on SimulatedTx
  • Chainable with .commit()
  • Documented in API Reference section of README
  • Example added to examples/

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