Commit fd11d103 authored by Grégory Wisniewski's avatar Grégory Wisniewski

Use more getFakeConnection() to build a clean mock object.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2055 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 7b66b2c2
...@@ -149,10 +149,14 @@ class NeoTestBase(unittest.TestCase): ...@@ -149,10 +149,14 @@ class NeoTestBase(unittest.TestCase):
uuids = self.getNewUUID(), self.getNewUUID() uuids = self.getNewUUID(), self.getNewUUID()
return min(uuids), max(uuids) return min(uuids), max(uuids)
def getFakeConnection(self, uuid=None, address=('127.0.0.1', 10000)): def getFakeConnection(self, uuid=None, address=('127.0.0.1', 10000),
is_server=False):
return Mock({ return Mock({
'getUUID': uuid, 'getUUID': uuid,
'getAddress': address, 'getAddress': address,
'isServer': is_server,
'__repr__': 'FakeConnection',
'__nonzero__': 0,
}) })
def checkProtocolErrorRaised(self, method, *args, **kwargs): def checkProtocolErrorRaised(self, method, *args, **kwargs):
......
...@@ -62,11 +62,8 @@ class MasterClientElectionTests(NeoTestBase): ...@@ -62,11 +62,8 @@ class MasterClientElectionTests(NeoTestBase):
def identifyToMasterNode(self): def identifyToMasterNode(self):
node = self.app.nm.getMasterList()[0] node = self.app.nm.getMasterList()[0]
node.setUUID(self.getNewUUID()) node.setUUID(self.getNewUUID())
conn = Mock({ conn = self.getFakeConnection(uuid=node.getUUID(),
"getUUID": node.getUUID(), address=node.getAddress())
"getAddress": node.getAddress(),
"getConnector": Mock(),
})
return (node, conn) return (node, conn)
def _checkUnconnected(self, node): def _checkUnconnected(self, node):
......
...@@ -49,43 +49,31 @@ class StorageInitializationHandlerTests(NeoTestBase): ...@@ -49,43 +49,31 @@ class StorageInitializationHandlerTests(NeoTestBase):
def getLastUUID(self): def getLastUUID(self):
return self.uuid return self.uuid
def getClientConnection(self):
address = ("127.0.0.1", self.client_port)
return self.getFakeConnection(uuid=self.getNewUUID(), address=address)
def test_02_timeoutExpired(self): def test_02_timeoutExpired(self):
# client connection conn = self.getClientConnection()
uuid = self.getNewUUID()
conn = Mock({"getUUID" : uuid,
"getAddress" : ("127.0.0.1", self.client_port),
"isServer" : False})
self.assertRaises(PrimaryFailure, self.verification.timeoutExpired, conn,) self.assertRaises(PrimaryFailure, self.verification.timeoutExpired, conn,)
# nothing happens # nothing happens
self.checkNoPacketSent(conn) self.checkNoPacketSent(conn)
def test_03_connectionClosed(self): def test_03_connectionClosed(self):
# client connection conn = self.getClientConnection()
uuid = self.getNewUUID()
conn = Mock({"getUUID" : uuid,
"getAddress" : ("127.0.0.1", self.client_port),
"isServer" : False})
self.assertRaises(PrimaryFailure, self.verification.connectionClosed, conn,) self.assertRaises(PrimaryFailure, self.verification.connectionClosed, conn,)
# nothing happens # nothing happens
self.checkNoPacketSent(conn) self.checkNoPacketSent(conn)
def test_04_peerBroken(self): def test_04_peerBroken(self):
# client connection conn = self.getClientConnection()
uuid = self.getNewUUID()
conn = Mock({"getUUID" : uuid,
"getAddress" : ("127.0.0.1", self.client_port),
"isServer" : False})
self.assertRaises(PrimaryFailure, self.verification.peerBroken, conn,) self.assertRaises(PrimaryFailure, self.verification.peerBroken, conn,)
# nothing happens # nothing happens
self.checkNoPacketSent(conn) self.checkNoPacketSent(conn)
def test_09_sendPartitionTable(self): def test_09_sendPartitionTable(self):
uuid = self.getNewUUID()
# send a table # send a table
conn = Mock({"getUUID" : uuid, conn = self.getClientConnection()
"getAddress" : ("127.0.0.1", self.client_port),
"isServer" : False})
self.app.pt = PartitionTable(3, 2) self.app.pt = PartitionTable(3, 2)
node_1 = self.getNewUUID() node_1 = self.getNewUUID()
node_2 = self.getNewUUID() node_2 = self.getNewUUID()
......
...@@ -29,10 +29,7 @@ from neo.protocol import INVALID_TID, INVALID_OID ...@@ -29,10 +29,7 @@ from neo.protocol import INVALID_TID, INVALID_OID
class StorageMasterHandlerTests(NeoTestBase): class StorageMasterHandlerTests(NeoTestBase):
def checkHandleUnexpectedPacket(self, _call, _msg_type, _listening=True, **kwargs): def checkHandleUnexpectedPacket(self, _call, _msg_type, _listening=True, **kwargs):
conn = Mock({ conn = self.getMasterConnection(is_server=_listening)
"getAddress" : ("127.0.0.1", self.master_port),
"isServer": _listening,
})
# hook # hook
self.operation.peerBroken = lambda c: c.peerBrokendCalled() self.operation.peerBroken = lambda c: c.peerBrokendCalled()
self.checkUnexpectedPacketRaised(_call, conn=conn, **kwargs) self.checkUnexpectedPacketRaised(_call, conn=conn, **kwargs)
...@@ -58,41 +55,32 @@ class StorageMasterHandlerTests(NeoTestBase): ...@@ -58,41 +55,32 @@ class StorageMasterHandlerTests(NeoTestBase):
def tearDown(self): def tearDown(self):
NeoTestBase.tearDown(self) NeoTestBase.tearDown(self)
def getMasterConnection(self):
address = ("127.0.0.1", self.master_port)
return self.getFakeConnection(uuid=self.master_uuid, address=address)
def test_06_timeoutExpired(self): def test_06_timeoutExpired(self):
# client connection # client connection
conn = Mock({ conn = self.getMasterConnection()
"getUUID": self.master_uuid,
"getAddress" : ("127.0.0.1", self.master_port),
})
self.assertRaises(PrimaryFailure, self.operation.timeoutExpired, conn) self.assertRaises(PrimaryFailure, self.operation.timeoutExpired, conn)
self.checkNoPacketSent(conn) self.checkNoPacketSent(conn)
def test_07_connectionClosed2(self): def test_07_connectionClosed2(self):
# primary has closed the connection # primary has closed the connection
conn = Mock({ conn = self.getMasterConnection()
"getUUID": self.master_uuid,
"getAddress" : ("127.0.0.1", self.master_port),
})
self.assertRaises(PrimaryFailure, self.operation.connectionClosed, conn) self.assertRaises(PrimaryFailure, self.operation.connectionClosed, conn)
self.checkNoPacketSent(conn) self.checkNoPacketSent(conn)
def test_08_peerBroken(self): def test_08_peerBroken(self):
# client connection # client connection
conn = Mock({ conn = self.getMasterConnection()
"getUUID": self.master_uuid,
"getAddress" : ("127.0.0.1", self.master_port),
})
self.assertRaises(PrimaryFailure, self.operation.peerBroken, conn) self.assertRaises(PrimaryFailure, self.operation.peerBroken, conn)
self.checkNoPacketSent(conn) self.checkNoPacketSent(conn)
def test_14_notifyPartitionChanges1(self): def test_14_notifyPartitionChanges1(self):
# old partition change -> do nothing # old partition change -> do nothing
app = self.app app = self.app
conn = Mock({ conn = self.getMasterConnection()
"isServer": False,
"getAddress" : ("127.0.0.1", self.master_port),
})
app.replicator = Mock({}) app.replicator = Mock({})
self.app.pt = Mock({'getID': 1}) self.app.pt = Mock({'getID': 1})
count = len(self.app.nm.getList()) count = len(self.app.nm.getList())
...@@ -113,10 +101,7 @@ class StorageMasterHandlerTests(NeoTestBase): ...@@ -113,10 +101,7 @@ class StorageMasterHandlerTests(NeoTestBase):
(2, uuid3, CellStates.OUT_OF_DATE), (2, uuid3, CellStates.OUT_OF_DATE),
) )
# context # context
conn = Mock({ conn = self.getMasterConnection()
"isServer": False,
"getAddress" : ("127.0.0.1", self.master_port),
})
app = self.app app = self.app
# register nodes # register nodes
app.nm.createStorage(uuid=uuid1) app.nm.createStorage(uuid=uuid1)
......
...@@ -52,43 +52,34 @@ class StorageVerificationHandlerTests(NeoTestBase): ...@@ -52,43 +52,34 @@ class StorageVerificationHandlerTests(NeoTestBase):
def getLastUUID(self): def getLastUUID(self):
return self.uuid return self.uuid
def getClientConnection(self):
address = ("127.0.0.1", self.client_port)
return self.getFakeConnection(uuid=self.getNewUUID(), address=address)
def getMasterConnection(self):
return self.getFakeConnection(address=("127.0.0.1", self.master_port))
# Tests # Tests
def test_02_timeoutExpired(self): def test_02_timeoutExpired(self):
# client connection conn = self.getClientConnection()
uuid = self.getNewUUID()
conn = Mock({"getUUID" : uuid,
"getAddress" : ("127.0.0.1", self.client_port),
"isServer" : False})
self.assertRaises(PrimaryFailure, self.verification.timeoutExpired, conn,) self.assertRaises(PrimaryFailure, self.verification.timeoutExpired, conn,)
# nothing happens # nothing happens
self.checkNoPacketSent(conn) self.checkNoPacketSent(conn)
def test_03_connectionClosed(self): def test_03_connectionClosed(self):
# client connection conn = self.getClientConnection()
uuid = self.getNewUUID()
conn = Mock({"getUUID" : uuid,
"getAddress" : ("127.0.0.1", self.client_port),
"isServer" : False})
self.assertRaises(PrimaryFailure, self.verification.connectionClosed, conn,) self.assertRaises(PrimaryFailure, self.verification.connectionClosed, conn,)
# nothing happens # nothing happens
self.checkNoPacketSent(conn) self.checkNoPacketSent(conn)
def test_04_peerBroken(self): def test_04_peerBroken(self):
# client connection conn = self.getClientConnection()
uuid = self.getNewUUID()
conn = Mock({"getUUID" : uuid,
"getAddress" : ("127.0.0.1", self.client_port),
"isServer" : False})
self.assertRaises(PrimaryFailure, self.verification.peerBroken, conn,) self.assertRaises(PrimaryFailure, self.verification.peerBroken, conn,)
# nothing happens # nothing happens
self.checkNoPacketSent(conn) self.checkNoPacketSent(conn)
def test_07_askLastIDs(self): def test_07_askLastIDs(self):
uuid = self.getNewUUID() conn = self.getClientConnection()
# return invalid if db store nothing
conn = Mock({"getUUID" : uuid,
"getAddress" : ("127.0.0.1", self.client_port),
"isServer" : False})
last_ptid = '\x01' * 8 last_ptid = '\x01' * 8
last_oid = '\x02' * 8 last_oid = '\x02' * 8
self.app.pt = Mock({'getID': last_ptid}) self.app.pt = Mock({'getID': last_ptid})
...@@ -100,9 +91,7 @@ class StorageVerificationHandlerTests(NeoTestBase): ...@@ -100,9 +91,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
# return value stored in db # return value stored in db
# insert some oid # insert some oid
conn = Mock({"getUUID" : uuid, conn = self.getClientConnection()
"getAddress" : ("127.0.0.1", self.client_port),
"isServer" : False})
self.app.dm.begin() self.app.dm.begin()
self.app.dm.query("""insert into obj (oid, serial, compression, self.app.dm.query("""insert into obj (oid, serial, compression,
checksum, value) values (3, 'A', 0, 0, '')""") checksum, value) values (3, 'A', 0, 0, '')""")
...@@ -132,14 +121,11 @@ class StorageVerificationHandlerTests(NeoTestBase): ...@@ -132,14 +121,11 @@ class StorageVerificationHandlerTests(NeoTestBase):
self.assertEqual(ptid, self.app.pt.getID()) self.assertEqual(ptid, self.app.pt.getID())
def test_08_askPartitionTable(self): def test_08_askPartitionTable(self):
uuid = self.getNewUUID()
# try to get unknown offset # try to get unknown offset
self.assertEqual(len(self.app.pt.getNodeList()), 0) self.assertEqual(len(self.app.pt.getNodeList()), 0)
self.assertFalse(self.app.pt.hasOffset(1)) self.assertFalse(self.app.pt.hasOffset(1))
self.assertEqual(len(self.app.pt.getCellList(1)), 0) self.assertEqual(len(self.app.pt.getCellList(1)), 0)
conn = Mock({"getUUID" : uuid, conn = self.getClientConnection()
"getAddress" : ("127.0.0.1", self.client_port),
"isServer" : False})
self.verification.askPartitionTable(conn, [1]) self.verification.askPartitionTable(conn, [1])
ptid, row_list = self.checkAnswerPartitionTable(conn, decode=True) ptid, row_list = self.checkAnswerPartitionTable(conn, decode=True)
self.assertEqual(len(row_list), 1) self.assertEqual(len(row_list), 1)
...@@ -154,9 +140,7 @@ class StorageVerificationHandlerTests(NeoTestBase): ...@@ -154,9 +140,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
) )
self.app.pt.setCell(1, node, CellStates.UP_TO_DATE) self.app.pt.setCell(1, node, CellStates.UP_TO_DATE)
self.assertTrue(self.app.pt.hasOffset(1)) self.assertTrue(self.app.pt.hasOffset(1))
conn = Mock({"getUUID" : uuid, conn = self.getClientConnection()
"getAddress" : ("127.0.0.1", self.client_port),
"isServer" : False})
self.verification.askPartitionTable(conn, [1]) self.verification.askPartitionTable(conn, [1])
ptid, row_list = self.checkAnswerPartitionTable(conn, decode=True) ptid, row_list = self.checkAnswerPartitionTable(conn, decode=True)
self.assertEqual(len(row_list), 1) self.assertEqual(len(row_list), 1)
...@@ -166,19 +150,13 @@ class StorageVerificationHandlerTests(NeoTestBase): ...@@ -166,19 +150,13 @@ class StorageVerificationHandlerTests(NeoTestBase):
def test_10_notifyPartitionChanges(self): def test_10_notifyPartitionChanges(self):
# old partition change # old partition change
conn = Mock({ conn = self.getMasterConnection()
"isServer": False,
"getAddress" : ("127.0.0.1", self.master_port),
})
self.verification.notifyPartitionChanges(conn, 1, ()) self.verification.notifyPartitionChanges(conn, 1, ())
self.verification.notifyPartitionChanges(conn, 0, ()) self.verification.notifyPartitionChanges(conn, 0, ())
self.assertEqual(self.app.pt.getID(), 1) self.assertEqual(self.app.pt.getID(), 1)
# new node # new node
conn = Mock({ conn = self.getMasterConnection()
"isServer": False,
"getAddress" : ("127.0.0.1", self.master_port),
})
new_uuid = self.getNewUUID() new_uuid = self.getNewUUID()
cell = (0, new_uuid, CellStates.UP_TO_DATE) cell = (0, new_uuid, CellStates.UP_TO_DATE)
self.app.nm.createStorage(uuid=new_uuid) self.app.nm.createStorage(uuid=new_uuid)
...@@ -194,21 +172,18 @@ class StorageVerificationHandlerTests(NeoTestBase): ...@@ -194,21 +172,18 @@ class StorageVerificationHandlerTests(NeoTestBase):
self.assertEquals(calls[0].getParam(1), (cell, )) self.assertEquals(calls[0].getParam(1), (cell, ))
def test_11_startOperation(self): def test_11_startOperation(self):
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port), conn = self.getMasterConnection()
'isServer': False })
self.assertFalse(self.app.operational) self.assertFalse(self.app.operational)
self.verification.startOperation(conn) self.verification.startOperation(conn)
self.assertTrue(self.app.operational) self.assertTrue(self.app.operational)
def test_12_stopOperation(self): def test_12_stopOperation(self):
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port), conn = self.getMasterConnection()
'isServer': False })
self.assertRaises(OperationFailure, self.verification.stopOperation, conn) self.assertRaises(OperationFailure, self.verification.stopOperation, conn)
def test_13_askUnfinishedTransactions(self): def test_13_askUnfinishedTransactions(self):
# client connection with no data # client connection with no data
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port), conn = self.getMasterConnection()
'isServer': False})
self.verification.askUnfinishedTransactions(conn) self.verification.askUnfinishedTransactions(conn)
(tid_list, ) = self.checkAnswerUnfinishedTransactions(conn, decode=True) (tid_list, ) = self.checkAnswerUnfinishedTransactions(conn, decode=True)
self.assertEqual(len(tid_list), 0) self.assertEqual(len(tid_list), 0)
...@@ -218,8 +193,7 @@ class StorageVerificationHandlerTests(NeoTestBase): ...@@ -218,8 +193,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
self.app.dm.query("""insert into tobj (oid, serial, compression, self.app.dm.query("""insert into tobj (oid, serial, compression,
checksum, value) values (0, 4, 0, 0, '')""") checksum, value) values (0, 4, 0, 0, '')""")
self.app.dm.commit() self.app.dm.commit()
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port), conn = self.getMasterConnection()
'isServer': False})
self.verification.askUnfinishedTransactions(conn) self.verification.askUnfinishedTransactions(conn)
(tid_list, ) = self.checkAnswerUnfinishedTransactions(conn, decode=True) (tid_list, ) = self.checkAnswerUnfinishedTransactions(conn, decode=True)
self.assertEqual(len(tid_list), 1) self.assertEqual(len(tid_list), 1)
...@@ -227,8 +201,7 @@ class StorageVerificationHandlerTests(NeoTestBase): ...@@ -227,8 +201,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
def test_14_askTransactionInformation(self): def test_14_askTransactionInformation(self):
# ask from client conn with no data # ask from client conn with no data
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port), conn = self.getMasterConnection()
'isServer': False })
self.verification.askTransactionInformation(conn, p64(1)) self.verification.askTransactionInformation(conn, p64(1))
code, message = self.checkErrorPacket(conn, decode=True) code, message = self.checkErrorPacket(conn, decode=True)
self.assertEqual(code, ErrorCodes.TID_NOT_FOUND) self.assertEqual(code, ErrorCodes.TID_NOT_FOUND)
...@@ -241,8 +214,7 @@ class StorageVerificationHandlerTests(NeoTestBase): ...@@ -241,8 +214,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
description, ext) values (1,'%s', 'u2', 'd2', 'e2')""" %(p64(2),)) description, ext) values (1,'%s', 'u2', 'd2', 'e2')""" %(p64(2),))
self.app.dm.commit() self.app.dm.commit()
# object from trans # object from trans
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port), conn = self.getClientConnection()
'isServer': False })
self.verification.askTransactionInformation(conn, p64(1)) self.verification.askTransactionInformation(conn, p64(1))
tid, user, desc, ext, packed, oid_list = self.checkAnswerTransactionInformation(conn, decode=True) tid, user, desc, ext, packed, oid_list = self.checkAnswerTransactionInformation(conn, decode=True)
self.assertEqual(u64(tid), 1) self.assertEqual(u64(tid), 1)
...@@ -252,8 +224,7 @@ class StorageVerificationHandlerTests(NeoTestBase): ...@@ -252,8 +224,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
self.assertEqual(len(oid_list), 1) self.assertEqual(len(oid_list), 1)
self.assertEqual(u64(oid_list[0]), 2) self.assertEqual(u64(oid_list[0]), 2)
# object from ttrans # object from ttrans
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port), conn = self.getMasterConnection()
'isServer': False })
self.verification.askTransactionInformation(conn, p64(3)) self.verification.askTransactionInformation(conn, p64(3))
tid, user, desc, ext, packed, oid_list = self.checkAnswerTransactionInformation(conn, decode=True) tid, user, desc, ext, packed, oid_list = self.checkAnswerTransactionInformation(conn, decode=True)
self.assertEqual(u64(tid), 3) self.assertEqual(u64(tid), 3)
...@@ -264,8 +235,7 @@ class StorageVerificationHandlerTests(NeoTestBase): ...@@ -264,8 +235,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
self.assertEqual(u64(oid_list[0]), 4) self.assertEqual(u64(oid_list[0]), 4)
# input some tmp data and ask from server, must find one transaction # input some tmp data and ask from server, must find one transaction
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port), conn = self.getMasterConnection()
'isServer': True })
# find the one in trans # find the one in trans
self.verification.askTransactionInformation(conn, p64(1)) self.verification.askTransactionInformation(conn, p64(1))
tid, user, desc, ext, packed, oid_list = self.checkAnswerTransactionInformation(conn, decode=True) tid, user, desc, ext, packed, oid_list = self.checkAnswerTransactionInformation(conn, decode=True)
...@@ -276,16 +246,14 @@ class StorageVerificationHandlerTests(NeoTestBase): ...@@ -276,16 +246,14 @@ class StorageVerificationHandlerTests(NeoTestBase):
self.assertEqual(len(oid_list), 1) self.assertEqual(len(oid_list), 1)
self.assertEqual(u64(oid_list[0]), 2) self.assertEqual(u64(oid_list[0]), 2)
# do not find the one in ttrans # do not find the one in ttrans
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port), conn = self.getMasterConnection()
'isServer': True })
self.verification.askTransactionInformation(conn, p64(2)) self.verification.askTransactionInformation(conn, p64(2))
code, message = self.checkErrorPacket(conn, decode=True) code, message = self.checkErrorPacket(conn, decode=True)
self.assertEqual(code, ErrorCodes.TID_NOT_FOUND) self.assertEqual(code, ErrorCodes.TID_NOT_FOUND)
def test_15_askObjectPresent(self): def test_15_askObjectPresent(self):
# client connection with no data # client connection with no data
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port), conn = self.getMasterConnection()
'isServer': False})
self.verification.askObjectPresent(conn, p64(1), p64(2)) self.verification.askObjectPresent(conn, p64(1), p64(2))
code, message = self.checkErrorPacket(conn, decode=True) code, message = self.checkErrorPacket(conn, decode=True)
self.assertEqual(code, ErrorCodes.OID_NOT_FOUND) self.assertEqual(code, ErrorCodes.OID_NOT_FOUND)
...@@ -295,8 +263,7 @@ class StorageVerificationHandlerTests(NeoTestBase): ...@@ -295,8 +263,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
self.app.dm.query("""insert into tobj (oid, serial, compression, self.app.dm.query("""insert into tobj (oid, serial, compression,
checksum, value) values (1, 2, 0, 0, '')""") checksum, value) values (1, 2, 0, 0, '')""")
self.app.dm.commit() self.app.dm.commit()
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port), conn = self.getMasterConnection()
'isServer': False})
self.verification.askObjectPresent(conn, p64(1), p64(2)) self.verification.askObjectPresent(conn, p64(1), p64(2))
oid, tid = self.checkAnswerObjectPresent(conn, decode=True) oid, tid = self.checkAnswerObjectPresent(conn, decode=True)
self.assertEqual(u64(tid), 2) self.assertEqual(u64(tid), 2)
...@@ -304,8 +271,7 @@ class StorageVerificationHandlerTests(NeoTestBase): ...@@ -304,8 +271,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
def test_16_deleteTransaction(self): def test_16_deleteTransaction(self):
# client connection with no data # client connection with no data
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port), conn = self.getMasterConnection()
'isServer': False})
self.verification.deleteTransaction(conn, p64(1)) self.verification.deleteTransaction(conn, p64(1))
# client connection with data # client connection with data
self.app.dm.begin() self.app.dm.begin()
...@@ -318,8 +284,7 @@ class StorageVerificationHandlerTests(NeoTestBase): ...@@ -318,8 +284,7 @@ class StorageVerificationHandlerTests(NeoTestBase):
def test_17_commitTransaction(self): def test_17_commitTransaction(self):
# commit a transaction # commit a transaction
conn = Mock({ "getAddress" : ("127.0.0.1", self.master_port), conn = self.getMasterConnection()
'isServer': False })
dm = Mock() dm = Mock()
self.app.dm = dm self.app.dm = dm
self.verification.commitTransaction(conn, p64(1)) self.verification.commitTransaction(conn, p64(1))
......
...@@ -45,7 +45,7 @@ class HandlerTests(NeoTestBase): ...@@ -45,7 +45,7 @@ class HandlerTests(NeoTestBase):
self.assertEquals(len(calls), 1) self.assertEquals(len(calls), 1)
def test_dispatch(self): def test_dispatch(self):
conn = Mock({'getAddress': ('127.0.0.1', 10000)}) conn = self.getFakeConnection()
packet = self.getFakePacket() packet = self.getFakePacket()
# all is ok # all is ok
self.setFakeMethod(lambda c: None) self.setFakeMethod(lambda c: None)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment