to be honest, i don't get what you're trying to do here. if i may make a guess, you can't do it this way. capturing the actual traffic is not useful.
On Aug 17, 2012, at 9:20 AM, andrea crotti wrote: > It's starting to slowly make more sense (even if I'm far from > convinced), the following code for example has a protocol object that > takes a message, and knows how to serialise and unserialise. > > Usign a simple list I go over all the possible message types to > construct the right type, and potentially in the message types I can do > more fancy parsing.. > > The thing I don't understand now for example is how would I actually > convert automagically this code to be tested via SPIN? > Because here there still is no logic like "if get X answer Y to the > channel". > > I'm also thinking that even if not the same with heavy unit testing I > might even not need a real model checker, also because there might be > bugs in the conversion code -> SPIN, while unit tests run on actual > code. > > But in case I wanted that then I would need to pass the communication > channels to the protocol somehow, and not sure how I should do that, any > advice? > > > class Message: > def __init__(self, message): > self.message = message > > def dump(self): > return self.message > > def __eq__(self, other): > return self.message == other.message > > > class TaskStarting(Message): > key = 'T_START' > def __init__(self, message): > super(TaskStarting, self).__init__(message) > # create some extra fields from the message > > > class TaskOver(Message): > key = 'T_OVER' > > > > class WorkerSinkProtocol: > """Communication protocol to communicate between the worker and > the sink, sending results and the actual status. > TODO:Does it make sense to send also the actual status? > """ > ACTIONS = [TaskStarting, TaskOver] > > def __init__(self, message): > self.message = message > > def __eq__(self, other): > return self.message == other.message > > def serialise(self): > return DELIMITER.join([type(self.message).key, self.message.dump()]) > > @classmethod > def unserialise(cls, st): > act, msg = st.split(DELIMITER) > for a in cls.ACTIONS: > if a.key == act: > return cls(a(msg)) > _______________________________________________ > zeromq-dev mailing list > [email protected] > http://lists.zeromq.org/mailman/listinfo/zeromq-dev ------------------ Andrew Hume (best -> Telework) +1 623-551-2845 [email protected] (Work) +1 973-236-2014 AT&T Labs - Research; member of USENIX and LOPSA
_______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
