def test_TestCreateUnspent(): err, pubkey, seckey, address = utils.makeKeysAndAddress() assert err == skycoin.SKY_OK hash1 = skycoin.cipher_SHA256() handle = utils.makeEmptyTransaction() err = skycoin.SKY_coin_Transaction_PushOutput(handle, address, 11000000, 255) assert err == skycoin.SKY_OK bh = skycoin.coin__BlockHeader() bh.Time = 0 bh.BkSeq = 1 t = [] tc1 = testcase() t.append(tc1) tc2 = testcase() tc2.index = 10 tc2.failure = skycoin.SKY_ERROR t.append(tc2) ux = skycoin.coin__UxOut() tests_count = len(t) for i in range(tests_count): err = skycoin.SKY_coin_CreateUnspent(bh, handle, t[i].index, ux) if t[i].failure == skycoin.SKY_ERROR: pass assert bh.Time == ux.Head.Time assert bh.BkSeq == ux.Head.BkSeq
def test_TestCreateUnspents(): err, pubkey, seckey, address = utils.makeKeysAndAddress() assert err == skycoin.SKY_OK hash1 = skycoin.cipher_SHA256() txn = utils.makeEmptyTransaction() err = skycoin.SKY_coin_Transaction_PushOutput(txn, address, int(11e6), int(255)) assert err == skycoin.SKY_OK bh = skycoin.coin__BlockHeader() bh.Time = 0 bh.BkSeq = 1 err, uxouts = skycoin.SKY_coin_CreateUnspents(bh, txn) assert err == skycoin.SKY_OK assert err == skycoin.SKY_OK assert len(uxouts) == 1
def test_TestNewGenesisBlock(): pubkey = skycoin.cipher_PubKey() seckey = skycoin.cipher_SecKey() genTime = 1000 genCoins = int(1000 * 1000 * 1000) genCoinHours = int(1000 * 1000) err, pubkey, seckey, address = utils.makeKeysAndAddress() assert err == skycoin.SKY_OK err, block = skycoin.SKY_coin_NewGenesisBlock(address, genCoins, genTime) assert err == skycoin.SKY_OK err, pBlock = skycoin.SKY_coin_GetBlockObject(block) assert err == skycoin.SKY_OK nullHash = skycoin.cipher_SHA256() err, pHead = skycoin.SKY_coin_BlockHeader_Bytes(pBlock.Head) assert err == skycoin.SKY_OK assert nullHash.compareToString(str(pHead)) assert genTime == pBlock.Head.Time assert 0 == pBlock.Head.BkSeq assert 0 == pBlock.Head.Version assert 0 == pBlock.Head.Fee