Ejemplo n.º 1
0
def test_construct_pow_evidence_genesis_block():
    coinstate = CoinState.empty()

    transactions = [
        construct_coinbase_transaction(0, [], immutables.Map(), b"Political statement goes here", example_public_key),
    ]

    summary = construct_minable_summary_genesis(transactions, 1231006505, 0)

    evidence = construct_pow_evidence(coinstate, summary, 0, transactions)
    evidence.serialize()
Ejemplo n.º 2
0
def test_construct_pow_evidence_non_genesis_block():
    coinstate = _read_chain_from_disk(5)

    transactions = [
        construct_coinbase_transaction(0, [], immutables.Map(),
                                       b"Political statement goes here",
                                       example_public_key),
    ]

    summary = construct_minable_summary(coinstate, transactions, 1231006505, 0)

    evidence = construct_pow_evidence(coinstate, summary,
                                      coinstate.head().height + 1,
                                      transactions)
    evidence.serialize()
Ejemplo n.º 3
0
def test_validate_block_by_itself_invalid_coinbase_transaction():
    coinstate = CoinState.empty()

    transactions = [
        Transaction(inputs=[
            Input(
                OutputReference(b'x' * 32, 1),
                SECP256k1Signature(b'y' * 64),
            )
        ],
                    outputs=[Output(1, example_public_key)])
    ]

    summary = construct_minable_summary(coinstate, transactions, 1615209942,
                                        39)
    evidence = construct_pow_evidence(coinstate, summary, 0, transactions)
    block = Block(BlockHeader(summary, evidence), transactions)

    with pytest.raises(ValidateTransactionError, match=".*thin air.*"):
        validate_block_by_itself(block, 1615209942)