F
Flow6mo ago
joshua

joshua | Flow (2024-06-05)

How do I get errors in the Cadence testing framework to print so they are easily readable?
6 Replies
Needle
Needle6mo ago
I've created a thread for your message. Please continue any relevant discussion in this thread. You can rename this thread using /title <new title> If this is a technical question that others may benefit from, considering also asking it on Stackoverflow: https://stackoverflow.com/questions/ask?tags=onflow-cadence
joshua
joshuaOP6mo ago
When I run tests, I get errors like this:
joshuahannan@Joshuas-MacBook-Pro-2 flow-usdc % flow-c1 test --cover --covercode="contracts" tests/*.cdc
❌ Command Error: 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 --> 751d5fec3fe39dfac9e27973430720b5fcf70588d93503e349d5f4b88f80e0e4:4:16\n |\n4 | signer.contracts.add(name: \"FiatToken\", code: \"696d706f72742043727970746f0a696d706f72742046756e6769626c65546f6b656e2066726f6d203078303030303030303030303030303030320a696d706f72742046756e6769626c65546f6b656e4d6574616461746156696577732066726f6d203078303030303030303030303030303030320a696d706f7274204d6574616461746156696577732066726f6d203078303030303030303030303030303030310a696d706f7274204f6e436861696e4d756c74695369672066726f6d203078303030303030303030303030303030370a696d706f72742049427... \n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nerror: resource `FiatToken.Admin` does not conform to resource interface `OnChainMultiSig.PublicSigner`\n --> 0000000000000007.FiatToken:334:22\n |\n334 | \taccess(all)\tresource Admin: OnChainMultiSig.PublicSigner, ResourceId, AdminCapReceiver { \n | \t \t ^\n ... \n |\n391 | \t\taccess(all) fun UUID(): UInt64{ \n | \t\t ---- mismatch here\n ... \n |\n395 | \t\taccess(all) fun getTxIndex(): UInt64{ \n | \t\t ---------- mismatch here\n\n\n")
--> test_helpers.cdc:26:4
joshuahannan@Joshuas-MacBook-Pro-2 flow-usdc % flow-c1 test --cover --covercode="contracts" tests/*.cdc
❌ Command Error: 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 --> 751d5fec3fe39dfac9e27973430720b5fcf70588d93503e349d5f4b88f80e0e4:4:16\n |\n4 | signer.contracts.add(name: \"FiatToken\", code: \"696d706f72742043727970746f0a696d706f72742046756e6769626c65546f6b656e2066726f6d203078303030303030303030303030303030320a696d706f72742046756e6769626c65546f6b656e4d6574616461746156696577732066726f6d203078303030303030303030303030303030320a696d706f7274204d6574616461746156696577732066726f6d203078303030303030303030303030303030310a696d706f7274204f6e436861696e4d756c74695369672066726f6d203078303030303030303030303030303030370a696d706f72742049427... \n | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nerror: resource `FiatToken.Admin` does not conform to resource interface `OnChainMultiSig.PublicSigner`\n --> 0000000000000007.FiatToken:334:22\n |\n334 | \taccess(all)\tresource Admin: OnChainMultiSig.PublicSigner, ResourceId, AdminCapReceiver { \n | \t \t ^\n ... \n |\n391 | \t\taccess(all) fun UUID(): UInt64{ \n | \t\t ---- mismatch here\n ... \n |\n395 | \t\taccess(all) fun getTxIndex(): UInt64{ \n | \t\t ---------- mismatch here\n\n\n")
--> test_helpers.cdc:26:4
all jumbled up
Giovanni S
Giovanni S6mo ago
I haven't been able to figure out how to pretty print test errors. I typically copy paste that and replace \n with enter but it's not very efficient
turbolent
turbolent6mo ago
it's just printing the value, which as a string in it which is the error message ah, I guess I.Test.Test.Error is actually defined by the test framework please open an issue in https://github.com/onflow/cadence-tools for now maybe just pipe the output into something that replaces the newline literals (\n) into newlines, e.g. | sed -e 's/\\n/\n/g' e.g. flow-c1 test --cover --covercode="contracts" tests/*.cdc | sed -e 's/\\n/\n/g'
joshua
joshuaOP6mo ago
Thanks!
joshua
joshuaOP6mo ago
GitHub
[Cadence Testing Framework] Pretty Print Error Messages when runnin...
Issue to be solved When running tests with the Cadence testing framework, the errors are spat out as a huge wall of text. It would be great if they were printed in a way that makes them easier to r...
Want results from more Discord servers?
Add your server