def test_genesis_chain(db): k, v, k2, v2 = accounts() chain = Chain({v: {"balance": utils.denoms.ether * 1}}, difficulty=1) blk = mine_on_chain(chain) print('blook', blk) assert chain.has_block(blk.hash) assert blk.hash in chain assert chain.get_block(blk.hash) == blk assert chain.head == blk assert chain.get_children(blk) == [] assert chain.get_chain() == [blk] assert chain.get_block_by_number(1) assert not chain.get_block_by_number(2) assert chain.get_block_by_number(1) == blk
def test_simple_chain(db): k, v, k2, v2 = accounts() chain = Chain({v: {"balance": utils.denoms.ether * 1}}, difficulty=1) tx = get_transaction() blk2 = mine_next_block(chain, transactions=[tx]) blk3 = mine_next_block(chain) assert blk2.hash in chain assert blk3.hash in chain assert chain.has_block(blk2.hash) assert chain.has_block(blk3.hash) assert chain.get_block(blk2.hash) == blk2 assert chain.get_block(blk3.hash) == blk3 assert chain.head == blk3 assert chain.get_children(blk2) == [blk3] assert chain.get_chain() == [blk2, blk3] assert chain.get_block_by_number(1) == blk2 assert chain.get_block_by_number(2) == blk3 assert not chain.get_block_by_number(3) assert chain.get_tx_position(tx.hash) == (blk2.number, 0)