#NEWLINE# def test_create_and_parse( self ) : #NEWLINE# #INDENT# ( nA , nB , entA , entB ) = self . make_connected_nodes ( ) #NEWLINE# cidAB = entA [ 'id' ] #NEWLINE# c = channel . OutboundChannel ( nA . db , cidAB ) #NEWLINE# payload = { #NEWLINE# #INDENT# 'hi' : 'there' , #NEWLINE# #UNINDENT# } #NEWLINE# msgC = c . createMsgC ( payload ) #NEWLINE# self . failUnless ( msgC . startswith ( 'c0:' ) ) #NEWLINE# ( CIDToken , CIDBox , msgD ) = channel . parse_msgC ( msgC ) #NEWLINE# CIDKey = entB [ 'my_CID_key' ] . decode ( 'hex' ) #NEWLINE# ( seqnum , HmsgD , channel_pubkey ) = channel . decrypt_CIDBox ( CIDKey , CIDBox ) #NEWLINE# self . failUnlessEqual ( HmsgD , sha256 ( msgD ) . digest ( ) ) #NEWLINE# Bkey = PrivateKey ( entB [ 'my_new_channel_privkey' ] . decode ( 'hex' ) ) #NEWLINE# keylist = [ ( Bkey , 'keyid' ) ] #NEWLINE# ( keyid , pubkey2_s , msgE ) = channel . decrypt_msgD ( msgD , keylist ) #NEWLINE# their_verfkey = entB [ 'their_verfkey' ] . decode ( 'hex' ) #NEWLINE# ( seqnum , payload2_s ) = channel . check_msgE ( msgE , pubkey2_s , their_verfkey , entB [ 'highest_inbound_seqnum' ] ) #NEWLINE# self . failUnlessEqual ( c , json . loads ( payload2_s ) )