Пример #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]
Пример #2
0
def test_TestAddressUxOutsFlatten():
    uxa = utils.makeUxArray(3)
    empty = utils.makeUxArray(0)
    err, uxH = skycoin.SKY_coin_NewAddressUxOuts(empty)
    assert err == skycoin.SKY_OK
    uxa[2].Body.Address = uxa[1].Body.Address
    emptyAddr = skycoin.cipher__Address()
    err = skycoin.SKY_coin_AddressUxOuts_Set(uxH, emptyAddr, empty)
    assert err == skycoin.SKY_OK
    ux_1 = [uxa[0]]
    err = skycoin.SKY_coin_AddressUxOuts_Set(uxH, uxa[0].Body.Address, ux_1)
    assert err == skycoin.SKY_OK
    ux_2 = uxa[1:]
    err = skycoin.SKY_coin_AddressUxOuts_Set(uxH, uxa[1].Body.Address, ux_2)
    assert err == skycoin.SKY_OK
    err, flatArray = skycoin.SKY_coin_AddressUxOuts_Flatten(uxH)
    assert err == skycoin.SKY_OK
    assert len(flatArray) == 3
    for x in flatArray:
        assert x.Body.Address != emptyAddr

    if flatArray[0].Body.Address == uxa[0].Body.Address:
        assert flatArray[0] == uxa[0]
        assert flatArray[0].Body.Address == uxa[0].Body.Address
        assert flatArray[1] == uxa[1]
        assert flatArray[1].Body.Address == uxa[1].Body.Address
        assert flatArray[2] == uxa[2]
        assert flatArray[2].Body.Address == uxa[2].Body.Address
    else:
        assert flatArray[0] == uxa[1]
        assert flatArray[0].Body.Address == uxa[1].Body.Address
        assert flatArray[1] == uxa[2]
        assert flatArray[1].Body.Address == uxa[2].Body.Address
        assert flatArray[2] == uxa[0]
        assert flatArray[2].Body.Address == uxa[0].Body.Address
Пример #3
0
def test_TestAddressUxOutsKeys():
    uxa = utils.makeUxArray(3)
    err, uxH = skycoin.SKY_coin_NewAddressUxOuts(uxa)
    assert err == skycoin.SKY_OK
    # keys = []
    err, keys = skycoin.SKY_coin_AddressUxOuts_Keys(uxH)
    assert err == skycoin.SKY_OK
    assert len(keys) == 3
    for k in keys:
        assert k == uxa[0].Body.Address or k == uxa[
            1].Body.Address or k == uxa[2].Body.Address
Пример #4
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