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

Test contract member intialization #931

Merged
merged 2 commits into from
May 25, 2021

Conversation

turbolent
Copy link
Member

Closes #312

Description

Accessing fields before they are initialized does not cause a crash anymore since #768.

Add additional tests for this particular use-case, accessing contract fields before they are initialized.

When adding the tests I realized that in tests, the initializer of a contract is not called.
This is due to an optimization we added a while ago to only lazily load a contract value.
As most tests rely on contract declarations and thus contract initializers being evaluated eagerly, I added this to the parseCheckAndInterpret helper function that is used by all interpreter tests.


  • 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 May 21, 2021

Codecov Report

Merging #931 (e028729) into master (c84693a) will increase coverage by 34.10%.
The diff coverage is 83.33%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #931       +/-   ##
===========================================
+ Coverage   40.09%   74.20%   +34.10%     
===========================================
  Files         254      267       +13     
  Lines       32206    33001      +795     
===========================================
+ Hits        12913    24487    +11574     
+ Misses      18406     7386    -11020     
- Partials      887     1128      +241     
Flag Coverage Δ
unittests 74.20% <83.33%> (+34.10%) ⬆️

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

Impacted Files Coverage Δ
runtime/interpreter/interpreter.go 90.11% <75.00%> (+68.40%) ⬆️
runtime/interpreter/interpreter_invocation.go 96.22% <100.00%> (+47.16%) ⬆️
runtime/interpreter/interpreter_statement.go 88.63% <100.00%> (+68.18%) ⬆️
runtime/cmd/minifier/minifier.go
runtime/tests/checker/utils.go
runtime/errors/errors.go 0.00% <0.00%> (ø)
fixedpoint/parse.go 93.50% <0.00%> (ø)
runtime/compiler/ir/valtype_string.go 0.00% <0.00%> (ø)
vm/vm.go 55.17% <0.00%> (ø)
runtime/compiler/wasm/gen/main.go 0.00% <0.00%> (ø)
... and 177 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 c84693a...e028729. Read the comment docs.

runtime/tests/interpreter/contract_test.go Outdated Show resolved Hide resolved
@turbolent turbolent merged commit e52d0ba into master May 25, 2021
@turbolent turbolent deleted the bastian/312-contract-field-initialization branch May 25, 2021 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Qualifying a contract-level struct errors
3 participants