def testCreateAgentDoesNotAllocatePort(tdirWithPoolTxns): for i in range(2): checkPortAvailable(HA("0.0.0.0", agentPort)) agent = getNewAgent("Agent0", tdirWithPoolTxns, agentPort, agentWallet()) checkPortAvailable(HA("0.0.0.0", agentPort)) agent.stop()
def testAgentUsesRestoredWalletIfItHas(poolNodesStarted, emptyLooper, tdirWithClientPoolTxns, agentAddedBySponsor, agentStarted): agent, wallet = agentStarted changeAndPersistWallet(agent, emptyLooper) newAgent = getNewAgent(agent.name, tdirWithClientPoolTxns, agentPort, agentWallet()) assert newAgent._wallet.idsToSigners == {}
def testAgentUsesRestoredWalletIfItHas( poolNodesStarted, emptyLooper, tdirWithClientPoolTxns, agentAddedBySponsor, agentStarted): agent, wallet = agentStarted changeAndPersistWallet(agent, emptyLooper) newAgent = getNewAgent(agent.name, tdirWithClientPoolTxns, agentPort, agentWallet()) assert newAgent._wallet.idsToSigners == {}
def testStartAgentChecksForPortAvailability(poolNodesStarted, tdirWithClientPoolTxns, emptyLooper, agentAddedBySponsor): newAgentName1 = "Agent11" newAgentName2 = "Agent12" with pytest.raises(PortNotAvailable): agent = getNewAgent(newAgentName1, tdirWithClientPoolTxns, agentPort, agentWallet()) runAgent(emptyLooper, tdirWithClientPoolTxns, agentPort, name=newAgentName2) runAgent(emptyLooper, tdirWithClientPoolTxns, agentPort, name=newAgentName1, agent=agent) stopAgent(emptyLooper, newAgentName2)
def testStartAgentChecksForPortAvailability(poolNodesStarted, tdirWithPoolTxns, emptyLooper, agentAddedBySponsor): newAgentName1 = "Agent11" newAgentName2 = "Agent12" with pytest.raises(PortNotAvailable): agent = getNewAgent(newAgentName1, tdirWithPoolTxns, agentPort, agentWallet()) runAgent(emptyLooper, tdirWithPoolTxns, agentPort, name=newAgentName2) runAgent(emptyLooper, tdirWithPoolTxns, agentPort, name=newAgentName1, agent=agent) stopAgent(emptyLooper, newAgentName2)
def runAgent(looper, basedir, port, name=None, agent=None): wallet = agentWallet() wallet.name = name name = name or "Agent" + randomString(5) agent = agent or getNewAgent(name, basedir, port, wallet) return startAgent(looper, agent, wallet)
def runAgent(looper, basedir, port, name=None, agent=None): wallet = agentWallet() name = name or "Agent" + randomString(5) agent = agent or getNewAgent(name, basedir, port, wallet) agent._name = name return startAgent(looper, agent, wallet, bootstrap_agent(agent))