Skip to content

Add ability to assert identical functionality for teal programs/methods#36

Merged
tzaffi merged 12 commits intomainfrom
identical-functions
Dec 7, 2022
Merged

Add ability to assert identical functionality for teal programs/methods#36
tzaffi merged 12 commits intomainfrom
identical-functions

Conversation

@tzaffi
Copy link
Copy Markdown
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
Copy Markdown
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 thread graviton/models.py
Comment thread graviton/invariant.py Outdated
Comment thread graviton/invariant.py
Comment thread graviton/invariant.py Outdated
Comment thread graviton/invariant.py
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
Copy Markdown
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
Copy Markdown
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

Comment thread tests/integration/identical_test.py
Comment thread graviton/invariant.py Outdated
Comment thread graviton/blackbox.py
on_complete: OnComplete = OnComplete.NoOpOC,
dryrun_accounts: List[DryRunAccountType] = [],
) -> Tuple[Sequence["DryRunInspector"], Sequence["DryRunInspector"]]:
return tuple( # type: ignore
Copy link
Copy Markdown
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

Comment thread graviton/blackbox.py Outdated
Co-authored-by: Michael Diamant <michaeldiamant@users.noreply.github.com>
Comment thread graviton/blackbox.py
Copy link
Copy Markdown
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