def test_text_store__write_version_incompatible(tmp_path) -> None: wallet_path = os.path.join(tmp_path, "database") store = TextStore(wallet_path) try: store.put("seed_version", TextStore.FINAL_SEED_VERSION + 1) with pytest.raises(IncompatibleWalletError): store.write() finally: store.close()
def test_text_store__write_version_incompatible() -> None: wallet_path = tempfile.mktemp() store = TextStore(wallet_path) try: store.put("seed_version", TextStore.FINAL_SEED_VERSION + 1) with pytest.raises(IncompatibleWalletError): store.write() finally: store.close()
def test_text_store__raise_unsupported_version() -> None: wallet_path = tempfile.mktemp() store = TextStore(wallet_path) with pytest.raises(Exception) as e: store._raise_unsupported_version(5) assert "To open this wallet" in e.value.args[0] with pytest.raises(Exception) as e: store._raise_unsupported_version(6) assert "It does not contain any keys" in e.value.args[0] store.put("master_public_keys", 1) with pytest.raises(Exception) as e: store._raise_unsupported_version(6) assert "Please open this file" in e.value.args[0]
def test_text_store__raise_unsupported_version(tmp_path) -> None: wallet_path = os.path.join(tmp_path, "database") store = TextStore(wallet_path) try: with pytest.raises(Exception) as e: store._raise_unsupported_version(5) assert "To open this wallet" in e.value.args[0] with pytest.raises(Exception) as e: store._raise_unsupported_version(6) assert "It does not contain any keys" in e.value.args[0] store.put("master_public_keys", 1) with pytest.raises(Exception) as e: store._raise_unsupported_version(6) assert "Please open this file" in e.value.args[0] finally: store.close()
def test_store__write(tmp_path) -> None: wallet_path = os.path.join(tmp_path, "wallet") store = TextStore(wallet_path) try: assert not store.is_primed() store.put("number", 10) store._write() assert store.is_primed() # This will raise an assertion if there is not locatible JSON lump. store._read_raw_data() assert store.get("number") == 10 finally: store.close() store = TextStore(wallet_path) try: assert store.is_primed() # We need to do this here because the wallet storage normally does it. store.load_data(store._read_raw_data()) assert store.get("number") == 10 finally: store.close()