def test_get_transactions_of_address_limit(self):
        """Test validity of transactions of an address. Limit returned amount."""
        db = rocksdb.DB(DB_PATH,
                        rocksdb.Options(create_if_missing=True,
                                        max_open_files=10000),
                        read_only=True)
        with open('tests/resources/address_transactions_filter_limit.txt',
                  'r') as f:
            compare_data = json.loads(f.read())

        address = '0x004b7f28a01a9f9142b2fc818b22325c4c049166'
        gatherer = DatabaseGatherer(db)
        gathered_data = gatherer.get_transactions_of_address(
            address, 0, 99999999999, 0, 9999999999999999999999999999, 5)

        self.assertEqual(compare_data, gathered_data)
def get_transactions_by_address(address: str,
                                time_from: str = '0',
                                time_to: str = '',
                                val_from: str = '0',
                                val_to: str = '',
                                no_tx_list: str = '',
                                db: Any = None) -> None:
    """
    Get transactions of an address.

    Args:
        address: Ethereum address.
        time_from: Beginning datetime to take transactions from.
        time_to: Ending datetime to take transactions from.
        val_from: Minimum transferred currency of the transactions.
        val_to: Maximum transferred currency of transactions.
        no_tx_list: Maximum transactions to gather.
        db: Read-only database instance.
    """
    try:
        int_time_from = int(time_from)
    except ValueError:
        return 'Start time {} couldn\'t be parsed.'.format(time_from), 400

    if time_to == '':
        time_to = str(int(time.time()) + 1000000)
    try:
        int_time_to = int(time_to)
    except ValueError:
        return 'End time {} couldn\'t be parsed.'.format(time_to), 400

    try:
        int_val_from = int(val_from)
    except ValueError:
        return 'Minimum value {} couldn\'t be parsed.'.format(val_from), 400

    if val_to == '':
        val_to = str(1000000000000000000000000000000)
    try:
        int_val_to = int(val_to)
    except ValueError:
        return 'Maximum value {} couldn\'t be parsed.'.format(val_to), 400

    if int_time_from > int_time_to:
        return 'Minimum time is larger than maximum time', 400
    if int_val_from > int_val_to:
        return 'Minimum value is larger than maximum value', 400

    if no_tx_list == '':
        no_tx_list = str(1000000000000000000000000000000)
    try:
        int_no_tx_list = int(no_tx_list)
    except ValueError:
        return 'Maximum number of transactions {} couldn\'t be parsed.'.format(no_tx_list), 400

    gatherer = DatabaseGatherer(db)
    transactions = gatherer.get_transactions_of_address(address.lower(), int_time_from,
                                                        int_time_to, int_val_from, int_val_to,
                                                        int_no_tx_list)
    if transactions is None:
        return 'No transactions of address {} found'.format(address), 404

    return transactions