Skip to content

test: add comprehensive tests for invoice amendment (#135)#152

Open
edehvictor wants to merge 1 commit intoShadeProtocol:mainfrom
edehvictor:test/issue-135-invoice-amendment
Open

test: add comprehensive tests for invoice amendment (#135)#152
edehvictor wants to merge 1 commit intoShadeProtocol:mainfrom
edehvictor:test/issue-135-invoice-amendment

Conversation

@edehvictor
Copy link

@edehvictor edehvictor commented Feb 26, 2026

Description

This PR introduces comprehensive unit tests to verify the amendment rules for invoices within the shade contract. It explicitly tests the allowed happy path for pending invoices and the restricted error path for already-paid invoices.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Test improvements
  • Other (please describe):

Related Issues

Fixes #135

Changes Made

  • Added a new test file contracts/shade/src/tests/test_invoice_amendment.rs.
  • Implemented test_merchant_can_amend_pending_invoice to verify a merchant can successfully update the amount of an invoice currently in the Pending state.
  • Implemented test_amend_paid_invoice_fails using the #[should_panic] attribute to ensure that attempting to amend an invoice in the Paid state is securely rejected by the contract.
  • Registered the new test_invoice_amendment module in the parent tests module.

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • All existing tests pass locally
  • I have tested this manually

How to reproduce:
Run the standard Soroban test command for this specific module:
cargo test --package shade test_invoice_amendment

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Screenshots (if applicable)

N/A

Additional Notes

These tests rely on the standard Env::default().mock_all_auths() setup to cleanly bypass signature requirements and isolate the specific state-transition logic of the invoices.

@edehvictor
Copy link
Author

@DanielEmmanuel1 please review

@edehvictor
Copy link
Author

@DanielEmmanuel1 please kindly review

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create Comprehensive Tests for Invoice Amendment

1 participant