def getInitiatingCell(self): '''Build and return the initiating cell for this ntor fsm - a Create2Cell. Advance this ntor fsm's state. :returns: **oppy.cell.fixedlen.Create2Cell** ''' onion_skin = self._ntor_handshakes[0].createOnionSkin() cell = Create2Cell.make(self.circuit_id, hdata=onion_skin) self._state = State.EXPECT_CREATED2 return cell
def test_recvCell_non_backward_cell_fail(self, mock_logging): self.circuit._recvRelayCell = mock.Mock() self.circuit._pollReadQueue = mock.Mock() self.circuit._sendDestroyCell = mock.Mock() self.circuit._closeCircuit = mock.Mock() cell = Create2Cell.make(ID, hdata=84 * 'a') self.circuit._recvCell(cell) self.assertEqual(self.circuit._sendDestroyCell.call_count, 1) self.assertEqual(self.circuit._closeCircuit.call_count, 1) self.assertEqual(self.circuit._recvRelayCell.call_count, 0) self.assertEqual(self.circuit._pollReadQueue.call_count, 0) self.assertTrue(mock_logging.warning.called)
def test_recvCell_non_backward_cell_fail(self, mock_logging): self.circuit._recvRelayCell = mock.Mock() self.circuit._pollReadQueue = mock.Mock() self.circuit._sendDestroyCell = mock.Mock() self.circuit._closeCircuit = mock.Mock() cell = Create2Cell.make(ID, hdata=84*'a') self.circuit._recvCell(cell) self.assertEqual(self.circuit._sendDestroyCell.call_count, 1) self.assertEqual(self.circuit._closeCircuit.call_count, 1) self.assertEqual(self.circuit._recvRelayCell.call_count, 0) self.assertEqual(self.circuit._pollReadQueue.call_count, 0) self.assertTrue(mock_logging.warning.called)
def _sendCreate2Cell(self, _, path_node): self._hs_state = ntor.NTorState(path_node.microdescriptor) onion_skin = ntor.createOnionSkin(self._hs_state) create2 = Create2Cell.make(self.circuit_id, hdata=onion_skin) self._conn.send(create2)