Skip to content

flow test prints unreadable output #2331

@holyfuchs

Description

@holyfuchs

Summary

When a Cadence test deploys contracts in the wrong dependency order or similar issues, flow test prints hundreds of lines of raw, unformatted output that is nearly impossible to read and lags the terminal.

Current Behavior

The CLI outputs the full internal Cadence representation of the error, including the I.Test.Test.Error(message: "...") wrapper with all nested error chains encoded as an escaped string. Every line of the output is also padded with trailing spaces to a fixed column width. Example:

flow test
❌ Command Error: error in test file "cadence/tests/yield_vaults_strategy_vault_test.cdc": Execution failed:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
error: assertion failed: given value is: I.Test.Test.Error(message: "[Error Code: 1101] error caused by: 1 error occurred:\n\t* transaction execute failed: [Error Code: 1101] cadence runtime error: Execution failed:\nerror: cannot deploy invalid contract\n --> 69f412eecfa8b27d65c15b19943ed0d8a00b87d89ca7e7fabb309dc13b400084:5:20\n  |\n5 |                     signer.contracts.add(name: \"FlowYieldVaultsInterfaces\", code: \"696d706f72742046756e6769626c65546f6b656e2066726f6d203078303030303030303030303030303030320a696d706f727420466c6f77416374696f6e732066726f6d203078303030303030303030303030303030370a0a61636365737328616c6c2920636f6e747261637420466c6f775969656c645661756c7473496e7465726661636573207b0a0a2020202061636365737328616c6c292073747275637420696e74657266616365205374726174656779207b0a202020202020202061636365737328616c6c292066756e20637... \n  |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nerror: cannot find declaration `FlowActions` in `0000000000000007.FlowActions`\n --> 0000000000000007.FlowYieldVaultsInterfaces:2:7\n  |\n2 | import FlowActions from 0x0000000000000007\n  |        ^^^^^^^^^^^ available exported declarations are:\n\n\n  See documentation at: https://cadence-lang.org/docs/language/imports\n\nWas this error unhelpful?\nConsider suggesting an improvement here: https://github.com/onflow/cadence/issues.\n\n\n")
  --> helpers/deployment_helpers.cdc:52:4                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Was this error unhelpful?                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
Consider suggesting an improvement here: https://github.com/onflow/cadence/issues.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        


  • thousands of whitespaces, which need text wrapping lagging the terminal
    The output frequently exceeds 200 lines for a single assertion failure.

Expected Behavior

The CLI should display only the actionable Cadence errors (compiler/checker errors, type errors, etc.) with their source locations, without the [Error Code: 1101] transaction wrapper, the cannot deploy invalid contract outer block, or the raw I.Test.Test.Error(message: "...") encoding. Example:

❌ Test Error: cadence/tests/yield_vaults_test.cdc
Assertion failed at: helpers/deployment_helpers.cdc:55:4

error: cannot find declaration `FlowYieldVaults` in `0000000000000007.FlowYieldVaults`
 --> 0000000000000007.FlowYieldVaultsAdmin:1:7

error: ambiguous intersection type
  --> 0000000000000007.FlowYieldVaultsAdmin:23:62

Steps to Reproduce

  1. Write 2 contracts
  2. A includes B
  3. deploy A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions