def setUp(self): self.nodes = [] for s in largenetwork_setup.makeNodes(): newNode = node.Node(s) newNode.start() self.nodes.append(newNode) #Allow links to connect time.sleep(3)
def test_payerSide(self): 'Test behavior when no route is found on the payer side' log.log( '\n\n\n\nSCENARIO TEST: largenetwork_haveNoRoute.py test_payerSide\n' ) #Make a copy, where the link between 2 and 4 is broken: linkDefinitions = copy.deepcopy( largenetwork_setup.linkDefinitions_global) linkDefinitions[2].remove(4) linkDefinitions[4].remove(2) for s in largenetwork_setup.makeNodes(linkDefinitions): newNode = node.Node(s) newNode.start() self.nodes.append(newNode) #Allow links to connect time.sleep(3) self.checkCancelledState()
def test_payerSide(self): 'Test behavior when route times out on the payer side' log.log('\n\n\n\nSCENARIO TEST: largenetwork_routeTimeout.py test_payerSide\n') settings = largenetwork_setup.makeNodes() #Let node 2 ignore MakeRoute: with open(settings[2].stateFile, 'rb') as f: stateData = f.read() stateData = stateData.replace('NodeState', 'NodeState_IgnoreMakeRoute') with open(settings[2].stateFile, 'wb') as f: f.write(stateData) for s in settings: newNode = node.Node(s) newNode.start() self.nodes.append(newNode) #Allow links to connect time.sleep(3) self.checkCancelledState()
def test_lockDelay(self): 'Test behavior when the lock is delayed until after reservation time-out' log.log('\n\n\n\nSCENARIO TEST: largenetwork_lockDelay.py\n') settings = largenetwork_setup.makeNodes() #Let node 2 delay the Lock: with open(settings[2].stateFile, 'rb') as f: stateData = f.read() stateData = stateData.replace('NodeState', 'NodeState_LockDelay') with open(settings[2].stateFile, 'wb') as f: f.write(stateData) for s in settings: newNode = node.Node(s) newNode.start() self.nodes.append(newNode) #Allow links to connect time.sleep(3) self.checkCancelledState()
def test_noLock(self): 'Test behavior when no lock happens' log.log('\n\n\n\nSCENARIO TEST: largenetwork_noLock.py\n') settings = largenetwork_setup.makeNodes() #Let node 0 (the paying node) generate no lock: with open(settings[0].stateFile, 'rb') as f: stateData = f.read() stateData = stateData.replace('NodeState', 'NodeState_NoLock') with open(settings[0].stateFile, 'wb') as f: f.write(stateData) for s in settings: newNode = node.Node(s) newNode.start() self.nodes.append(newNode) #Allow links to connect time.sleep(3) self.checkCancelledState()
def test_noCommit(self): 'Test behavior when no commit happens' log.log('\n\n\n\nSCENARIO TEST: largenetwork_noCommit.py\n') settings = largenetwork_setup.makeNodes() #Let node 7 (the receiving node) generate no commit: with open(settings[7].stateFile, 'rb') as f: stateData = f.read() stateData = stateData.replace('NodeState', 'NodeState_NoCommit') with open(settings[7].stateFile, 'wb') as f: f.write(stateData) for s in settings: s.timeoutIncrement = 3 newNode = node.Node(s) newNode.start() self.nodes.append(newNode) #Allow links to connect time.sleep(3) self.checkCancelledState()
linknames = data['links'].keys() linkname = choiceInput(linknames, 'Choose a link to withdraw from') numChannels = len(data['links'][linkname]['channels']) channelID = choiceInput(range(numChannels), 'Channel index') if raw_input('Are you sure (y/n)? ') != 'y': print 'Aborted' return a.withdraw(linkname, channelID) else: print 'Unknown command. Enter \'help\' for a list of commands.' a = node.Node() a.start() print ''' Amiko Pay %s Copyright (C) 2013 - %s Enter 'help' for a list of commands. Enter 'license' for licensing information. ''' % (node.version, node.lastCopyrightYear) while True: cmd = raw_input('> ') try: handleCommand(cmd) except Exception as e: print str(e)
def setUp(self): settings1 = settings.Settings() settings1.name = 'Node 1' settings1.bitcoinRPCURL = 'dummy' settings1.listenHost = 'localhost' settings1.listenPort = 4322 settings1.advertizedHost = settings1.listenHost settings1.advertizedPort = settings1.listenPort settings1.stateFile = 'twonodes_1.dat' settings1.payLogFile = 'payments1.log' settings1.externalMeetingPoints = ['MeetingPoint2'] with open(settings1.stateFile, 'wb') as f: f.write(''' { "_class": "NodeState", "links": { "node1": { "_class": "Link", "channels": [ { "_class": "PlainChannel", "state": "open", "amountLocal": 1000, "amountRemote": 0, "transactionsIncomingLocked": {}, "transactionsOutgoingLocked": {}, "transactionsIncomingReserved": {}, "transactionsOutgoingReserved": {} } ], "localID": "node1", "remoteID": "node2" } }, "connections": { "node1": { "_class": "PersistentConnection", "connectMessage": { "_class": "ConnectLink", "ID": "node2", "callbackHost": "localhost", "callbackPort": 4322, "callbackID": "node1" }, "messages": [], "lastIndex": -1, "notYetTransmitted": 0, "host": "localhost", "port": 4323, "closing": false } }, "transactions": [], "meetingPoints": {}, "payeeLinks": {}, "payerLink": null, "timeoutMessages": [] } ''') self.node1 = node.Node(settings1) self.node1.start() settings2 = settings.Settings() settings2.name = 'Node 2' settings2.bitcoinRPCURL = 'dummy' settings2.listenHost = 'localhost' settings2.listenPort = 4323 settings2.advertizedHost = settings2.listenHost settings2.advertizedPort = settings2.listenPort settings2.stateFile = 'twonodes_2.dat' settings2.payLogFile = 'payments2.log' with open(settings2.stateFile, 'wb') as f: f.write(''' { "_class": "NodeState", "links": { "node2": { "_class": "Link", "channels": [ { "_class": "PlainChannel", "state": "open", "amountLocal": 0, "amountRemote": 1000, "transactionsIncomingLocked": {}, "transactionsOutgoingLocked": {}, "transactionsIncomingReserved": {}, "transactionsOutgoingReserved": {} } ], "localID": "node2", "remoteID": "node1" } }, "connections": { "node2": { "_class": "PersistentConnection", "connectMessage": { "_class": "ConnectLink", "ID": "node1", "callbackHost": "localhost", "callbackPort": 4323, "callbackID": "node2" }, "messages": [], "lastIndex": -1, "notYetTransmitted": 0, "host": "localhost", "port": 4322, "closing": false } }, "transactions": [], "meetingPoints": {"MeetingPoint2": {"_class": "MeetingPoint", "transactions": {}, "ID": "MeetingPoint2"}}, "payeeLinks": {}, "payerLink": null, "timeoutMessages": [] } ''') self.node2 = node.Node(settings2) self.node2.start() #Allow links to connect time.sleep(3)