예제 #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
예제 #2
0
def makeNewBlock(uxHash):
    bodyhash = skycoin.cipher_SHA256()
    transactions = makeTestTransactions()
    err, block = skycoin.SKY_coin_NewEmptyBlock(transactions)
    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 = 0
    pBlock.Head.Fee = 10
    err, body = skycoin.SKY_coin_GetBlockBody(block)
    assert err == skycoin.SKY_OK
    err = skycoin.SKY_coin_BlockBody_Hash(body, bodyhash)
    assert err == skycoin.SKY_OK
    return skycoin.SKY_coin_NewBlock(block, int(100 + 200), uxHash,
                                     transactions, utils.feeCalc)
예제 #3
0
def makeNewBlock(uxHash):
    transactions = makeTestTransactions()
    err, block = skycoin.SKY_coin_NewEmptyBlock(transactions)
    assert err == skycoin.SKY_OK
    err, pBlockHeader = skycoin.SKY_coin_Block_GetBlockHeader(block)
    assert err == skycoin.SKY_OK
    err = skycoin.SKY_coin_BlockHeader_SetTime(pBlockHeader, 100)
    assert err == skycoin.SKY_OK
    err = skycoin.SKY_coin_BlockHeader_SetBkSeq(pBlockHeader, 0)
    assert err == skycoin.SKY_OK
    err = skycoin.SKY_coin_BlockHeader_SetVersion(pBlockHeader, 0x02)
    assert err == skycoin.SKY_OK
    err = skycoin.SKY_coin_BlockHeader_SetFee(pBlockHeader, 10)
    assert err == skycoin.SKY_OK
    err, body = skycoin.SKY_coin_GetBlockBody(block)
    assert err == skycoin.SKY_OK
    return skycoin.SKY_coin_NewBlock(block, int(100 + 200), uxHash,
                                     transactions, utils.feeCalc)