Ursula can't just willy-nilly spin up an in-memory db anymore.

pull/120/head
jMyles 2017-11-21 12:04:33 -08:00
parent 83e63a2ffe
commit 4ff94f385b
3 changed files with 8 additions and 12 deletions

View File

@ -6,7 +6,6 @@ import msgpack
from apistar import http
from apistar.core import Route
from apistar.frameworks.wsgi import WSGIApp as App
from sqlalchemy.engine import create_engine
from sqlalchemy.exc import IntegrityError
from kademlia.network import Server
@ -15,8 +14,6 @@ from nkms.crypto import api as API
from nkms.crypto.api import secure_random, keccak_digest
from nkms.crypto.constants import NOT_SIGNED, NO_DECRYPTION_PERFORMED
from nkms.crypto.powers import CryptoPower, SigningPower, EncryptingPower
from nkms.keystore import keystore
from nkms.keystore.db import Base
from nkms.keystore.keypairs import Keypair
from nkms.network import blockchain_client
from nkms.network.blockchain_client import list_all_ursulas
@ -270,13 +267,7 @@ class Ursula(Character):
def __init__(self, urulsas_keystore=None, *args, **kwargs):
super().__init__(*args, **kwargs)
if urulsas_keystore:
self.keystore = urulsas_keystore
else:
self.log.warning("You didn't pass a keystore when creating Ursula - using in-memory sqlite DB (not persistent)")
engine = create_engine('sqlite:///:memory:')
Base.metadata.create_all(engine)
self.keystore = keystore.KeyStore(engine)
self.keystore = urulsas_keystore
self._rest_app = None

View File

@ -6,7 +6,6 @@ import pytest
from kademlia.utils import digest
from nkms.characters import Ursula, Alice, Character, Bob, congregate
from nkms.keystore.db.models import KeyFrag
from nkms.network.blockchain_client import list_all_ursulas
from nkms.network.protocols import dht_value_splitter
from nkms.policy.constants import NON_PAYMENT

View File

@ -1,8 +1,11 @@
import asyncio
from apistar.test import TestClient
from sqlalchemy.engine import create_engine
from nkms.characters import Ursula
from nkms.keystore import keystore
from nkms.keystore.db import Base
from nkms.network.node import NetworkyStuff
@ -17,7 +20,10 @@ def make_fake_ursulas(how_many_ursulas: int, ursula_starting_port: int) -> list:
URSULAS = []
for _u in range(how_many_ursulas):
_URSULA = Ursula()
engine = create_engine('sqlite:///:memory:')
Base.metadata.create_all(engine)
ursulas_keystore = keystore.KeyStore(engine)
_URSULA = Ursula(urulsas_keystore=ursulas_keystore)
_URSULA.attach_server()
_URSULA.listen(ursula_starting_port + _u, "127.0.0.1")