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=}") pdre = PyTealDryRunExecutor(subr, mode) assert pdre.is_abi(), "should be an ABI subroutine" arg_types = pdre.abi_argument_types() if subr.name() != "fn_1tt_arg_uint64_ret": assert not arg_types or any( arg_types), "abi_argument_types() should have had some abi info" if abi_return_type: expected_sdk_return_type = pt.abi.algosdk_from_type_spec( abi_return_type.type_spec()) assert expected_sdk_return_type == pdre.abi_return_type() else: assert pdre.abi_return_type() is None compiled = pdre.compile(version=6) tealdir = GENERATED / "abi" tealdir.mkdir(parents=True, exist_ok=True) save_to = tealdir / (name + ".teal") with open(save_to, "w") as f: f.write(compiled) assert_teal_as_expected(save_to, FIXTURES / "abi" / (name + ".teal"))
def test_PyTealBlackboxExecutor_is_abi(mode: pt.Mode, fn: BlackboxWrapper, expected_is_abi: bool): p = PyTealDryRunExecutor(fn, mode) assert p.is_abi() == expected_is_abi if expected_is_abi: assert p.abi_argument_types() is not None assert p.abi_return_type() is not None else: assert p.abi_argument_types() is None assert p.abi_return_type() is None