Beispiel #1
0
def test_TestNewBlock():
    txns = makeTestTransactions()
    err, block = skycoin.SKY_coin_NewEmptyBlock(txns)
    assert err == skycoin.SKY_OK
    err, pBlock = skycoin.SKY_coin_GetBlockObject(block)
    assert err == skycoin.SKY_OK
    pBlock.Head.Version = 0x02
    pBlock.Head.Time = 100
    pBlock.Head.BkSeq = 98
    uxHash = utils.RandSHA256()
    err, _ = skycoin.SKY_coin_NewBlock(block, 133, uxHash, txns,
                                       utils.badFeeCalculator)
    assert err == skycoin.SKY_ERROR
    err, txns1 = skycoin.SKY_coin_Create_Transactions()
    assert err == skycoin.SKY_OK
    err, _ = skycoin.SKY_coin_NewBlock(block, 133, uxHash, txns1,
                                       utils.feeCalc)
    assert err == skycoin.SKY_ERROR
    fee = int(121)
    currentTime = int(133)
    err, b = skycoin.SKY_coin_NewBlock(block, currentTime, uxHash, txns,
                                       utils.fix121FeeCalculator)
    assert err == skycoin.SKY_OK
    err, pBlock = skycoin.SKY_coin_GetBlockObject(b)
    assert err == skycoin.SKY_OK
Beispiel #2
0
def test_TestBlockHashHeader():
    uxHash = utils.RandSHA256()
    err, block = makeNewBlock(uxHash)
    assert err == skycoin.SKY_OK
    err, pBlock = skycoin.SKY_coin_GetBlockObject(block)
    assert err == skycoin.SKY_OK
    hash1 = skycoin.cipher_SHA256()
    hash2 = skycoin.cipher_SHA256()
    err = skycoin.SKY_coin_Block_HashHeader(block, hash1)
    assert err == skycoin.SKY_OK
    err = skycoin.SKY_coin_BlockHeader_Hash(pBlock.Head, hash2)
    assert err == skycoin.SKY_OK
    assert hash1.toStr() == hash2.toStr()
    hash2 = skycoin.cipher_SHA256()
    assert hash1 != hash2
Beispiel #3
0
def test_TestBlockHashBody():
    uxHash = utils.RandSHA256()
    err, block = makeNewBlock(uxHash)
    assert err == skycoin.SKY_OK
    err, pBlock = skycoin.SKY_coin_GetBlockObject(block)
    assert err == skycoin.SKY_OK

    hash1 = skycoin.cipher_SHA256()
    hash2 = skycoin.cipher_SHA256()
    err = skycoin.SKY_coin_Block_HashBody(block, hash1)
    assert err == skycoin.SKY_OK
    err, blockBody = skycoin.SKY_coin_GetBlockBody(block)
    assert err == skycoin.SKY_OK
    err = skycoin.SKY_coin_BlockBody_Hash(blockBody, hash2)
    assert err == skycoin.SKY_OK
    assert hash1 == hash2