mirror of https://github.com/nucypher/nucypher.git
Round-up more test constants
parent
6a79833165
commit
11afd1b50c
|
@ -24,8 +24,8 @@ from web3.middleware import geth_poa_middleware
|
|||
from nucypher.blockchain.eth import constants
|
||||
from nucypher.blockchain.eth.chains import Blockchain
|
||||
from nucypher.utilities.sandbox.constants import (DEVELOPMENT_ETH_AIRDROP_AMOUNT,
|
||||
DEFAULT_NUMBER_OF_URSULAS_IN_DEVELOPMENT_NETWORK,
|
||||
TEST_URSULA_INSECURE_DEVELOPMENT_PASSWORD)
|
||||
NUMBER_OF_URSULAS_IN_DEVELOPMENT_NETWORK,
|
||||
INSECURE_DEVELOPMENT_PASSWORD)
|
||||
|
||||
|
||||
def token_airdrop(token_agent, amount: int, origin: str, addresses: List[str]):
|
||||
|
@ -62,11 +62,11 @@ class TesterBlockchain(Blockchain):
|
|||
w3.middleware_stack.inject(geth_poa_middleware, layer=0)
|
||||
|
||||
# Generate additional ethereum accounts for testing
|
||||
enough_accounts = len(self.interface.w3.eth.accounts) >= DEFAULT_NUMBER_OF_URSULAS_IN_DEVELOPMENT_NETWORK
|
||||
enough_accounts = len(self.interface.w3.eth.accounts) >= NUMBER_OF_URSULAS_IN_DEVELOPMENT_NETWORK
|
||||
if test_accounts is not None and not enough_accounts:
|
||||
|
||||
accounts_to_make = DEFAULT_NUMBER_OF_URSULAS_IN_DEVELOPMENT_NETWORK - len(self.interface.w3.eth.accounts)
|
||||
test_accounts = test_accounts if test_accounts is not None else DEFAULT_NUMBER_OF_URSULAS_IN_DEVELOPMENT_NETWORK
|
||||
accounts_to_make = NUMBER_OF_URSULAS_IN_DEVELOPMENT_NETWORK - len(self.interface.w3.eth.accounts)
|
||||
test_accounts = test_accounts if test_accounts is not None else NUMBER_OF_URSULAS_IN_DEVELOPMENT_NETWORK
|
||||
|
||||
self.__generate_insecure_unlocked_accounts(quantity=accounts_to_make)
|
||||
|
||||
|
@ -84,7 +84,7 @@ class TesterBlockchain(Blockchain):
|
|||
Generate additional unlocked accounts transferring a balance to each account on creation.
|
||||
"""
|
||||
addresses = list()
|
||||
insecure_password = TEST_URSULA_INSECURE_DEVELOPMENT_PASSWORD
|
||||
insecure_password = INSECURE_DEVELOPMENT_PASSWORD
|
||||
for _ in range(quantity):
|
||||
|
||||
umbral_priv_key = UmbralPrivateKey.gen_key()
|
||||
|
|
|
@ -14,16 +14,19 @@ GNU General Public License for more details.
|
|||
You should have received a copy of the GNU General Public License
|
||||
along with nucypher. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
|
||||
import os
|
||||
|
||||
from nucypher.blockchain.eth.constants import DISPATCHER_SECRET_LENGTH, M
|
||||
from nucypher.config.constants import DEFAULT_CONFIG_ROOT
|
||||
|
||||
TEST_KNOWN_URSULAS_CACHE = {}
|
||||
|
||||
TEST_URSULA_STARTING_PORT = 7468
|
||||
MOCK_KNOWN_URSULAS_CACHE = {}
|
||||
|
||||
DEFAULT_NUMBER_OF_URSULAS_IN_DEVELOPMENT_NETWORK = 10
|
||||
MOCK_URSULA_STARTING_PORT = 49152
|
||||
|
||||
NUMBER_OF_URSULAS_IN_DEVELOPMENT_NETWORK = 10
|
||||
|
||||
DEVELOPMENT_TOKEN_AIRDROP_AMOUNT = 1000000 * int(M)
|
||||
|
||||
|
@ -33,6 +36,12 @@ MINERS_ESCROW_DEPLOYMENT_SECRET = os.urandom(DISPATCHER_SECRET_LENGTH)
|
|||
|
||||
POLICY_MANAGER_DEPLOYMENT_SECRET = os.urandom(DISPATCHER_SECRET_LENGTH)
|
||||
|
||||
TEST_URSULA_INSECURE_DEVELOPMENT_PASSWORD = 'this-is-not-a-secure-password'
|
||||
INSECURE_DEVELOPMENT_PASSWORD = 'this-is-not-a-secure-password'
|
||||
|
||||
DEFAULT_SIMULATION_REGISTRY_FILEPATH = os.path.join(DEFAULT_CONFIG_ROOT, 'simulated_registry.json')
|
||||
MAX_TEST_SEEDER_ENTRIES = 20
|
||||
|
||||
MOCK_IP_ADDRESS = '0.0.0.0'
|
||||
|
||||
MOCK_IP_ADDRESS_2 = '10.10.10.10'
|
||||
|
||||
MOCK_CUSTOM_INSTALLATION_PATH = '/tmp/nucypher-tmp-test-custom'
|
||||
|
|
|
@ -21,7 +21,7 @@ from apistar import TestClient
|
|||
from nucypher.characters.lawful import Ursula
|
||||
from nucypher.crypto.kits import RevocationKit
|
||||
from nucypher.network.middleware import RestMiddleware
|
||||
from nucypher.utilities.sandbox.constants import TEST_KNOWN_URSULAS_CACHE
|
||||
from nucypher.utilities.sandbox.constants import MOCK_KNOWN_URSULAS_CACHE
|
||||
|
||||
|
||||
class MockRestMiddleware(RestMiddleware):
|
||||
|
@ -46,7 +46,7 @@ class MockRestMiddleware(RestMiddleware):
|
|||
|
||||
def _get_ursula_by_port(self, port):
|
||||
try:
|
||||
return TEST_KNOWN_URSULAS_CACHE[port]
|
||||
return MOCK_KNOWN_URSULAS_CACHE[port]
|
||||
except KeyError:
|
||||
raise RuntimeError(
|
||||
"Can't find an Ursula with port {} - did you spin up the right test ursulas?".format(port))
|
||||
|
|
|
@ -25,21 +25,21 @@ from nucypher.characters.lawful import Ursula
|
|||
from nucypher.config.characters import UrsulaConfiguration
|
||||
from nucypher.crypto.api import secure_random
|
||||
from nucypher.utilities.sandbox.constants import (
|
||||
TEST_KNOWN_URSULAS_CACHE,
|
||||
TEST_URSULA_STARTING_PORT,
|
||||
DEFAULT_NUMBER_OF_URSULAS_IN_DEVELOPMENT_NETWORK
|
||||
MOCK_KNOWN_URSULAS_CACHE,
|
||||
MOCK_URSULA_STARTING_PORT,
|
||||
NUMBER_OF_URSULAS_IN_DEVELOPMENT_NETWORK
|
||||
)
|
||||
|
||||
|
||||
def make_federated_ursulas(ursula_config: UrsulaConfiguration,
|
||||
quantity: int = DEFAULT_NUMBER_OF_URSULAS_IN_DEVELOPMENT_NETWORK,
|
||||
quantity: int = NUMBER_OF_URSULAS_IN_DEVELOPMENT_NETWORK,
|
||||
know_each_other: bool = True,
|
||||
**ursula_overrides) -> Set[Ursula]:
|
||||
|
||||
if not TEST_KNOWN_URSULAS_CACHE:
|
||||
starting_port = TEST_URSULA_STARTING_PORT
|
||||
if not MOCK_KNOWN_URSULAS_CACHE:
|
||||
starting_port = MOCK_URSULA_STARTING_PORT
|
||||
else:
|
||||
starting_port = max(TEST_KNOWN_URSULAS_CACHE.keys()) + 1
|
||||
starting_port = max(MOCK_KNOWN_URSULAS_CACHE.keys()) + 1
|
||||
|
||||
federated_ursulas = set()
|
||||
for port in range(starting_port, starting_port+quantity):
|
||||
|
@ -53,7 +53,7 @@ def make_federated_ursulas(ursula_config: UrsulaConfiguration,
|
|||
# Store this Ursula in our global testing cache.
|
||||
|
||||
port = ursula.rest_information()[0].port
|
||||
TEST_KNOWN_URSULAS_CACHE[port] = ursula
|
||||
MOCK_KNOWN_URSULAS_CACHE[port] = ursula
|
||||
|
||||
if know_each_other:
|
||||
|
||||
|
@ -75,10 +75,10 @@ def make_decentralized_ursulas(ursula_config: UrsulaConfiguration,
|
|||
if isinstance(ether_addresses, int):
|
||||
ether_addresses = [to_checksum_address(secure_random(20)) for _ in range(ether_addresses)]
|
||||
|
||||
if not TEST_KNOWN_URSULAS_CACHE:
|
||||
starting_port = TEST_URSULA_STARTING_PORT
|
||||
if not MOCK_KNOWN_URSULAS_CACHE:
|
||||
starting_port = MOCK_URSULA_STARTING_PORT
|
||||
else:
|
||||
starting_port = max(TEST_KNOWN_URSULAS_CACHE.keys()) + 1
|
||||
starting_port = max(MOCK_KNOWN_URSULAS_CACHE.keys()) + 1
|
||||
|
||||
ursulas = set()
|
||||
for port, checksum_address in enumerate(ether_addresses, start=starting_port):
|
||||
|
@ -101,7 +101,7 @@ def make_decentralized_ursulas(ursula_config: UrsulaConfiguration,
|
|||
ursulas.add(ursula)
|
||||
# Store this Ursula in our global cache.
|
||||
port = ursula.rest_information()[0].port
|
||||
TEST_KNOWN_URSULAS_CACHE[port] = ursula
|
||||
MOCK_KNOWN_URSULAS_CACHE[port] = ursula
|
||||
|
||||
if know_each_other:
|
||||
|
||||
|
|
Loading…
Reference in New Issue