Пример #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)
Пример #2
0
def test_if_first_pendingblock_is_just_created_then_mining_should_be_started_once():
    node = NodeComponent(miner=True)
    node.create_genesis_chain()
    patcher = patch('dokuztas.node.NodeComponent.mine')
    mock = patcher.start()
    for x in range(0, 200):
        node.add_transaction(x)
    patcher.stop()
    mock.assert_called_once()
Пример #3
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)
Пример #4
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