Exemplo n.º 1
0
def test_chain_builder_without_any_mining_config():
    chain = build(
        MiningChain,
        frontier_at(0),
        genesis(),
    )
    with pytest.raises(ValidationError, match='mix hash mismatch'):
        chain.mine_block()
Exemplo n.º 2
0
def test_chain_builder_enable_pow_mining():
    chain = build(
        MiningChain,
        frontier_at(0),
        enable_pow_mining(),
        genesis(),
    )
    block = chain.mine_block()
    check_eccpow(block.header.parent_hash, block.header.mining_hash, 24, 3, 6)
def mining_chain_params(funded_address):
    return (
        MiningChain,
        frontier_at(0),
        disable_pow_check,
        genesis(params={'gas_limit': 1000000},
                state={funded_address: {
                    'balance': to_wei(1000, 'ether')
                }}),
    )
Exemplo n.º 4
0
def test_chain_builder_enable_pow_mining():
    chain = build(
        MiningChain,
        frontier_at(0),
        enable_pow_mining(),
        genesis(),
    )
    block = chain.mine_block()
    check_pow(
        block.number,
        block.header.mining_hash,
        block.header.mix_hash,
        block.header.nonce,
        block.header.difficulty,
    )
Exemplo n.º 5
0
def test_chain_builder_disable_pow_check():
    chain = build(
        MiningChain,
        frontier_at(0),
        disable_pow_check(),
        genesis(),
    )
    block = chain.mine_block()
    with pytest.raises(ValidationError, match='mix hash mismatch'):
        check_pow(
            block.number,
            block.header.mining_hash,
            block.header.mix_hash,
            block.header.nonce,
            block.header.difficulty,
        )
Exemplo n.º 6
0
def test_chain_builder_disable_pow_check():
    chain = build(
        MiningChain,
        frontier_at(0),
        disable_pow_check(),
        genesis(),
    )
    block = chain.mine_block()
    # check_eccpow(
    #     block.header.parent_hash,
    #     block.header.mining_hash,
    #     24, 3, 6)
    with pytest.raises(ValidationError, match='mix hash mismatch'):
        # ToDo: Have to change difficulty
        check_eccpow(block.header.parent_hash, block.header.mining_hash, 24, 3,
                     6)
Exemplo n.º 7
0
def chain_class():
    return frontier_at(0)(Chain)
        disable_pow_check,
        genesis(params={'gas_limit': 1000000},
                state={funded_address: {
                    'balance': to_wei(1000, 'ether')
                }}),
    )


@pytest.fixture
def mining_chain(mining_chain_params):
    return build(*mining_chain_params)


REGULAR_CHAIN_PARAMS = (
    Chain,
    frontier_at(0),
    genesis(),
)


@pytest.fixture
def regular_chain():
    return build(*REGULAR_CHAIN_PARAMS)


def test_chain_builder_build_single_default_block(mining_chain):
    chain = build(
        mining_chain,
        mine_block(),
    )