Esempio n. 1
0
async def test_eth_api_send_get_block_headers(alice, bob):
    payload = BlockHeadersQueryFactory()

    command_fut = asyncio.Future()

    async def _handle_cmd(connection, cmd):
        command_fut.set_result(cmd)

    bob.connection.add_command_handler(GetBlockHeadersV65, _handle_cmd)
    alice.eth_api.send_get_block_headers(
        block_number_or_hash=payload.block_number_or_hash,
        max_headers=payload.block_number_or_hash,
        skip=payload.skip,
        reverse=payload.reverse,
    )

    result = await asyncio.wait_for(command_fut, timeout=1)
    assert isinstance(result, GetBlockHeadersV65)
    assert_type_equality(payload, result.payload)
Esempio n. 2
0
from trinity.tools.factories.eth import (
    NewBlockHashFactory,
    NewBlockPayloadFactory,
    StatusPayloadFactory,
    StatusV63PayloadFactory,
)


@pytest.mark.parametrize(
    'command_type,payload',
    (
        (StatusV63, StatusV63PayloadFactory()),
        (Status, StatusPayloadFactory()),
        (NewBlockHashes, tuple(NewBlockHashFactory.create_batch(2))),
        (Transactions, tuple(SerializedTransactionFactory.create_batch(2))),
        (GetBlockHeadersV65, BlockHeadersQueryFactory()),
        (GetBlockHeadersV65,
         BlockHeadersQueryFactory(block_number_or_hash=BlockHashFactory())),
        (BlockHeadersV65, tuple(BlockHeaderFactory.create_batch(2))),
        (GetBlockBodiesV65, tuple(BlockHashFactory.create_batch(2))),
        (BlockBodiesV65, tuple(BlockBodyFactory.create_batch(2))),
        (NewBlock, NewBlockPayloadFactory()),
        (GetNodeDataV65, tuple(BlockHashFactory.create_batch(2))),
        (NodeDataV65, (secrets.token_bytes(10), secrets.token_bytes(100))),
        (GetReceiptsV65, tuple(BlockHashFactory.create_batch(2))),
        (ReceiptsV65, (tuple(ReceiptFactory.create_batch(2)),
                       tuple(ReceiptFactory.create_batch(3)))),
    ),
)
@pytest.mark.parametrize(
    'snappy_support',