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 ability to assert identical functionality for teal programs/methods #36

Merged
merged 12 commits into from
Dec 7, 2022

Conversation

tzaffi
Copy link
Contributor

@tzaffi tzaffi commented Nov 12, 2022

Test one teal program against another, with the optionality of using ABI

New functionality

The best place to see the new capabilities is in identical_test.py

  • Add a new method Invariant.full_validation() that accepts the standard inspectors parameter of dry run execution results, but also the new parameter identities which is a sequence of inspectors used to assert equivalence with inspectors
  • Also allow the pre-existing method Invariant.validates() to accept the identities parameter
  • Add a new class PredicateKind to better signal which kind of predicate is being supplied to an Invariant
    • The value PredicateKind.IdenticalPair acts as a sentinel for asserting that two dry-run execution scenarios are identical

Testing

C.I.

Also, C.I. in PyTeal PR #605 provides additional coverage.

@tzaffi tzaffi marked this pull request as draft November 12, 2022 18:45
@tzaffi tzaffi marked this pull request as ready for review November 14, 2022 15:38
@tzaffi tzaffi requested a review from ahangsu November 14, 2022 15:38
Copy link
Contributor

@ahangsu ahangsu left a comment

Choose a reason for hiding this comment

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

having some questions about the type arrangement, mostly around INVARIANT_TYPE and PredicateKind.

I am inclined to approve once these questions are resolved.

Comment on lines 46 to 52
N = len(sig.parameters)
assert N in (1, 2), f"predicate has the wrong number of paramters {N}"

if N == 2:
return PredicateKind.RangeMatch

return PredicateKind.ExactMatch
Copy link
Contributor

Choose a reason for hiding this comment

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

Another dumb question: the callable object seems to be having only 1 or 2 argument, could you pin point me any examples of INVARIANT_TYPE falling into the 2 categories?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. cost lambda with a single confusingly named args argument
  2. final scratch lambda with first parameter args and second parameter actual

on_complete: OnComplete = OnComplete.NoOpOC,
dryrun_accounts: List[DryRunAccountType] = [],
) -> Tuple[Sequence["DryRunInspector"], Sequence["DryRunInspector"]]:
return tuple( # type: ignore
Copy link
Contributor Author

Choose a reason for hiding this comment

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

to the best of my current understand, to fix this type-hints issue would require an upgrade to python 3.11

Co-authored-by: Michael Diamant <michaeldiamant@users.noreply.github.com>
Copy link
Contributor

@michaeldiamant michaeldiamant left a comment

Choose a reason for hiding this comment

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

@tzaffi Thanks for taking in my feedback here!

@tzaffi tzaffi merged commit d84fc61 into main Dec 7, 2022
@tzaffi tzaffi deleted the identical-functions branch December 7, 2022 16:52
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