Skip to content

Add unit tests for signature aggregation edge cases #698

@theref

Description

@theref

Overview

The aggregateSignatures function in the signing module handles critical security logic for combining threshold signatures. While basic functionality is tested, edge cases need coverage to ensure robustness.

Current Testing Gap

The function at packages/taco/src/sign.ts:38-54 lacks tests for several edge cases that could occur in production.

Test Cases to Add

Add the following test cases to packages/taco/test/taco-sign.test.ts:

  1. Empty signatures object

    • Input: {} with any threshold
    • Expected: Should handle gracefully (define expected behavior)
  2. Threshold of 1 (already handled but not explicitly tested)

    • Input: Single signature
    • Expected: Return the single signature without concatenation
  3. Threshold greater than available signatures

    • Input: 2 signatures with threshold of 3
    • Expected: Should only use available signatures (current behavior)
  4. Invalid signature format

    • Input: Signatures without '0x' prefix or invalid hex
    • Expected: Define error handling behavior
  5. Large threshold values

    • Input: 10+ signatures with high threshold
    • Expected: Correct concatenation of all signatures
  6. Signature ordering consistency

    • Input: Same signatures in different orders
    • Expected: Consistent output (document if order matters)

Implementation Notes

describe('aggregateSignatures', () => {
  it('should handle empty signatures object', () => {
    // Test implementation
  });
  
  it('should return single signature when threshold is 1', () => {
    // Test implementation
  });
  
  // ... more tests
});

Files to Change

  • packages/taco/test/taco-sign.test.ts - Add new test suite for aggregateSignatures
  • Consider extracting aggregateSignatures for easier testing if needed

Definition of Done

  • All listed edge cases have test coverage
  • Tests are well-documented with clear descriptions
  • Tests follow existing testing patterns in the codebase
  • All tests pass
  • Coverage report shows improvement for the signing module

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions