예제 #1
0
def test_stream(tmpdir, start_block, end_block, batch_size, resource_group,
                provider_type, chain):
    try:
        os.remove('last_synced_block.txt')
    except OSError:
        pass

    blocks_output_file = str(tmpdir.join('actual_block.json'))
    transactions_output_file = str(tmpdir.join("actual_transactions.json"))

    stream(eos_rpc=ThreadLocalProxy(lambda: get_eos_rpc(
        provider_type,
        read_resource_lambda=lambda file: read_resource(resource_group, file),
        chain=chain)),
           start_block=start_block,
           end_block=end_block,
           batch_size=batch_size,
           item_exporter=blocks_and_transactions_item_exporter(
               blocks_output_file, transactions_output_file))

    print('=====================')
    print(read_file(blocks_output_file))
    compare_lines_ignore_order(
        read_resource(resource_group, 'expected_blocks.json'),
        read_file(blocks_output_file))

    print('=====================')
    print(read_file(transactions_output_file))
    compare_lines_ignore_order(
        read_resource(resource_group, 'expected_transactions.json'),
        read_file(transactions_output_file))
예제 #2
0
def test_export_blocks_job(tmpdir, start_block, end_block, batch_size,
                           resource_group, provider_type):
    blocks_output_file = str(tmpdir.join('actual_block.json'))
    transactions_output_file = str(tmpdir.join("actual_transactions.json"))
    actions_output_file = str(tmpdir.join("actual_actions.json"))

    job = ExportBlocksJob(
        start_block=start_block,
        end_block=end_block,
        batch_size=batch_size,
        eos_rpc=ThreadLocalProxy(
            lambda: get_eos_rpc(provider_type,
                                read_resource_lambda=lambda file:
                                read_resource(resource_group, file))),
        max_workers=5,
        item_exporter=blocks_item_exporter(blocks_output_file,
                                           transactions_output_file,
                                           actions_output_file),
        export_blocks=blocks_output_file is not None,
        export_transactions=transactions_output_file is not None,
        export_actions=actions_output_file is not None)
    job.run()

    print('=====================')
    print(read_file(blocks_output_file))
    compare_lines_ignore_order(
        read_resource(resource_group, 'expected_blocks.json'),
        read_file(blocks_output_file))

    print('=====================')
    print(read_file(transactions_output_file))
    compare_lines_ignore_order(
        read_resource(resource_group, 'expected_transactions.json'),
        read_file(transactions_output_file))

    print('=====================')
    print(read_file(actions_output_file))
    compare_lines_ignore_order(
        read_resource(resource_group, 'expected_actions.json'),
        read_file(actions_output_file))
def get_new_btc_block_range_service(chain):
    rpc = get_eos_rpc("online", chain=chain)
    return BtcBlockRangeService(rpc)
예제 #4
0
def get_new_eos_block_range_service():
    rpc = get_eos_rpc("online")
    return EosBlockRangeService(rpc)