Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various regression tests #1425

Merged
merged 6 commits into from
Mar 3, 2022
Merged

Conversation

robert-e-davidson3
Copy link
Contributor

Closes https://github.com/dapperlabs/cadence-private-issues/issues/29

Description

Adds regression tests for Cadence. These bugs were found by Joe Soroka's fuzz testing.


  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@codecov-commenter
Copy link

codecov-commenter commented Feb 16, 2022

Codecov Report

Merging #1425 (19a32a3) into master (e5b31e1) will increase coverage by 0.14%.
The diff coverage is n/a.

❗ Current head 19a32a3 differs from pull request most recent head f67db5b. Consider uploading reports for the commit f67db5b to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1425      +/-   ##
==========================================
+ Coverage   73.00%   73.14%   +0.14%     
==========================================
  Files         288      282       -6     
  Lines       39786    39067     -719     
==========================================
- Hits        29044    28575     -469     
+ Misses       9266     9045     -221     
+ Partials     1476     1447      -29     
Flag Coverage Δ
unittests 73.14% <ø> (+0.14%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
runtime/interpreter/interpreter_tracing.go 0.00% <0.00%> (-91.67%) ⬇️
runtime/interpreter/interpreter_import.go 81.48% <0.00%> (-18.52%) ⬇️
runtime/ast/argument.go 66.66% <0.00%> (-16.67%) ⬇️
runtime/stdlib/crypto.go 71.79% <0.00%> (-13.74%) ⬇️
runtime/ast/expression.go 83.03% <0.00%> (-5.88%) ⬇️
runtime/interpreter/statictype.go 70.58% <0.00%> (-2.72%) ⬇️
runtime/interpreter/function.go 48.71% <0.00%> (-2.57%) ⬇️
runtime/ast/type.go 91.16% <0.00%> (-2.13%) ⬇️
runtime/interpreter/value.go 55.94% <0.00%> (-2.11%) ⬇️
runtime/interpreter/interpreter_expression.go 81.52% <0.00%> (-1.84%) ⬇️
... and 33 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e5b31e1...f67db5b. Read the comment docs.

@github-actions
Copy link

github-actions bot commented Feb 16, 2022

Cadence Benchstat comparison

This branch with compared with the base branch onflow:master commit 242fcfa
The command for i in {1..N}; do go test ./... -run=XXX -bench=. -shuffle=on; done was used.
Bench tests were run a total of 7 times on each branch.

Results

old.txtnew.txt
time/opdelta
RuntimeResourceDictionaryValues-217.3ms ± 6%17.0ms ± 4%~(p=0.535 n=7+7)
RuntimeFungibleTokenTransfer-21.40ms ±23%1.66ms ± 2%~(p=0.530 n=7+5)
ParseFungibleToken-2221µs ± 2%219µs ± 1%~(p=0.128 n=7+7)
ParseInfix-210.1µs ± 2%10.1µs ± 4%~(p=0.836 n=6+7)
ParseDeploy/byte_array-231.9ms ± 7%31.5ms ± 7%~(p=0.805 n=7+7)
QualifiedIdentifierCreation/One_level-22.82ns ± 0%2.81ns ± 0%~(p=0.281 n=6+6)
QualifiedIdentifierCreation/Three_levels-2170ns ± 3%171ns ± 4%~(p=0.805 n=7+7)
CheckContractInterfaceFungibleTokenConformance-2160µs ± 1%160µs ± 3%~(p=0.366 n=6+7)
ContractInterfaceFungibleToken-247.8µs ± 1%47.4µs ± 1%~(p=0.138 n=7+6)
InterpretRecursionFib-23.30ms ± 1%3.30ms ± 2%~(p=0.805 n=7+7)
NewInterpreter/new_interpreter-21.38µs ± 3%1.37µs ± 1%~(p=0.848 n=7+5)
NewInterpreter/new_sub-interpreter-22.71µs ± 7%2.69µs ± 7%~(p=0.620 n=7+7)
ParseDeploy/decode_hex-21.45ms ± 1%1.41ms ± 1%−2.23%(p=0.002 n=6+6)
ParseArray-219.7ms ±10%18.2ms ± 3%−7.75%(p=0.001 n=7+6)
 
alloc/opdelta
RuntimeResourceDictionaryValues-24.05MB ± 0%4.05MB ± 0%~(p=0.234 n=7+6)
RuntimeFungibleTokenTransfer-2273kB ± 0%273kB ± 0%~(p=0.971 n=7+7)
QualifiedIdentifierCreation/One_level-20.00B 0.00B ~(all equal)
QualifiedIdentifierCreation/Three_levels-264.0B ± 0%64.0B ± 0%~(all equal)
CheckContractInterfaceFungibleTokenConformance-266.2kB ± 0%66.2kB ± 0%~(all equal)
ContractInterfaceFungibleToken-226.6kB ± 0%26.6kB ± 0%~(p=0.140 n=7+6)
InterpretRecursionFib-21.26MB ± 0%1.26MB ± 0%~(p=0.429 n=7+7)
NewInterpreter/new_interpreter-2848B ± 0%848B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-21.32kB ± 0%1.32kB ± 0%~(all equal)
 
allocs/opdelta
RuntimeResourceDictionaryValues-2102k ± 0%102k ± 0%~(p=0.528 n=7+6)
RuntimeFungibleTokenTransfer-24.53k ± 0%4.52k ± 0%~(p=0.621 n=7+7)
QualifiedIdentifierCreation/One_level-20.00 0.00 ~(all equal)
QualifiedIdentifierCreation/Three_levels-22.00 ± 0%2.00 ± 0%~(all equal)
CheckContractInterfaceFungibleTokenConformance-21.07k ± 0%1.07k ± 0%~(all equal)
ContractInterfaceFungibleToken-2458 ± 0%458 ± 0%~(all equal)
InterpretRecursionFib-226.2k ± 0%26.2k ± 0%~(all equal)
NewInterpreter/new_interpreter-213.0 ± 0%13.0 ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-239.0 ± 0%39.0 ± 0%~(all equal)
 

"github.com/onflow/cadence/runtime/sema"
)

func TestVariousAgainstRegression(t *testing.T) {
Copy link
Member

@turbolent turbolent Feb 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be better to move each test to the related component (parser/lexer, sema/checker, interpreter). This allows running the component's tests individually and detect regressions in one component earlier in the development. For example, if we were to break the parser, all parser tests could pass, and then only when we would run the runtime tests, we would realize there is a regression.

For example, the first test case is a parser test case, so it should go into runtime/parser2/parser_test.go.
The next five test cases are checker tests, so they should go into runtime/tests/checker.
For the test cases where no error is expected, the tests should be "duplicated" in both the checker tests and the interpreter tests, so we can ensure they are successfully checked, but then also successfully interpreted (other successful tests are "duplicated" in a similar way).

Sorry I was not clear about where to add the tests to begin with, I will document this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@turbolent I moved the tests around and restructured them to fit with the other tests in those files.

@robert-e-davidson3 robert-e-davidson3 force-pushed the robert/various-regressions branch from 19a32a3 to f67db5b Compare March 2, 2022 23:39
Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you for adding these and putting them into the related "test suites" 👍

Only got a couple minor naming suggestions for keeping consistency, nothing major

@robert-e-davidson3 robert-e-davidson3 merged commit 4f14349 into master Mar 3, 2022
@turbolent turbolent deleted the robert/various-regressions branch March 3, 2022 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants