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

Optional refactorings to #322 #346

Merged
merged 3 commits into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions tests/unit/blackbox_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from itertools import product
from pathlib import Path
import pytest
from typing import Literal
from typing import Literal, Optional, Tuple

import pyteal as pt

Expand Down Expand Up @@ -151,7 +151,7 @@ def fn_2mixed_arg_1ret(


@pytest.mark.parametrize("subr, mode", product(UNITS, pt.Mode))
def test_blackbox_pyteal(subr, mode):
def test_blackbox_pyteal(subr: BlackboxWrapper, mode: pt.Mode):
is_app = mode == pt.Mode.Application
name = f"{'app' if is_app else 'lsig'}_{subr.name()}"

Expand All @@ -166,7 +166,9 @@ def test_blackbox_pyteal(subr, mode):


@pytest.mark.parametrize("subr_abi, mode", product(ABI_UNITS, pt.Mode))
def test_abi_blackbox_pyteal(subr_abi, mode):
def test_abi_blackbox_pyteal(
subr_abi: Tuple[BlackboxWrapper, Optional[pt.ast.abi.BaseType]], mode: pt.Mode
):
subr, abi_return_type = subr_abi
name = f"{'app' if mode == pt.Mode.Application else 'lsig'}_{subr.name()}"
print(f"Case {subr.name()=}, {abi_return_type=}, {mode=} ------> {name=}")
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/user_guide_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,17 @@ def user_guide_snippet_ABIReturnSubroutine():

# --- BEGIN doc-comment --- #
@ABIReturnSubroutine
def abi_sum(toSum: abi.DynamicArray[abi.Uint64], *, output: abi.Uint64) -> Expr:
def abi_sum(to_sum: abi.DynamicArray[abi.Uint64], *, output: abi.Uint64) -> Expr:
i = ScratchVar(TealType.uint64)
valueAtIndex = abi.Uint64()
value_at_index = abi.Uint64()
return Seq(
output.set(0),
For(
i.store(Int(0)), i.load() < toSum.length(), i.store(i.load() + Int(1))
i.store(Int(0)), i.load() < to_sum.length(), i.store(i.load() + Int(1))
).Do(
Seq(
toSum[i.load()].store_into(valueAtIndex),
output.set(output.get() + valueAtIndex.get()),
to_sum[i.load()].store_into(value_at_index),
output.set(output.get() + value_at_index.get()),
)
),
)
Expand Down