Ejemplo n.º 1
0
async def test_consensus_match_sync_4(request, event_loop):
    '''
    Blockchain databases of client and server match up to a point within the consensus match stage, but there are additional
    blocks in the server's db after that time.
    :param request:
    :param event_loop:
    :return:
    '''

    genesis_time = int(time.time() / 1000) * 1000 - 1000 * 900
    equal_to_time = int(time.time() / 1000) * 1000 - 1000 * 890
    new_blocks_start_time = int(time.time() / 1000) * 1000 - 1000 * 25
    new_blocks_end_time = int(time.time() / 1000) * 1000 - 1000 * 3

    server_db = get_random_blockchain_to_time(genesis_time, equal_to_time)
    client_db = MemoryDB(kv_store=server_db.kv_store.copy())

    add_random_transactions_to_db_for_time_window(server_db, equal_to_time,
                                                  equal_to_time + 1000 * 5)

    add_random_transactions_to_db_for_time_window(server_db,
                                                  new_blocks_start_time,
                                                  new_blocks_end_time)

    client_node = MainnetChain(
        client_db, GENESIS_PRIVATE_KEY.public_key.to_canonical_address())
    client_node.chaindb.initialize_historical_minimum_gas_price_at_genesis(
        min_gas_price=1, net_tpc_cap=100, tpc=1)

    await _test_sync_with_variable_sync_parameters(
        request, event_loop, client_db, server_db,
        ensure_blockchain_databases_identical)
Ejemplo n.º 2
0
async def test_fast_sync_5(request, event_loop):
    '''
    Blockchain databases of client and server match up to a point before chronological block windows starts, but there are additional
    blocks in the server's db after that time.
    :param request:
    :param event_loop:
    :return:
    '''
    for i in range(5):
        genesis_time = int(time.time() / 1000) * 1000 - 1000 * 1100
        equal_to_time = int(time.time() / 1000) * 1000 - 1000 * 1095
        new_blocks_start_time = int(time.time() / 1000) * 1000 - 1000 * 25
        new_blocks_end_time = int(time.time() / 1000) * 1000 - 1000 * 3

        server_db = get_random_blockchain_to_time(genesis_time, equal_to_time)
        client_db = MemoryDB(kv_store=server_db.kv_store.copy())

        add_random_transactions_to_db_for_time_window(client_db, equal_to_time,
                                                      equal_to_time + 1000 * 5)

        add_random_transactions_to_db_for_time_window(client_db,
                                                      new_blocks_start_time,
                                                      new_blocks_end_time)

        client_node = TestnetChain(
            client_db,
            TESTNET_GENESIS_PRIVATE_KEY.public_key.to_canonical_address())
        client_node.min_gas_db.initialize_historical_minimum_gas_price_at_genesis(
            min_gas_price=1, net_tpc_cap=100)

        await _test_sync_with_variable_sync_parameters(
            request, event_loop, client_db, server_db,
            ensure_blockchain_databases_identical)
Ejemplo n.º 3
0
async def test_sparse_sync_2(request, event_loop):
    '''
    Blockchain databases of client and server match up to a point within the consensus match stage, but there are additional
    blocks in the server's db after that time.
    :param request:
    :param event_loop:
    :return:
    '''

    genesis_time = int(time.time() / 1000) * 1000 - 1000 * 900
    equal_to_time = int(time.time() / 1000) * 1000 - 1000 * 890

    server_db = get_random_blockchain_to_time(genesis_time, equal_to_time)
    client_db = MemoryDB(kv_store=server_db.kv_store.copy())

    add_random_transactions_to_db_for_time_window(server_db, equal_to_time,
                                                  equal_to_time + 1000 * 5)

    tx_list = [[
        TESTNET_GENESIS_PRIVATE_KEY, RECEIVER, 100,
        int(time.time() / 1000) * 1000 - 1000 * 800
    ],
               [
                   TESTNET_GENESIS_PRIVATE_KEY, RECEIVER, 100,
                   int(time.time() / 1000) * 1000 - 1000 * 700
               ],
               [
                   TESTNET_GENESIS_PRIVATE_KEY, RECEIVER, 100,
                   int(time.time() / 1000) * 1000 - 1000 * 100
               ],
               [
                   TESTNET_GENESIS_PRIVATE_KEY, RECEIVER, 100,
                   int(time.time() / 1000) * 1000 - 1000 * 5
               ],
               [
                   TESTNET_GENESIS_PRIVATE_KEY, RECEIVER, 100,
                   int(time.time() / 1000) * 1000 - 1000 * 1
               ]]

    add_transactions_to_blockchain_db(client_db, tx_list)

    client_node = TestnetChain(
        client_db,
        TESTNET_GENESIS_PRIVATE_KEY.public_key.to_canonical_address())
    client_node.min_gas_db.initialize_historical_minimum_gas_price_at_genesis(
        min_gas_price=1, net_tpc_cap=100)

    await _test_sync_with_variable_sync_parameters(
        request, event_loop, client_db, server_db,
        ensure_blockchain_databases_identical)
Ejemplo n.º 4
0
async def test_fast_sync_2(request, event_loop):
    genesis_time = int(time.time() / 1000) * 1000 - 1000 * 1100
    equal_to_time = int(time.time() / 1000) * 1000 - 1000 * 1095

    server_db = get_random_blockchain_to_time(genesis_time, equal_to_time)
    client_db = MemoryDB(kv_store=server_db.kv_store.copy())

    add_random_transactions_to_db_for_time_window(client_db, equal_to_time,
                                                  equal_to_time + 1000 * 5)

    node_2 = MainnetChain(
        client_db, GENESIS_PRIVATE_KEY.public_key.to_canonical_address())
    node_2.chaindb.initialize_historical_minimum_gas_price_at_genesis(
        min_gas_price=1, net_tpc_cap=100, tpc=1)

    await _test_sync_with_variable_sync_parameters(
        request, event_loop, client_db, server_db,
        ensure_blockchain_databases_identical, FAST_SYNC_STAGE_ID)
Ejemplo n.º 5
0
async def test_additive_sync_4(request, event_loop):
    '''
    Blockchain databases of client and server match up to a point within the consensus match stage, but there are additional
    blocks in the server's db after that time.
    :param request:
    :param event_loop:
    :return:
    '''

    genesis_time = int(time.time() / 1000) * 1000 - 1000 * 25
    equal_to_time = int(time.time() / 1000) * 1000 - 1000 * 2

    server_db = get_random_blockchain_to_time(genesis_time, equal_to_time)
    client_db = MemoryDB(kv_store=server_db.kv_store.copy())

    tx_list = [[GENESIS_PRIVATE_KEY, RECEIVER, 100,
                int(time.time() - 2000)],
               [GENESIS_PRIVATE_KEY, RECEIVER, 100,
                int(time.time() - 1500)],
               [GENESIS_PRIVATE_KEY, RECEIVER, 100,
                int(time.time() - 1000)]]

    add_transactions_to_blockchain_db(server_db, tx_list)

    client_node = MainnetChain(
        client_db, GENESIS_PRIVATE_KEY.public_key.to_canonical_address())
    client_node.chaindb.initialize_historical_minimum_gas_price_at_genesis(
        min_gas_price=1, net_tpc_cap=100, tpc=1)
    server_node = MainnetChain(
        server_db, GENESIS_PRIVATE_KEY.public_key.to_canonical_address())
    server_node.chaindb.initialize_historical_minimum_gas_price_at_genesis(
        min_gas_price=1, net_tpc_cap=100, tpc=1)

    await _test_sync_with_variable_sync_parameters(
        request, event_loop, client_db, server_db,
        ensure_blockchain_databases_identical)