Skip to content

Enhance Error Messaging for Failed Tests and Incorrect Contract Addresses #430

@mshakeg

Description

@mshakeg

Description

Currently, when a test case fails or when the contract address in the subgraph.yaml file is incorrect, Matchstick does not provide clear error messages to indicate these issues. This lack of feedback makes it challenging for developers to identify and resolve problems efficiently.

Current Behavior

  • When a test fails, there is no detailed error message or stack trace.
  • When the contract address in subgraph.yaml is incorrect, the test seems to run without errors but doesn't execute as expected.

Proposed Improvement

  1. For failed tests:

    • Provide a clear error message indicating which assertion failed.
    • Show a stack trace to help pinpoint the location of the failure.
    • Display the expected vs. actual values for failed assertions.
  2. For incorrect contract addresses:

    • Implement a validation check for contract addresses in subgraph.yaml
    • Provide a clear error message if the contract address is invalid or not found.
    • Suggest potential fixes or next steps for the developer.
  3. General improvements:

    • Implement verbose logging options to allow developers to see more details about the test execution process.
    • Add a debug mode that provides step-by-step information about entity creation, updates, and event handling.

Benefits

  • Faster debugging and problem-solving for developers.
  • Improved developer experience when working with Matchstick and subgraphs.
  • Reduced time spent on identifying issues related to configuration or test setup.

Example

Current output for a failed test or incorrect contract address:

Igniting tests 🔥
handletransfer
--------------------------------------------------
  Transfer handling:
✨  Done in 3.10s.

Proposed output for a failed test:

Igniting tests 🔥
handletransfer
--------------------------------------------------
  Transfer handling:
    ✘ should handle a transfer and update user balances - FAILED
      AssertionError: Expected balance to be 1000, but got -1000
      at transfer.test.ts:42:7
      
      Stack trace:
      [stack trace information]

      Expected: 1000
      Actual: -1000

✨  Done in 3.15s.
1 test failed.

Proposed output for an incorrect contract address:

Error: Invalid contract address in subgraph.yaml
The contract address "0x1234...5678" specified in subgraph.yaml could not be found or is invalid.
Please check the following:
1. Ensure the address is correct and properly formatted.
2. Verify that the contract exists on the specified network.
3. Check if the start block is set correctly in subgraph.yaml.

For more information, see: [link to documentation]

Additional Context

This improvement would significantly enhance the developer experience when working with Matchstick, making it easier to identify and resolve issues in subgraph development and testing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions