コード例 #1
0
ファイル: test_link.py プロジェクト: MKTHINGS/amiko-pay
    def test_haveRouteIncoming(self):
        'test haveRouteIncoming'

        msg_in = messages.HaveRoute(ID=None,
                                    transactionID='foobar',
                                    isPayerSide=True,
                                    startTime=123,
                                    endTime=456)

        self.link.channels.append(DummyChannel())
        self.link.channels.append(DummyChannel())

        self.assertRaises(Exception, self.link.haveRouteIncoming, msg_in)
        self.link.channels[0].state = []
        self.link.channels[1].state = []

        self.link.channels[1].hasRouteReturn = True

        ret = self.link.haveRouteIncoming(msg_in)

        self.assertEqual(ret, [])

        self.assertEqual(self.link.channels[0].state, ['1foobar'])

        self.assertEqual(self.link.channels[1].state, [
            '1foobar', ('updateReservation', (True, '1foobar', 123, 456), {})
        ])
コード例 #2
0
ファイル: test_payerlink.py プロジェクト: MKTHINGS/amiko-pay
    def test_haveRouteIncoming(self):
        "Test haveRouteIncoming)"

        self.payerLink.amount = 123

        self.assertRaises(
            Exception, self.payerLink.haveRouteIncoming,
            messages.HaveRoute(ID=messages.payerLocalID,
                               transactionID=self.payerLink.transactionID,
                               isPayerSide=False))

        self.payerLink.state = payerlink.PayerLink.states.confirmed

        ret = self.payerLink.haveRouteIncoming(
            messages.HaveRoute(ID=messages.payerLocalID,
                               transactionID=self.payerLink.transactionID,
                               isPayerSide=False))

        self.assertEqual(self.payerLink.state,
                         payerlink.PayerLink.states.hasPayeeRoute)

        self.assertEqual(len(ret), 0)

        self.payerLink.state = payerlink.PayerLink.states.hasPayerRoute

        ret = self.payerLink.haveRouteIncoming(
            messages.HaveRoute(ID=messages.payerLocalID,
                               transactionID=self.payerLink.transactionID,
                               isPayerSide=False))

        self.assertEqual(self.payerLink.state,
                         payerlink.PayerLink.states.locked)

        self.assertEqual(len(ret), 1)
        msg = ret[0]
        self.assertTrue(isinstance(msg, messages.Lock))
        self.assertEqual(msg.transactionID, self.payerLink.transactionID)
        self.assertEqual(msg.isPayerSide, True)
        self.assertEqual(msg.amount, 123)
コード例 #3
0
ファイル: test_payeelink.py プロジェクト: MKTHINGS/amiko-pay
	def test_haveRouteOutgoing(self):
		"Test haveRouteOutgoing"

		ret = self.payeeLink.haveRouteOutgoing(
			messages.HaveRoute(ID="foobar", transactionID="bar", isPayerSide=False))

		self.assertEqual(len(ret), 1)
		msg = ret[0]
		self.assertTrue(isinstance(msg, messages.OutboundMessage))
		self.assertEqual(msg.localID, "foobar")
		msg = msg.message
		self.assertTrue(isinstance(msg, messages.HaveRoute))
		self.assertEqual(msg.transactionID, None)
		self.assertEqual(msg.isPayerSide, False)
コード例 #4
0
ファイル: test_link.py プロジェクト: MKTHINGS/amiko-pay
    def test_haveRouteOutgoing(self):
        'test haveRouteOutgoing'

        msg_in = messages.HaveRoute(ID=None,
                                    transactionID='foobar',
                                    isPayerSide=True,
                                    startTime=123,
                                    endTime=456)

        self.link.channels.append(DummyChannel())
        self.link.channels.append(DummyChannel())

        self.assertRaises(Exception, self.link.haveRouteOutgoing, msg_in)
        self.link.channels[0].state = []
        self.link.channels[1].state = []

        self.link.channels[1].hasRouteReturn = True

        ret = self.link.haveRouteOutgoing(msg_in)

        self.assertEqual(len(ret), 1)
        msg = ret[0]
        self.assertTrue(isinstance(msg, messages.OutboundMessage))
        self.assertEqual(msg.localID, 'local')
        msg = msg.message
        self.assertFalse(msg is msg_in)
        self.assertTrue(isinstance(msg, messages.HaveRoute))
        self.assertEqual(msg.ID, 'remote')
        self.assertEqual(msg.transactionID, msg_in.transactionID)
        self.assertEqual(msg.isPayerSide, msg_in.isPayerSide)
        self.assertEqual(msg.startTime, msg_in.startTime)
        self.assertEqual(msg.endTime, msg_in.endTime)

        self.assertEqual(self.link.channels[0].state, ['1foobar'])

        self.assertEqual(self.link.channels[1].state, [
            '1foobar', ('updateReservation', (False, '1foobar', 123, 456), {})
        ])