Ejemplo n.º 1
0
def test_TestNewAddressUxOuts():
    uxa = utils.makeUxArray(6)
    uxa[1].Body.Address = uxa[0].Body.Address
    uxa[3].Body.Address = uxa[2].Body.Address
    uxa[4].Body.Address = uxa[2].Body.Address
    err, uxH = skycoin.SKY_coin_NewAddressUxOuts(uxa)
    assert err == skycoin.SKY_OK
    # length
    err, length = skycoin.SKY_coin_AddressUxOuts_Length(uxH)
    assert err == skycoin.SKY_OK
    assert length == 3
    err, ux_2 = skycoin.SKY_coin_AddressUxOuts_Get(uxH, uxa[0].Body.Address)
    assert err == skycoin.SKY_OK
    assert len(ux_2) == 2
    assert ux_2[0] == uxa[0]
    assert ux_2[1] == uxa[1]
    err, ux_2 = skycoin.SKY_coin_AddressUxOuts_Get(uxH, uxa[3].Body.Address)
    assert err == skycoin.SKY_OK
    assert len(ux_2) == 3
    assert ux_2[0] == uxa[2]
    assert ux_2[1] == uxa[3]
    assert ux_2[2] == uxa[4]
    err, ux_2 = skycoin.SKY_coin_AddressUxOuts_Get(uxH, uxa[5].Body.Address)
    assert err == skycoin.SKY_OK
    assert len(ux_2) == 1
    assert ux_2[0] == uxa[5]
Ejemplo n.º 2
0
def test_TestAddressUxOutsAdd():
    uxa = utils.makeUxArray(4)
    empty = utils.makeUxArray(0)
    err, uxH_1 = skycoin.SKY_coin_NewAddressUxOuts(empty)
    assert err == skycoin.SKY_OK
    err, uxH_2 = skycoin.SKY_coin_NewAddressUxOuts(empty)
    assert err == skycoin.SKY_OK
    uxa[1].Body.Address = uxa[0].Body.Address
    ux_2 = [uxa[0]]
    err = skycoin.SKY_coin_AddressUxOuts_Set(uxH_1, uxa[0].Body.Address, ux_2)
    assert err == skycoin.SKY_OK
    ux_3 = [uxa[2]]
    err = skycoin.SKY_coin_AddressUxOuts_Set(uxH_1, uxa[2].Body.Address, ux_3)
    assert err == skycoin.SKY_OK
    ux_4 = [uxa[3]]
    err = skycoin.SKY_coin_AddressUxOuts_Set(uxH_1, uxa[3].Body.Address, ux_4)
    assert err == skycoin.SKY_OK
    ux_5 = [uxa[0]]
    err = skycoin.SKY_coin_AddressUxOuts_Set(uxH_2, uxa[0].Body.Address, ux_5)
    assert err == skycoin.SKY_OK
    ux_6 = [uxa[2]]
    err = skycoin.SKY_coin_AddressUxOuts_Set(uxH_2, uxa[2].Body.Address, ux_6)
    assert err == skycoin.SKY_OK
    err, uxH_3 = skycoin.SKY_coin_AddressUxOuts_Add(uxH_1, uxH_2)
    assert err == skycoin.SKY_OK
    # length
    err, length = skycoin.SKY_coin_AddressUxOuts_Length(uxH_3)
    assert err == skycoin.SKY_OK
    assert length == 3
    err, length = skycoin.SKY_coin_AddressUxOuts_GetOutputLength(
        uxH_3, uxa[0].Body.Address)
    assert err == skycoin.SKY_OK
    # assert length == 2
    err, ux_2 = skycoin.SKY_coin_AddressUxOuts_Get(uxH_3, uxa[0].Body.Address)
    assert err == skycoin.SKY_OK
    # assert len(ux_2) == 2
    assert ux_2[0] == uxa[0]
    # assert ux_2[1] == uxa[1]
    err, ux_2 = skycoin.SKY_coin_AddressUxOuts_Get(uxH_3, uxa[2].Body.Address)
    assert err == skycoin.SKY_OK
    assert len(ux_2) == 1
    assert ux_2[0] == uxa[2]
    err, ux_2 = skycoin.SKY_coin_AddressUxOuts_Get(uxH_3, uxa[3].Body.Address)
    assert err == skycoin.SKY_OK
    assert len(ux_2) == 1
    assert ux_2[0] == uxa[3]
    err, ux_2 = skycoin.SKY_coin_AddressUxOuts_Get(uxH_3, uxa[1].Body.Address)
    assert err == skycoin.SKY_OK
    # assert len(ux_2) == 2
    assert ux_2[0] == uxa[0]
    # assert ux_2[1] == uxa[1]
    # Originals should be unmodified
    err, length = skycoin.SKY_coin_AddressUxOuts_Length(uxH_1)
    assert err == skycoin.SKY_OK
    assert length == 3
    err, length = skycoin.SKY_coin_AddressUxOuts_GetOutputLength(
        uxH_1, uxa[0].Body.Address)
    assert err == skycoin.SKY_OK
    assert length == 1
    err, length = skycoin.SKY_coin_AddressUxOuts_GetOutputLength(
        uxH_1, uxa[2].Body.Address)
    assert err == skycoin.SKY_OK
    assert length == 1
    err, length = skycoin.SKY_coin_AddressUxOuts_GetOutputLength(
        uxH_1, uxa[3].Body.Address)
    assert err == skycoin.SKY_OK
    assert length == 1
    err, length = skycoin.SKY_coin_AddressUxOuts_Length(uxH_2)
    assert err == skycoin.SKY_OK
    assert length == 2
    err, length = skycoin.SKY_coin_AddressUxOuts_GetOutputLength(
        uxH_2, uxa[0].Body.Address)
    assert err == skycoin.SKY_OK
    assert length == 1
    err, length = skycoin.SKY_coin_AddressUxOuts_GetOutputLength(
        uxH_2, uxa[2].Body.Address)
    assert err == skycoin.SKY_OK
    assert length == 1