def test_start_private_geth(test_config_path, dbsession): """We can spawn a standalone private geth instance for private testnet.""" project_dir = os.getcwd() # Goes under "chains" # Use non-default port, so that we don't conflict with existing # test geth daemon geth = start_private_geth("foobar", project_dir, "127.0.0.1", 10010, p2p_port=40000) web3 = Web3(RPCProvider("127.0.0.1", 10010)) deadline = time.time() + 10 while time.time() < deadline: if not geth.is_alive: pytest.fail("geth died") try: web3.eth.coinbase geth.stop() return except Exception as e: print(e) time.sleep(1) geth.stop() pytest.fail("Could not connect to geth instance using a specific port")
def start_geth(self): if self.config["private_geth"]: chains_dir = self.request.registry.settings["ethereum.chains_dir"] host = self.config["host"] port = int(self.config["port"]) p2p_port = int(self.config.get("p2p_port", 30303)) # Start private geth instance to connect to chain_dir = os.path.join(chains_dir, self.name.replace(" ", "-")) geth = start_private_geth(self.name.replace(" ", "-"), chain_dir, host, port, p2p_port=p2p_port) time.sleep(2) # Give geth time to wake up else: geth = None return geth