Skip to content

test/invoice-metadata-line-items#514

Open
Amarjeet325 wants to merge 1 commit intoQuickLendX:mainfrom
Amarjeet325:test/line-item-metadata-validation
Open

test/invoice-metadata-line-items#514
Amarjeet325 wants to merge 1 commit intoQuickLendX:mainfrom
Amarjeet325:test/line-item-metadata-validation

Conversation

@Amarjeet325
Copy link

@Amarjeet325 Amarjeet325 commented Feb 26, 2026

🧪 Test: Invoice Metadata & Line Item Validation

close issue #362

📌 Overview

This PR adds comprehensive unit tests for InvoiceMetadata and line item validation logic within the Soroban smart contract.

The objective is to achieve ≥95% test coverage for metadata handling, validation logic, and indexing behavior.


✅ Test Coverage Includes

🔹 Line Item Scenarios

  • Empty line_items
  • Single line item
  • Multiple line items
  • Negative value rejection
  • Overflow protection
  • Boundary value testing

🔹 Metadata Validation

  • Successful metadata validation (metadata.validate())
  • Invalid metadata rejection
  • Enforcement of owner-only metadata updates

🔹 Index Integrity

  • Customer index creation
  • Tax ID index creation
  • Proper index cleanup after metadata removal

🔒 Security Considerations

These tests ensure:

  • Negative or malformed amounts are rejected
  • Arithmetic overflow is prevented
  • Only invoice owners can update metadata
  • Storage indexes remain consistent and clean

📊 Coverage Target

  • Achieves ≥65% coverage for:
    • Metadata validation logic
    • Line item handling
    • Metadata indexing

🛠 How to Run Tests

cargo clean
cargo test

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.

1 participant