Exemplo n.º 1
0
def test_AddressTypeSpec_eq():
    assert abi.AddressTypeSpec() == abi.AddressTypeSpec()

    for otherType in (
            abi.ByteTypeSpec(),
            abi.StaticArrayTypeSpec(abi.ByteTypeSpec(), 32),
            abi.DynamicArrayTypeSpec(abi.ByteTypeSpec()),
    ):
        assert abi.AddressTypeSpec() != otherType
Exemplo n.º 2
0
def test_AccountTypeSpec_eq():
    assert abi.AccountTypeSpec() == abi.AccountTypeSpec()

    for otherType in (
            abi.ByteTypeSpec(),
            abi.Uint8TypeSpec(),
            abi.AddressTypeSpec(),
    ):
        assert abi.AccountTypeSpec() != otherType
Exemplo n.º 3
0
def test_ApplicationTypeSpec_eq():
    assert abi.ApplicationTypeSpec() == abi.ApplicationTypeSpec()

    for otherType in (
            abi.ByteTypeSpec(),
            abi.Uint8TypeSpec(),
            abi.AddressTypeSpec(),
    ):
        assert abi.ApplicationTypeSpec() != otherType
Exemplo n.º 4
0
def test_TransactionTypeSpec_eq():
    for tv in TransactionValues:
        assert tv.ts == tv.ts

        for otherType in (
            abi.ByteTypeSpec(),
            abi.Uint8TypeSpec(),
            abi.AddressTypeSpec(),
        ):
            assert tv.ts != otherType
Exemplo n.º 5
0
def test_Address_set_computed():
    av = pt.Addr("MDDKJUCTY57KA2PBFI44CLTJ5YHY5YVS4SVQUPZAWSRV2ZAVFKI33O6YPE")
    computed_value = ContainerType(abi.AddressTypeSpec(), av)

    value = abi.Address()
    expr = value.set(computed_value)
    assert expr.type_of() == pt.TealType.none
    assert not expr.has_return()

    _, byte_ops = av.__teal__(options)
    expected = pt.TealSimpleBlock([
        byte_ops.ops[0],
        pt.TealOp(None, pt.Op.store, value.stored_value.slot),
    ])

    actual, _ = expr.__teal__(options)
    actual.addIncoming()
    actual = pt.TealBlock.NormalizeBlocks(actual)

    with pt.TealComponent.Context.ignoreExprEquality():
        assert actual == expected

    with pytest.raises(pt.TealInputError):
        value.set(ContainerType(abi.ByteTypeSpec(), pt.Int(0x01)))
Exemplo n.º 6
0
def test_AddressTypeSpec_new_instance():
    assert isinstance(abi.AddressTypeSpec().new_instance(), abi.Address)
Exemplo n.º 7
0
def test_AddressTypeSpec_length_static():
    assert (abi.AddressTypeSpec()).length_static() == abi.AddressLength.Bytes
Exemplo n.º 8
0
def test_AddressTypeSpec_is_dynamic():
    assert (abi.AddressTypeSpec()).is_dynamic() is False
Exemplo n.º 9
0
def test_AddressTypeSpec_str():
    assert str(abi.AddressTypeSpec()) == "address"