Beispiel #1
0
 def func_wrapper():
     from dokuztas.blockchain import Blockchain
     node = NodeComponent()
     node.chain = Blockchain(difficulty=difficulty)
     node.miner = True
     node.create_genesis_chain()
     for x in range(0, txs_count):
         node.add_transaction(str(x))
     func(node)
Beispiel #2
0
 def func_wrapper():
     patcher = patch('dokuztas.node.NodeComponent.mine')
     patcher.start()
     node = NodeComponent()
     node.miner = True
     node.create_genesis_chain()
     for x in range(0, txs_count):
         node.add_transaction(str(x))
     patcher.stop()
     func(node)
Beispiel #3
0
def test_after_first_block_is_mined_then_pending_txs_should_be_mined():
    from dokuztas.blockchain import Blockchain
    node = NodeComponent()
    node.miner = True
    node.chain = Blockchain(difficulty=1)
    node.chain._generate_genesis()

    def sync_mine(**kwargs):
        node.chain.mine(kwargs['args'][0], kwargs['args'][1],
                        kwargs['args'][2])

    thread_patcher = patch('dokuztas.node.NodeComponent._internal_mine',
                           side_effect=sync_mine)
    thread_patcher.start()
    for x in range(0, 22):
        node.add_transaction(str(x))
    thread_patcher.stop()
    assert len(node.chain.blocks) == 3