def setUp(self): try: self.network = run_4_nodes("exonum-cryptocurrency-advanced") wait_network_to_start(self.network) instances = {"crypto": {"artifact": "cryptocurrency"}} cryptocurrency_advanced_config_dict = generate_config( self.network, instances=instances) cryptocurrency_advanced_config = Configuration( cryptocurrency_advanced_config_dict) with Launcher(cryptocurrency_advanced_config) as launcher: explorer = launcher.explorer() launcher.deploy_all() launcher.wait_for_deploy() launcher.start_all() launcher.wait_for_start() for artifact in launcher.launch_state.completed_deployments(): deployed = explorer.check_deployed(artifact) self.assertEqual(deployed, True) # Launcher checks that config is applied, no need to check it again. except Exception as error: # If exception is raise in `setUp`, `tearDown` won't be called, # thus here we ensure that network is stopped and temporary data is removed. # Then we re-raise exception, since the test should fail. self.network.stop() self.network.deinitialize() raise error
def setUp(self): self.network = run_4_nodes("exonum-cryptocurrency-advanced") self.addCleanup(self._tear_down, False) wait_network_to_start(self.network) instances = {"crypto": {"artifact": "cryptocurrency"}} cryptocurrency_advanced_config_dict = generate_config( self.network, instances=instances) cryptocurrency_advanced_config = Configuration( cryptocurrency_advanced_config_dict) with Launcher(cryptocurrency_advanced_config) as launcher: explorer = launcher.explorer() for artifact in launcher.launch_state.completed_deployments(): deployed = explorer.is_deployed(artifact) self.assertEqual(deployed, True)
def setUp(self): try: self.network = run_4_nodes("vega-cryptocurrency-advanced") wait_network_to_start(self.network) cryptocurrency_advanced_config_dict = { "networks": launcher_networks(self.network), "deadline_height": 10000, "artifacts": { "cryptocurrency": { "runtime": "rust", "name": "vega-cryptocurrency-advanced", "version": "0.1.0", } }, "instances": {"crypto": {"artifact": "cryptocurrency", "action": "start"}}, } cryptocurrency_advanced_config = Configuration( cryptocurrency_advanced_config_dict ) with Launcher(cryptocurrency_advanced_config) as launcher: explorer = launcher.explorer() launcher.deploy_all() launcher.wait_for_deploy() launcher.start_all() launcher.wait_for_start() for artifact in launcher.launch_state.completed_deployments(): deployed = explorer.check_deployed(artifact) self.assertEqual(deployed, True) # Launcher checks that config is applied, no need to check it again. except Exception as error: # If exception is raise in `setUp`, `tearDown` won't be called, # thus here we ensure that network is stopped and temporary data is removed. # Then we re-raise exception, since the test should fail. self.network.stop() self.network.deinitialize() raise error
def setUp(self): self.network = run_4_nodes("exonum-cryptocurrency-advanced") wait_network_to_start(self.network)
def wait_for_api_restart(self): """Waits until the API servers of nodes are restarted after the set of active services has changed.""" time.sleep(0.25) wait_network_to_start(self.network)
def setUp(self): self.network = run_4_nodes("cryptocurrency-migration") self.addCleanup(self._tear_down, False) wait_network_to_start(self.network)
def setUp(self): self.network = run_dev_node("cryptocurrency-migration") wait_network_to_start(self.network)
def test_deploy_regular_stop_and_resume_running_instance(self): """Tests the deploy mechanism to stop and resume running instance.""" instances = {"crypto": {"artifact": "cryptocurrency"}} cryptocurrency_advanced_config_dict = generate_config(self.network, instances=instances) cryptocurrency_advanced_config = Configuration(cryptocurrency_advanced_config_dict) with Launcher(cryptocurrency_advanced_config) as launcher: explorer = launcher.explorer() launcher.deploy_all() launcher.wait_for_deploy() launcher.start_all() launcher.wait_for_start() self.wait_for_api_restart() for artifact in launcher.launch_state.completed_deployments(): deployed = explorer.is_deployed(artifact) self.assertEqual(deployed, True) self.assertEqual(len(launcher.launch_state.completed_configs()), 1) # stop service instances = {"crypto": {"artifact": "cryptocurrency", "action": "stop"}} cryptocurrency_advanced_config_dict = generate_config(self.network, instances=instances, artifact_action="none") cryptocurrency_advanced_config = Configuration(cryptocurrency_advanced_config_dict) with Launcher(cryptocurrency_advanced_config) as launcher: launcher.deploy_all() launcher.wait_for_deploy() launcher.start_all() launcher.wait_for_start() # The changes restart the HTTP servers of the nodes, so we wait for the servers to restart. wait_network_to_start(self.network) for validator_id in range(self.network.validators_count()): host, public_port, private_port = self.network.api_address(validator_id) client = ExonumClient(host, public_port, private_port) available_services = client.public_api.available_services().json() service_status = find_service_status(available_services, "crypto") self.assertEqual(service_status, "stopped") with ExonumCryptoAdvancedClient(client) as crypto_client: alice_keys = KeyPair.generate() tx_response = crypto_client.create_wallet(alice_keys, "Alice" + str(validator_id)) # in case of stopped service its tx will not be processed self.assertEqual(tx_response.status_code, 400) self.assertIn("Cannot dispatch transaction to non-active service", str(tx_response.content)) # resume service instances = {"crypto": {"artifact": "cryptocurrency", "action": "resume"}} cryptocurrency_advanced_config_dict = generate_config(self.network, instances=instances, artifact_action="none") cryptocurrency_advanced_config = Configuration(cryptocurrency_advanced_config_dict) with Launcher(cryptocurrency_advanced_config) as launcher: launcher.deploy_all() launcher.wait_for_deploy() launcher.start_all() launcher.wait_for_start() # The changes restart the HTTP servers of the nodes, so we wait for the servers to restart. self.wait_for_api_restart() for validator_id in range(self.network.validators_count()): host, public_port, private_port = self.network.api_address(validator_id) client = ExonumClient(host, public_port, private_port) available_services = client.public_api.available_services().json() service_status = find_service_status(available_services, "crypto") self.assertEqual(service_status, "active") with ExonumCryptoAdvancedClient(client) as crypto_client: alice_keys = KeyPair.generate() tx_response = crypto_client.create_wallet(alice_keys, "Alice" + str(validator_id)) # resumed service must process txs as usual self.assertEqual(tx_response.status_code, 200)
def setUp(self): self.network = run_4_nodes("exonum-cryptocurrency-advanced") self.addCleanup(self._tear_down, False) wait_network_to_start(self.network)
def setUp(self): self.network = run_dev_node("vega-cryptocurrency-advanced") wait_network_to_start(self.network)