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

Make encode method generalized for ComputedType #629

Merged
merged 15 commits into from
Jan 4, 2023

Conversation

ahangsu
Copy link
Contributor

@ahangsu ahangsu commented Jan 3, 2023

No description provided.

@ahangsu ahangsu marked this pull request as ready for review January 3, 2023 19:15
@ahangsu ahangsu force-pushed the generalized-encode-for-computed-type branch from a892314 to 994d9bb Compare January 3, 2023 20:20
@ahangsu ahangsu force-pushed the generalized-encode-for-computed-type branch from 44318bb to 76e6b58 Compare January 3, 2023 22:03
Copy link
Contributor

@tzaffi tzaffi left a comment

Choose a reason for hiding this comment

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

A couple of minor suggestions.

pyteal/ast/abi/type.py Show resolved Hide resolved
pyteal/ast/abi/tuple.py Outdated Show resolved Hide resolved
pyteal/ast/abi/util.py Outdated Show resolved Hide resolved
ignoreNext = 0
for i, typeAfter in enumerate(value_types[index + 1 :], start=index + 1):
lastBoolStart = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

It's hard to tell -without a deep dive- whether this new version is functionally equivalent. If I understand correctly (???), there is currently no unit test that covers this code so we can't be 100% confident of correctness. If a unit test is added, (but probably that should be in the parent PR), then this would allay my concerns.

As an aside, I'm already thinking of starting some nightly tests. It might be a good opportunity to add python's coverage tool to such tests: https://github.com/nedbat/coveragepy

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My apologies, I am hacking through these APIs without a same set of unit test coverage, so I guarantee there will be a same set of unit test for functional equivalence.

The side note for coveragepy also makes sense to me, maybe not going into this PR, but as a separate one. The expected result should be somehow like go-algorand one, i.e., coverage +/- lines?

Copy link
Contributor

@tzaffi tzaffi Jan 4, 2023

Choose a reason for hiding this comment

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

Regarding coverage testing in C.I., definitely not this PR. I've created issue #630 as a placeholder to discuss this.

I see that __prototype_encoding_store_into() is being tested for the case when the output parameter is present from pre-existing tests that applied to store_into(). I'm not seeing where the case of empty output parameter is being tested. Since this is very relevant to (or even exactly) the functionality being refactored, we can't have confidence -from testing at least- that the refactoring is correct. So I think before merging this child PR we should add more coverage to #624.

@barnjamin

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The refactoring of code is straightforward, which is against the old version of _index_tuple, by changing return item according to the existence of output: BaseType | None.

I added the testcases for tuple elements and array elements anyways, and will add some testcases for _GetAgainstEncoding, but I don't anticipate I have bandwidth for coverage adding in #624, and I hope @barnjamin can help on that one.

@ahangsu ahangsu force-pushed the generalized-encode-for-computed-type branch from 9f3e752 to 33c3e87 Compare January 3, 2023 23:54
Copy link
Contributor

@tzaffi tzaffi left a comment

Choose a reason for hiding this comment

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

I see now that the case of output=None for __prototype_encoding_store_into() is exercised, thank you!

@barnjamin barnjamin merged commit 105e307 into tuple-element-encode Jan 4, 2023
@barnjamin barnjamin deleted the generalized-encode-for-computed-type branch January 4, 2023 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants