onflow / onflow/flow-cli

flow test prints unreadable output

Open
#2,331 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
209
Forks
87
Avg merge
1d 17h
Merged PRs (30d)
3

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running flow test with the failing deployment-order scenario shown in cadence/tests/yield_vaults_strategy_vault_test.cdc, then trace the reported location in helpers/deployment_helpers.cdc:52. The work is done when test failures no longer emit the escaped internal Cadence wrapper, excessive padding, and unreadable raw error output.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.