Beispiel #1
0
def test_database_store_version_init_set(tmp_path) -> None:
    wallet_path = os.path.join(tmp_path, "database")
    db_store = DatabaseStore(wallet_path)
    try:
        _check_database_store_version_init_set(db_store, MIGRATION_CURRENT)
    finally:
        db_store.close()
Beispiel #2
0
def test_database_store_requires_split(tmp_path) -> None:
    wallet_path = os.path.join(tmp_path, "database")
    db_store = DatabaseStore(wallet_path)
    try:
        assert not db_store.requires_split()
    finally:
        db_store.close()
Beispiel #3
0
def test_database_store_requires_split() -> None:
    wallet_path = tempfile.mktemp()
    db_store = DatabaseStore(wallet_path)
    try:
        assert not db_store.requires_split()
    finally:
        db_store.close()
Beispiel #4
0
def test_database_store_version_init_set() -> None:
    wallet_path = tempfile.mktemp()
    db_store = DatabaseStore(wallet_path)
    try:
        _check_database_store_version_init_set(db_store,
                                               DatabaseStore.CURRENT_MIGRATION)
    finally:
        db_store.close()
Beispiel #5
0
def test_database_store_new_never_requires_upgrade(tmp_path) -> None:
    wallet_path = os.path.join(tmp_path, "database")
    db_store = DatabaseStore(wallet_path)
    try:
        # At this time this is not linked to anything as database storage upgrades internally.
        # However, we may need to extend it as the JSON lump contents change.
        assert not db_store.requires_upgrade()
    finally:
        db_store.close()
Beispiel #6
0
def test_database_store_from_text_store_initial_version(data) -> None:
    wallet_path = tempfile.mktemp()
    text_store = TextStore(wallet_path, data=data)
    try:
        # Verify that the seed version is rejected (the assertion is hit).
        with pytest.raises(AssertionError):
            DatabaseStore.from_text_store(text_store)
    finally:
        text_store.close()
Beispiel #7
0
def test_database_store_version_requires_upgrade_esv_wallet() -> None:
    wallet_path = tempfile.mktemp()
    db_store = DatabaseStore(wallet_path)
    db_store._set_seed_version(DatabaseStore.INITIAL_SEED_VERSION)
    db_store.put("wallet_author", "ESV")
    db_store.write()
    # "ESV" marker present.
    assert db_store.requires_upgrade()
Beispiel #8
0
def test_database_store_version_requires_upgrade_not_esv_wallet() -> None:
    wallet_path = tempfile.mktemp()
    db_store = DatabaseStore(wallet_path)
    db_store._set_seed_version(DatabaseStore.INITIAL_SEED_VERSION)
    db_store.write()
    # Missing "ESV" marker.
    with pytest.raises(IncompatibleWalletError):
        db_store.requires_upgrade()
Beispiel #9
0
def test_database_store_from_text_store_version_init_set() -> None:
    wallet_path = tempfile.mktemp()
    text_store = TextStore(
        wallet_path, data={"seed_version": DatabaseStore.INITIAL_SEED_VERSION})
    # Verify that the seed version is accepted (no assertion hit).
    db_store = DatabaseStore.from_text_store(text_store)
    _check_database_store_version_init_set(db_store)
Beispiel #10
0
def test_database_store_version_requires_upgrade(tmp_path) -> None:
    wallet_path = os.path.join(tmp_path, "database")
    db_store = DatabaseStore(wallet_path)
    try:
        db_store.put("migration", DatabaseStore.INITIAL_MIGRATION - 1)
        assert db_store.requires_upgrade()
    finally:
        db_store.close()
Beispiel #11
0
def test_database_store_version_requires_upgrade() -> None:
    wallet_path = tempfile.mktemp()
    db_store = DatabaseStore(wallet_path)
    try:
        db_store.put("migration", DatabaseStore.INITIAL_MIGRATION - 1)
        assert db_store.requires_upgrade()
    finally:
        db_store.close()
Beispiel #12
0
def test_database_store_from_text_store_version_init_set(tmp_path) -> None:
    wallet_path = os.path.join(tmp_path, "database")
    try:
        text_store = TextStore(wallet_path,
                               data={"seed_version": MIGRATION_FIRST})
        # Verify that the seed version is accepted (no assertion hit).
        db_store = DatabaseStore.from_text_store(text_store)
        _check_database_store_version_init_set(db_store, MIGRATION_CURRENT)
    finally:
        db_store.close()
        text_store.close()
Beispiel #13
0
def test_database_store_version_requires_upgrade() -> None:
    wallet_path = tempfile.mktemp()
    db_store = DatabaseStore(wallet_path)
    db_store._set_seed_version(DatabaseStore.INITIAL_SEED_VERSION - 1)
    with pytest.raises(IncompatibleWalletError):
        db_store.requires_upgrade()
Beispiel #14
0
def test_database_store_new_never_requires_upgrade() -> None:
    wallet_path = tempfile.mktemp()
    db_store = DatabaseStore(wallet_path)
    # At this time this is not linked to anything as database storage upgrades internally.
    # However, we may need to extend it as the JSON lump contents change.
    assert not db_store.requires_upgrade()
Beispiel #15
0
def test_database_store_version_init_set() -> None:
    wallet_path = tempfile.mktemp()
    db_store = DatabaseStore(wallet_path)
    _check_database_store_version_init_set(db_store)