Skip to content

[FEATURE]: Add Basic Unit Tests for Transaction Signing and Verification #3

@dhruvi-16-me

Description

@dhruvi-16-me

Feature and its Use Cases

📄 Description

MiniChain plans to implement transaction signing and verification using PyNaCl.

Once the core transaction logic is available, it would be beneficial to add a minimal unit test suite to ensure correctness and prevent subtle cryptographic bugs.

Since MiniChain aims to be a clean and educational blockchain implementation, including simple tests would improve reliability without adding unnecessary complexity.

Proposed Test Cases

  1. Valid Transaction

    • A properly signed transaction should verify successfully.
  2. Modified Transaction Data

    • Changing transaction fields (e.g., amount) after signing should cause verification to fail.
  3. Invalid Public Key

    • Using an incorrect public key should fail verification.
  4. Replay Protection

    • Reusing a transaction with the same nonce should be rejected by state validation logic.

Suggested Approach

  • Use Python’s built-in unittest or pytest
  • Add a tests/ directory
  • Keep test coverage minimal but focused on correctness

Why This Matters

  • Ensures deterministic and correct signature verification
  • Prevents subtle security issues
  • Encourages test-driven development
  • Keeps the project aligned with its educational goal

Additional Context

No response

Code of Conduct

  • I have joined the Discord server and will post updates there
  • I have searched existing issues to avoid duplicates

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions