예제 #1
0
	def test_commit(self):
		"Test msg_commit"

		t1 = DummyTransaction(
			amount=0, hash="hash", meetingPoint="meetingpoint", isPayerSide=True)
		t1.token = "token"
		t2 = DummyTransaction(
			amount=0, hash="hash", meetingPoint="meetingpoint", isPayerSide=False)
		self.mp.transactionPairs = {"hash": [t1, t2]}
		self.mp.msg_commit(t1)
		self.assertEqual(self.mp.transactionPairs, {})
		self.assertEqual(t1.trace, [])
		self.assertEqual(t2.trace, [
			('msg_commit', ("token",), {})
			])
예제 #2
0
	def test_makeRoute_payeeFirst(self):
		"Test msg_makeRoute (payee message arrives first)"

		t1 = DummyTransaction(
			amount=0, hash="hash", meetingPoint="meetingpoint", isPayerSide=False)
		self.mp.msg_makeRoute(t1)
		self.assertEqual(self.mp.transactionPairs, {"hash": [None, t1]})
		self.assertEqual(t1.trace, [])

		t1.trace = []
		t2 = DummyTransaction(
			amount=0, hash="hash", meetingPoint="meetingpoint", isPayerSide=True)
		self.mp.msg_makeRoute(t2)
		self.assertEqual(self.mp.transactionPairs, {"hash": [t2, t1]})
		self.assertEqual(t1.trace, [
			('msg_haveRoute', (self.mp, 12, 34), {})
			])
		self.assertEqual(t2.trace, [
			('msg_haveRoute', (self.mp, 12, 34), {})
			])
예제 #3
0
	def test_makeRoute_amountMismatch(self):
		"Test msg_makeRoute (payer message arrives first)"

		t1 = DummyTransaction(
			amount=100, hash="hash", meetingPoint="meetingpoint", isPayerSide=True)
		self.mp.msg_makeRoute(t1)
		self.assertEqual(self.mp.transactionPairs, {"hash": [t1, None]})
		self.assertEqual(t1.trace, [])

		t1.trace = []
		t2 = DummyTransaction(
			amount=101, hash="hash", meetingPoint="meetingpoint", isPayerSide=False)
		self.mp.msg_makeRoute(t2)
		self.assertEqual(self.mp.transactionPairs, {})
		self.assertEqual(t1.trace, [
			('msg_cancelRoute', (), {})
			])
		self.assertEqual(t2.trace, [
			('msg_cancelRoute', (), {})
			])
예제 #4
0
	def test_makeRoute_payeeTwice(self):
		"Test msg_makeRoute (payee message arrives twice)"

		t1 = DummyTransaction(
			amount=0, hash="hash", meetingPoint="meetingpoint", isPayerSide=False)
		self.mp.msg_makeRoute(t1)
		self.assertEqual(self.mp.transactionPairs, {"hash": [None, t1]})
		self.assertEqual(t1.trace, [])

		t1.trace = []
		t2 = DummyTransaction(
			amount=0, hash="hash", meetingPoint="meetingpoint", isPayerSide=False)
		self.mp.msg_makeRoute(t2)
		self.assertEqual(self.mp.transactionPairs, {})
		self.assertEqual(t1.trace, [
			('msg_cancelRoute', (), {})
			])
		self.assertEqual(t2.trace, [
			('msg_cancelRoute', (), {})
			])