internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: rotki/rotki

Issue:
IOTA historical price queries don't work
## Problem Definition

Discovered this from testing with fake data generated thanks to the data faker.

Historical price queries for the `IOTA` token don't work. That's because it's known in cryptocompare as `IOT` and not `IOTA`.

## Task

- [ ] Make sure that `IOTA` is translated to `IOT` when dealing with cryptocompare
- [ ] Add a test for it

## Future note

According to [coinmarketcap](https://coinmarketcap.com/currencies/iota/#markets) in some exchanges it's know as `MIOTA` so when they are added to rotkehlchen more conversion work may be needed.


Discussion:

Resolving patch:
diff --git a/rotkehlchen/history.py b/rotkehlchen/history.py
--- a/rotkehlchen/history.py
+++ b/rotkehlchen/history.py
@@ -252,6 +252,9 @@ def __init__(self, data_directory, history_date_start, inquirer):
         # it's not in the coinlist so let's add them here.
         self.cryptocompare_coin_list['DAO'] = object()
         self.cryptocompare_coin_list['USDT'] = object()
+        # IOTA is known to cryptocompare as IOT, but add IOTA too since
+        # we have conversion code to handle it and we accept queries with it
+        self.cryptocompare_coin_list['IOTA'] = object()
 
     def got_cached_price(self, cache_key, timestamp):
         """Check if we got a price history for the timestamp cached"""


Test patch:
diff --git a/rotkehlchen/tests/test_price_history.py b/rotkehlchen/tests/test_price_history.py
--- a/rotkehlchen/tests/test_price_history.py
+++ b/rotkehlchen/tests/test_price_history.py
@@ -54,3 +54,16 @@ def test_price_queries(price_historian):
     #        include them in the tests
     do_queries_for('BTC', 'EUR', price_historian)
     do_queries_for('ETH', 'EUR', price_historian)
+
+
+@pytest.mark.parametrize('should_mock_price_queries', [False])
+def test_cryptocompare_iota_query(price_historian):
+    """
+    Test that IOTA can be properly queried from cryptocompare
+
+    Issue: https://github.com/rotkehlchenio/rotkehlchen/issues/299
+    """
+    usd_price = price_historian.query_historical_price('IOTA', 'USD', 1511793374)
+    assert usd_price.is_close(FVal('0.954'))
+    usd_price = price_historian.query_historical_price('IOT', 'USD', 1511793374)
+    assert usd_price.is_close(FVal('0.954'))
Repository: rotki/rotki

Issue:
 Fix kraken.find_fiat_price() for pairs where XXBT is quote asset
 Fix #323 


Discussion:

Resolving patch:
diff --git a/rotkehlchen/kraken.py b/rotkehlchen/kraken.py
--- a/rotkehlchen/kraken.py
+++ b/rotkehlchen/kraken.py
@@ -424,16 +424,21 @@ def find_fiat_price(self, asset: Asset) -> FVal:
         pair = asset + 'XXBT'
         pair2 = asset + 'XBT'
         pair3 = 'XXBT' + asset
+        inverse = False
         if pair2 in self.tradeable_pairs:
             pair = pair2
         elif pair3 in self.tradeable_pairs:
             pair = pair3
+            # here XXBT is the base asset so inverse
+            inverse = True
 
         if pair not in self.tradeable_pairs:
             raise ValueError(
                 'Could not find a BTC tradeable pair in kraken for "{}"'.format(asset),
             )
         btc_price = FVal(self.ticker[pair]['c'][0])
+        if inverse:
+            btc_price = FVal('1.0') / btc_price
         common_name = KRAKEN_TO_WORLD[asset]
         with self.lock:
             self.usdprice[common_name] = btc_price * self.usdprice['BTC']


Test patch:
diff --git a/rotkehlchen/tests/test_kraken.py b/rotkehlchen/tests/test_kraken.py
--- a/rotkehlchen/tests/test_kraken.py
+++ b/rotkehlchen/tests/test_kraken.py
@@ -1,5 +1,6 @@
 import pytest
 
+from rotkehlchen.fval import FVal
 from rotkehlchen.kraken import (
     KRAKEN_ASSETS,
     WORLD_TO_KRAKEN,
@@ -64,3 +65,18 @@ def test_kraken_to_world_pair():
 
     with pytest.raises(ValueError):
         kraken_to_world_pair('GABOOBABOO')
+
+
+def test_find_fiat_price(kraken):
+    """
+    Testing that find_fiat_price works correctly
+
+    Also regression test for https://github.com/rotkehlchenio/rotkehlchen/issues/323
+    """
+    kraken.first_connection()
+    # A single YEN should cost less than 1 bitcoin
+    jpy_price = kraken.find_fiat_price('ZJPY')
+    assert jpy_price < FVal('1')
+
+    # Kraken fees have no value
+    kraken.find_fiat_price('KFEE') == FVal('0')
Repository: rotki/rotki

Issue:
Handle too many redirects thrown by http://exchangeratesapi.io/
## Problem Definition

The http://exchangeratesapi.io/ throws too many redirects error if you end up putting the EUR as the base symbol. Made an issue [there](https://github.com/exchangeratesapi/exchangeratesapi/issues/35) too.

## Task

We solve it in Rotkehlchen by handling the too many redirects error and falling back to a different API for querying fiat exchange rates.


Discussion:

Resolving patch:
diff --git a/rotkehlchen/inquirer.py b/rotkehlchen/inquirer.py
--- a/rotkehlchen/inquirer.py
+++ b/rotkehlchen/inquirer.py
@@ -6,6 +6,7 @@
 from typing import Dict, Iterable, Optional, cast
 
 import requests
+
 from rotkehlchen.constants import (
     CURRENCYCONVERTER_API_KEY,
     FIAT_CURRENCIES,
@@ -106,7 +107,7 @@ def _query_exchanges_rateapi(base: FiatAsset, quote: FiatAsset) -> Optional[FVal
     try:
         resp = request_get_dict(querystr)
         return FVal(resp['rates'][quote])
-    except (ValueError, RemoteError, KeyError):
+    except (ValueError, RemoteError, KeyError, requests.exceptions.TooManyRedirects):
         log.error(
             'Querying api.exchangeratesapi.io for fiat pair failed',
             base_currency=base,


Test patch:
Repository: rotki/rotki

Issue:
Allow end user to pass arguments to the python backend
## Problem Definition

At the moment the end users who don't build by source will find it hard to modify the arguments given to the python backend. A way for them to change the arguments should be provided.

## Task

Provide a way to pass arguments to the python backend. Perhaps via a configuration file. And perhaps the most common settings can also be exposed in the UI. But perhaps start with a config file and see which settings need to be most often changed by users.


Discussion:

Resolving patch:
diff --git a/rotkehlchen/args.py b/rotkehlchen/args.py
--- a/rotkehlchen/args.py
+++ b/rotkehlchen/args.py
@@ -22,27 +22,12 @@ def app_args(prog: str, description: str) -> argparse.ArgumentParser:
         description=description,
     )
 
-    p.add_argument(
-        '--output',
-        help=(
-            'A path to a file for logging all output. If nothing is given'
-            'stdout is used'
-        ),
-    )
     p.add_argument(
         '--sleep-secs',
         type=int,
         default=20,
         help="Seconds to sleep during the main loop",
     )
-    p.add_argument(
-        '--notify',
-        action='store_true',
-        help=(
-            'If given then the tool will send notifications via '
-            'notify-send.'
-        ),
-    )
     p.add_argument(
         '--data-dir',
         help='The directory where all data and configs are placed',
diff --git a/rotkehlchen/assets/converters.py b/rotkehlchen/assets/converters.py
--- a/rotkehlchen/assets/converters.py
+++ b/rotkehlchen/assets/converters.py
@@ -376,6 +376,9 @@
     # HINT. As of 28/07/2019 no data found outside of Bittrex for this token
     # https://twitter.com/BittrexIntl/status/1154445165257474051
     'HINT',
+    # TUDA. As of 02/08/2019 no data found outside of Bittrex for this token
+    # https://mobile.twitter.com/BittrexIntl/status/1156974900986490880
+    'TUDA',
 )
 
 


Test patch:
diff --git a/rotkehlchen/tests/fixtures/rotkehlchen.py b/rotkehlchen/tests/fixtures/rotkehlchen.py
--- a/rotkehlchen/tests/fixtures/rotkehlchen.py
+++ b/rotkehlchen/tests/fixtures/rotkehlchen.py
@@ -35,9 +35,7 @@ def rotkehlchen_api_secret():
 @pytest.fixture()
 def cli_args(data_dir):
     args = namedtuple('args', [
-        'output',
         'sleep_secs',
-        'notify',
         'data_dir',
         'zerorpc_port',
         'ethrpc_endpoint',
Repository: rotki/rotki

Issue:
Tax Report creation fails with index out of range error
## Problem Definition

When attempting to create a tax report with the account that we use for the e2e tests, I get the following exception in the logs.

```
24/08/2019 13:20:13 UTC -- ERROR:rotkehlchen.server:Greenlet for task 4 dies with exception: list index out of range.
Exception Name: <class 'IndexError'>
Exception Info: list index out of range
Traceback:
   File "src/gevent/greenlet.py", line 716, in gevent._greenlet.Greenlet.run
  File "/home/kelsos/development/github/rotkehlchenio/rotkehlchen/rotkehlchen/server.py", line 131, in _query_async
    result = getattr(self, command)(**kwargs)
  File "/home/kelsos/development/github/rotkehlchenio/rotkehlchen/rotkehlchen/server.py", line 344, in process_trade_history
    result, error_or_empty = self.rotkehlchen.process_history(start_ts, end_ts)
  File "/home/kelsos/development/github/rotkehlchenio/rotkehlchen/rotkehlchen/rotkehlchen.py", line 322, in process_history
    eth_transactions,
  File "/home/kelsos/development/github/rotkehlchenio/rotkehlchen/rotkehlchen/accounting/accountant.py", line 298, in process_history
    first_ts = action_get_timestamp(actions[0])

```


Discussion:

Resolving patch:
diff --git a/rotkehlchen/accounting/accountant.py b/rotkehlchen/accounting/accountant.py
--- a/rotkehlchen/accounting/accountant.py
+++ b/rotkehlchen/accounting/accountant.py
@@ -294,8 +294,8 @@ def process_history(
         actions.sort(
             key=lambda action: action_get_timestamp(action),
         )
-        # The first timestamp is the timestamp of the first action we have in history
-        first_ts = action_get_timestamp(actions[0])
+        # The first ts is the ts of the first action we have in history or 0 for empty history
+        first_ts = 0 if len(actions) == 0 else action_get_timestamp(actions[0])
         self.currently_processing_timestamp = first_ts
         self.started_processing_timestamp = first_ts
 


Test patch:
diff --git a/rotkehlchen/tests/test_accounting.py b/rotkehlchen/tests/test_accounting.py
--- a/rotkehlchen/tests/test_accounting.py
+++ b/rotkehlchen/tests/test_accounting.py
@@ -495,3 +495,17 @@ def test_no_corresponding_buy_for_sell(accountant):
     )
     assert FVal(result['overview']['general_trade_profit_loss']).is_close('2519.6')
     assert FVal(result['overview']['total_taxable_profit_loss']).is_close('2519.6')
+
+
+@pytest.mark.parametrize('mocked_price_queries', [prices])
+def test_accounting_works_for_empty_history(accountant):
+    history = []
+
+    result = accounting_history_process(
+        accountant,
+        1436979735,
+        1519693374,
+        history,
+    )
+    assert FVal(result['overview']['general_trade_profit_loss']).is_close('0')
+    assert FVal(result['overview']['total_taxable_profit_loss']).is_close('0')
Repository: rotki/rotki

Issue:
LBRY Credits cryptocompare price queries did not work
## Problem Definition

LBRY cryptocompare queries stopped working.
It seems that `LBRY` is known as `LBC` in cryptocompare.

## Task

Fix the cryptocompare mapping


Discussion:

Resolving patch:
diff --git a/rotkehlchen/constants/cryptocompare.py b/rotkehlchen/constants/cryptocompare.py
--- a/rotkehlchen/constants/cryptocompare.py
+++ b/rotkehlchen/constants/cryptocompare.py
@@ -1,4 +1,5 @@
 WORLD_TO_CRYPTOCOMPARE = {
+    'LBRY': 'LBC',
     'DATAcoin': 'DATA',
     'IOTA': 'MIOTA',
     'XRB': 'NANO',


Test patch:
Repository: rotki/rotki

Issue:
Querying some tokens via cryptocompare returns empty object which leads to a crash
## Problem Definition

Since 17.10.19 it seems that for some token price queries in cryptocompare an empty object `{}` is returned which does not seem to agree with the API documentation and leads to a crash.

The crash was seen by a Rotki user and looks like this in the logs:

```
17/10/2019 13:28:56 +08 -- DEBUG:rotkehlchen.inquirer:Get usd price from cryptocompare asset=WETH

17/10/2019 13:28:57 +08 -- ERROR:rotkehlchen.server:Greenlet for task 2 dies with exception: 'Response'.
Exception Name: <class 'KeyError'>
Exception Info: 'Response'
Traceback:

   File "src/gevent/greenlet.py", line 716, in gevent._greenlet.Greenlet.run
  File "rotkehlchen/server.py", line 132, in _query_async
  File "rotkehlchen/server.py", line 370, in query_balances
  File "rotkehlchen/rotkehlchen.py", line 368, in query_balances
  File "rotkehlchen/utils/misc.py", line 109, in wrapper
  File "rotkehlchen/blockchain.py", line 86, in query_balances
  File "rotkehlchen/blockchain.py", line 405, in query_ethereum_balances
  File "rotkehlchen/blockchain.py", line 354, in query_ethereum_tokens
  File "rotkehlchen/inquirer.py", line 133, in find_usd_price
  File "rotkehlchen/inquirer.py", line 49, in query_cryptocompare_for_fiat_price

17/10/2019 13:29:38 +08 -- DEBUG:rotkehlchen.rotkehlchen:Main loop start

17/10/2019 13:29:38 +08 -- DEBUG:rotkehlchen.rotkehlchen:Main loop end
```

An example of the offending cryptocompare API request is this:

https://min-api.cryptocompare.com/data/price?fsym=WETH&tsyms=USD

which returns `{}`

Normally for non-existing tokens or tokens for which data does not exist a proper error is returned like here:

https://min-api.cryptocompare.com/data/price?fsym=XXXX&tsyms=USD

`{"Response":"Error","Message":"There is no data for the symbol XXXX .","HasWarning":false,"Type":2,"RateLimit":{},"Data":{},"ParamWithError":"fsym"}`

The unexpected empty object leads to a crash of Rotki, so it's important to fix.

## Task

After talking with @vcealicu I confirmed this is a bug on the cryptocompare side so it should eventually go away on its own.

But the fact of the matter remains that any such unexpected answer should not crash the Rotki application. So we just need to handle the empty object return.


Discussion:
@Pol-Lanski fyi ^

Resolving patch:
diff --git a/rotkehlchen/inquirer.py b/rotkehlchen/inquirer.py
--- a/rotkehlchen/inquirer.py
+++ b/rotkehlchen/inquirer.py
@@ -46,8 +46,8 @@ def query_cryptocompare_for_fiat_price(asset: Asset) -> Price:
     # If there is an error in the response skip this token
     if 'USD' not in resp:
         error_message = ''
-        if resp['Response'] == 'Error':
-            error_message = resp['Message']
+        if resp.get('Response', None) == 'Error':
+            error_message = resp.get('Message', '')
 
         log.error(
             'Cryptocompare usd price query failed',


Test patch:
Repository: rotki/rotki

Issue:
At sign-in failure there is not enough debug information
## Problem Definition

If there is a sign-in failure due to an exception the user is greeted with the exception that is thrown as an error but not with more information like a stacktrace. And a stacktrace does not make it into the log.

A good example of the problems this presents can be seen by the difficulty of debugging #587 

## Note

This is probably not needed in develop as the REST API there would log an internal 500 Server error containing the stack trace

## Task

Add more debug information if sign-in fails due to some exception.




Discussion:

Resolving patch:
diff --git a/rotkehlchen/server.py b/rotkehlchen/server.py
--- a/rotkehlchen/server.py
+++ b/rotkehlchen/server.py
@@ -529,6 +529,11 @@ def unlock_user(
             res['result'] = False
             res['permission_needed'] = True
             res['message'] = str(e)
+        except: # noqa
+            tb = traceback.format_exc()
+            logging.critical(tb)
+            res['result'] = False
+            res['message'] = 'Unexpected exception occured during unlock. Check log for details'
 
         return res
 


Test patch:
Repository: rotki/rotki

Issue:
Remove semantic-version pinning if releases gets fixed
## Problem Definition

To keep generating the docs I had to pin the `semantic-version` dependency of `releases` since its latest version seems to break it.

Here is the issue tracking it: https://github.com/bitprophet/releases/issues/84

## Task

Check if/when `releases` is fixed and remove the pinning from here:

https://github.com/rotkehlchenio/rotkehlchen/blob/22c99f854cbe401f0872b320e9ded9c9d3e9e0db/requirements_docs.txt#L7-L8


Discussion:

Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -50,6 +50,10 @@
 # 'releases' (changelog) settings
 releases_issue_uri = "https://github.com/rotki/rotki/issues/%s"
 releases_release_uri = "https://github.com/rotki/rotki/releases/tag/v%s"
+# Enables 0.x.y releases to not be grouped into feature and bugfix releases
+# see: http://releases.readthedocs.io/en/latest/concepts.html#unstable-prehistory-mode
+# This needs to be kept enabled even once 1.0 has been reached!
+releases_unstable_prehistory = True
 
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
@@ -187,11 +191,3 @@
 
 # A list of files that should not be packed into the epub file.
 epub_exclude_files = ['search.html']
-
-
-# -- Extension configuration -------------------------------------------------
-
-# Enables 0.x.y releases to not be grouped into feature and bugfix releases
-# see: http://releases.readthedocs.io/en/latest/concepts.html#unstable-prehistory-mode
-# This needs to be kept enabled even once 1.0 has been reached!
-releases_unstable_prehistory = True
diff --git a/rotkehlchen/history.py b/rotkehlchen/history.py
--- a/rotkehlchen/history.py
+++ b/rotkehlchen/history.py
@@ -150,10 +150,10 @@ def __init__(
         self.exchange_manager = exchange_manager
         self.etherscan = etherscan
 
-    def create_history(self, start_ts: Timestamp, end_ts: Timestamp) -> HistoryResult:
+    def get_history(self, start_ts: Timestamp, end_ts: Timestamp) -> HistoryResult:
         """Creates trades and loans history from start_ts to end_ts"""
         log.info(
-            'Starting trade history creation',
+            'Get/create trade history',
             start_ts=start_ts,
             end_ts=end_ts,
         )
@@ -236,17 +236,3 @@ def fail_history_cb(error_msg: str) -> None:
             asset_movements,
             eth_transactions,
         )
-
-    def get_history(self, start_ts: Timestamp, end_ts: Timestamp) -> HistoryResult:
-        """Gets or creates trades and loans history from start_ts to end_ts or if
-        `end_at_least` is given and we have a cache history which satisfies it we
-        return the cache
-        """
-        log.info(
-            'Get or create trade history',
-            start_ts=start_ts,
-            end_ts=end_ts,
-        )
-        # TODO: Perhaps get rid of the extra function call since the caches
-        # are no longer used here?
-        return self.create_history(start_ts, end_ts)


Test patch:
Repository: rotki/rotki

Issue:
Handle new Kraken LTC and XPR pairs
## Problem Definition

Rotki does not handle the new LTC and XPR pairs offered by Kraken properly.

 The reason is the usual kraken incosistency shenanigans. XXRP and XLTC is what they have for the old pairs and what Rotki expects but these new ones have XRP and LTC.

## Task

Handle them properly.


Discussion:

Resolving patch:
diff --git a/rotkehlchen/exchanges/kraken.py b/rotkehlchen/exchanges/kraken.py
--- a/rotkehlchen/exchanges/kraken.py
+++ b/rotkehlchen/exchanges/kraken.py
@@ -87,7 +87,7 @@ def kraken_to_world_pair(pair: str) -> TradePair:
     elif pair[0:3] in KRAKEN_TO_WORLD:
         base_asset_str = pair[0:3]
         quote_asset_str = pair[3:]
-    elif pair[0:3] in ('XBT', 'ETH', 'XDG'):
+    elif pair[0:3] in ('XBT', 'ETH', 'XDG', 'LTC', 'XRP'):
         # Some assets can have the 'X' prefix omitted for some pairs
         base_asset_str = pair[0:3]
         quote_asset_str = pair[3:]
diff --git a/rotkehlchen/externalapis/coinpaprika.py b/rotkehlchen/externalapis/coinpaprika.py
--- a/rotkehlchen/externalapis/coinpaprika.py
+++ b/rotkehlchen/externalapis/coinpaprika.py
@@ -49,6 +49,7 @@
     'GPUC',
     'GUE',
     'HBD',
+    'HDAO',
     'HIVE',
     'HUGE',
     'HVC',
diff --git a/tools/asset_aggregator/typeinfo_check.py b/tools/asset_aggregator/typeinfo_check.py
--- a/tools/asset_aggregator/typeinfo_check.py
+++ b/tools/asset_aggregator/typeinfo_check.py
@@ -41,6 +41,7 @@
     'FLX': 'ethereum token',
     'FORK-2': 'ethereum token',
     'HBD': 'own chain',
+    'HDAO': 'ethereum token',
     'HIVE': 'own chain',
     'HKG': 'ethereum token',
     'ITM': 'ethereum token',


Test patch:
diff --git a/rotkehlchen/tests/exchanges/test_kraken.py b/rotkehlchen/tests/exchanges/test_kraken.py
--- a/rotkehlchen/tests/exchanges/test_kraken.py
+++ b/rotkehlchen/tests/exchanges/test_kraken.py
@@ -97,6 +97,10 @@ def test_kraken_to_world_pair(kraken):
     assert kraken_to_world_pair('EURCAD') == 'EUR_CAD'
     assert kraken_to_world_pair('USDCHF') == 'USD_CHF'
     assert kraken_to_world_pair('EURJPY') == 'EUR_JPY'
+    assert kraken_to_world_pair('LTCETH') == 'LTC_ETH'
+    assert kraken_to_world_pair('LTCUSDT') == 'LTC_USDT'
+    assert kraken_to_world_pair('XRPGBP') == 'XRP_GBP'
+    assert kraken_to_world_pair('XRPUSDT') == 'XRP_USDT'
 
     # now try to test all pairs that kraken returns and if one does not work note
     # down a test warning so that it can be fixed by us later
Repository: rotki/rotki

Issue:
FileNotFoundError ignored during tests
## Abstract

During running some tests with `-s` some times this may appear in the logs:

```
Exception ignored in: <function DBHandler.__del__ at 0x7efc93b51050>
Traceback (most recent call last):
  File "/home/lefteris/w/rotkehlchen/rotkehlchen/db/dbhandler.py", line 191, in __del__
    dbinfo = {'sqlcipher_version': self.sqlcipher_version, 'md5_hash': self.get_md5hash()}
  File "/home/lefteris/w/rotkehlchen/rotkehlchen/db/dbhandler.py", line 231, in get_md5hash
    with open(filename, 'rb') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/home/lefteris/.rotkehlchen/tests_data_directory/testuser/rotkehlchen.db
```

Not sure why this is happening but should be some kind of teardown timing problem that should be addressed.

## Task

Find out when and why this happens and fix it.


Discussion:

Resolving patch:
diff --git a/rotkehlchen/db/dbhandler.py b/rotkehlchen/db/dbhandler.py
--- a/rotkehlchen/db/dbhandler.py
+++ b/rotkehlchen/db/dbhandler.py
@@ -192,7 +192,7 @@ def __del__(self) -> None:
         self.disconnect()
         try:
             dbinfo = {'sqlcipher_version': self.sqlcipher_version, 'md5_hash': self.get_md5hash()}
-        except SystemPermissionError as e:
+        except (SystemPermissionError, FileNotFoundError) as e:
             # If there is problems opening the DB at destruction just log and exit
             log.error(f'At DB teardown could not open the DB: {str(e)}')
             return


Test patch:
diff --git a/rotkehlchen/tests/utils/premium.py b/rotkehlchen/tests/utils/premium.py
--- a/rotkehlchen/tests/utils/premium.py
+++ b/rotkehlchen/tests/utils/premium.py
@@ -203,8 +203,16 @@ def assert_db_got_replaced(rotkehlchen_instance: Rotkehlchen, username: str):
     # Also check a copy of our old DB is kept around.
     directory = os.path.join(rotkehlchen_instance.data.data_directory, username)
     files = [os.path.join(directory, f) for f in os.listdir(directory)]
-    msg = f'Expected 2 files in the directory but got {files}'
-    assert len(files) == 2, msg
+    msg = f'Expected 2 or 3 files in the directory but got {files}'
+    assert len(files) == 2 or len(files) == 3, msg  # 3rd file is the dbinfo.json
     # The order of the files is not guaranteed
-    assert 'rotkehlchen.db' in files[0] or 'rotkehlchen.db' in files[1]
-    assert 'backup' in files[0] or 'backup' in files[1]
+    main_db_exists = False
+    backup_db_exists = False
+    for file in files:
+        if 'rotkehlchen.db' in file:
+            main_db_exists = True
+        elif 'backup' in file:
+            backup_db_exists = True
+
+    assert main_db_exists
+    assert backup_db_exists