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

Add test for casting storage ref to an invalid type #1243

Merged
merged 1 commit into from
Nov 16, 2021

Conversation

SupunS
Copy link
Member

@SupunS SupunS commented Nov 16, 2021

Description

There were no tests for the following scenario:

  • Saving struct value of type T in an account
  • Borrowing it as a super-type auth AnyStruct
  • Downcast it to a different type auth R

This was the only scenario that doesn't work if we do #1217 (there's a solution for it, I'll update the original git-issue with more context/info), but realized there were no test cases for this particular case (all tests were passing!)


  • 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

@github-actions
Copy link

github-actions bot commented Nov 16, 2021

Cadence Benchstat comparison

This branch with compared with the base branch onflow:master commit ad6895c
The command go test ./... -run=XXX -bench=. -shuffle=on -count N was used.
Bench tests were run a total of 7 times on each branch.

Results

old.txtnew.txt
time/opdelta
RuntimeStorageWriteCached-2136µs ± 4%173µs ±29%+27.13%(p=0.011 n=7+7)
CheckContractInterfaceFungibleTokenConformance-2147µs ± 3%157µs ± 6%+7.14%(p=0.001 n=6+7)
InterpretRecursionFib-22.62ms ± 4%2.79ms ± 5%+6.47%(p=0.002 n=7+7)
ContractInterfaceFungibleToken-244.9µs ± 1%47.8µs ± 1%+6.34%(p=0.001 n=6+7)
RuntimeFungibleTokenTransfer-21.13ms ± 4%1.18ms ± 5%+4.58%(p=0.022 n=6+7)
ParseInfix-224.0µs ± 2%24.9µs ± 2%+3.91%(p=0.001 n=7+7)
QualifiedIdentifierCreation/Three_levels-2159ns ± 1%164ns ± 2%+3.19%(p=0.002 n=7+7)
QualifiedIdentifierCreation/One_level-22.69ns ± 3%2.78ns ± 1%+3.04%(p=0.005 n=7+7)
ParseArray-223.0ms ± 2%23.6ms ± 4%+3.01%(p=0.026 n=7+7)
ParseDeploy/decode_hex-21.37ms ± 1%1.41ms ± 1%+3.00%(p=0.001 n=7+7)
ParseFungibleToken-2459µs ± 1%469µs ± 5%+2.35%(p=0.035 n=6+7)
RuntimeResourceDictionaryValues-216.7ms ± 2%16.7ms ± 4%~(p=1.000 n=7+7)
ParseDeploy/byte_array-233.9ms ± 2%34.4ms ± 4%~(p=0.383 n=7+7)
NewInterpreter/new_interpreter-21.13µs ± 4%1.16µs ± 3%~(p=0.053 n=7+7)
NewInterpreter/new_sub-interpreter-22.09µs ± 4%2.13µs ± 4%~(p=0.128 n=7+7)
 
alloc/opdelta
RuntimeFungibleTokenTransfer-2233kB ± 0%233kB ± 0%~(p=0.831 n=7+7)
RuntimeResourceDictionaryValues-24.34MB ± 0%4.34MB ± 0%~(p=0.620 n=7+7)
RuntimeStorageWriteCached-283.7kB ± 0%83.7kB ± 0%~(p=0.434 n=7+6)
QualifiedIdentifierCreation/One_level-20.00B 0.00B ~(all equal)
QualifiedIdentifierCreation/Three_levels-264.0B ± 0%64.0B ± 0%~(all equal)
CheckContractInterfaceFungibleTokenConformance-266.4kB ± 0%66.4kB ± 0%~(all equal)
ContractInterfaceFungibleToken-226.7kB ± 0%26.7kB ± 0%~(all equal)
InterpretRecursionFib-21.21MB ± 0%1.21MB ± 0%~(all equal)
NewInterpreter/new_interpreter-2680B ± 0%680B ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-21.06kB ± 0%1.06kB ± 0%~(all equal)
 
allocs/opdelta
RuntimeFungibleTokenTransfer-24.43k ± 0%4.43k ± 0%~(p=1.000 n=7+7)
RuntimeResourceDictionaryValues-2108k ± 0%108k ± 0%~(p=0.730 n=6+7)
RuntimeStorageWriteCached-21.42k ± 0%1.42k ± 0%~(all equal)
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-225.0k ± 0%25.0k ± 0%~(all equal)
NewInterpreter/new_interpreter-211.0 ± 0%11.0 ± 0%~(all equal)
NewInterpreter/new_sub-interpreter-231.0 ± 0%31.0 ± 0%~(all equal)
 

@codecov-commenter
Copy link

Codecov Report

Merging #1243 (5b56d32) into master (ad6895c) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1243   +/-   ##
=======================================
  Coverage   77.59%   77.59%           
=======================================
  Files         274      274           
  Lines       35232    35232           
=======================================
  Hits        27339    27339           
  Misses       6806     6806           
  Partials     1087     1087           
Flag Coverage Δ
unittests 77.59% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out 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 ad6895c...5b56d32. Read the comment docs.

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.

Thank you for adding a test for this 👍

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