Changeset 215 for trunk/pyopencoin/oc/protocols.py
- Timestamp:
- 03/16/08 21:29:30 (4 years ago)
- Files:
-
- 1 modified
-
trunk/pyopencoin/oc/protocols.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pyopencoin/oc/protocols.py
r211 r215 72 72 def initiateHandshake(self,message): 73 73 self.newState(self.verifyHandshake) 74 return Message('HANDSHAKE', {'protocol': 'opencoin 1.0'})74 return Message('HANDSHAKE',[['protocol', 'opencoin 1.0']]) 75 75 76 76 def verifyHandshake(self, message): 77 77 if message.type == 'HANDSHAKE_ACCEPT': 78 78 self.newState(self.firstStep) 79 # FIXME: If we have handshakes that return things, we need to check for them here 79 80 return self.firstStep(message) 80 81 … … 101 102 def start(self,message): 102 103 if message.type == 'HANDSHAKE': 103 if message.data['protocol'] == 'opencoin 1.0': 104 105 # NOTE: We do not do set up the newState. If this fails, it comes right back to handshakes 106 if not isinstance(message.data, types.ListType): 107 return ProtocolErrorMessage('aHP') 108 109 for var in message.data: 110 try: 111 key, value = var 112 except ValueError: 113 return ProtocolErrorMessage('aHP') 114 115 if not message.data: 116 return ProtocolErrorMessage('aHP') 117 118 # Make a dictionary of options in the handshake 119 120 options = {} 121 for var in message.data: 122 key, value = var 123 if key in options: 124 raise ProtocolErrorMessage('aHP') 125 126 options[key] = value 127 128 # FIXME: If we allow opencoin 1.0+, we need to check for that as well 129 if options['protocol'] == 'opencoin 1.0': 104 130 # Set up a state where the handshake no longer is needed. 105 131 self.old_start = self.start … … 140 166 >>> css = TokenSpendSender([coin1,coin2],'foobar') 141 167 >>> css.state(Message(None)) 142 <Message('HANDSHAKE', {'protocol': 'opencoin 1.0'})>168 <Message('HANDSHAKE',[['protocol', 'opencoin 1.0']])> 143 169 >>> css.state(Message('HANDSHAKE_ACCEPT',None)) 144 170 <Message('SUM_ANNOUNCE',['...', '3', 'foobar'])> … … 378 404 >>> tts = TransferTokenSender('my account',[],[coin1, coin2],type='redeem') 379 405 >>> tts.state(Message(None)) 380 <Message('HANDSHAKE', {'protocol': 'opencoin 1.0'})>406 <Message('HANDSHAKE',[['protocol', 'opencoin 1.0']])> 381 407 >>> tts.state(Message('HANDSHAKE_ACCEPT',None)) 382 408 <Message('TRANSFER_TOKEN_REQUEST',['...', 'my account', [], [[(...)], [(...)]], [['type', 'redeem']]])> … … 874 900 >>> fmp = fetchMintKeyProtocol(denominations=['1']) 875 901 >>> fmp.state(Message(None)) 876 <Message('HANDSHAKE', {'protocol': 'opencoin 1.0'})>902 <Message('HANDSHAKE',[['protocol', 'opencoin 1.0']])> 877 903 >>> fmp.state(Message('HANDSHAKE_ACCEPT',None)) 878 904 <Message('MINT_KEY_FETCH_DENOMINATION',[['1'], '0'])> … … 892 918 >>> fmp = fetchMintKeyProtocol(keyids=['sj17RxE1hfO06+oTgBs9Z7xLut/3NN+nHJbXSJYTks0=']) 893 919 >>> fmp.state(Message(None)) 894 <Message('HANDSHAKE', {'protocol': 'opencoin 1.0'})>920 <Message('HANDSHAKE',[['protocol', 'opencoin 1.0']])> 895 921 >>> fmp.state(Message('HANDSHAKE_ACCEPT')) 896 922 <Message('MINT_KEY_FETCH_KEYID',['sj17RxE1hfO06+oTgBs9Z7xLut/3NN+nHJbXSJYTks0='])>
