#NEWLINE# def test_rpc_store( self ) : #NEWLINE# #INDENT# self . _connecting_to_connected ( ) #NEWLINE# self . protocol . router . addContact ( self . protocol . sourceNode ) #NEWLINE# m = message . Message ( ) #NEWLINE# m . messageID = digest ( 'msgid' ) #NEWLINE# m . sender . MergeFrom ( self . protocol . sourceNode . getProto ( ) ) #NEWLINE# m . command = message . Command . Value ( 'STORE' ) #NEWLINE# m . protoVer = self . version #NEWLINE# m . testnet = False #NEWLINE# m . arguments . extend ( [ digest ( 'Keyword' ) , 'Key' , self . protocol . sourceNode . getProto ( ) . SerializeToString ( ) , str ( 10 ) ] ) #NEWLINE# m . signature = self . signing_key . sign ( m . SerializeToString ( ) ) [ : 64 ] #NEWLINE# data = m . SerializeToString ( ) #NEWLINE# del m . arguments [ ( - 4 ) : ] #NEWLINE# m . arguments . append ( 'True' ) #NEWLINE# m . ClearField ( 'signature' ) #NEWLINE# expected_message = m . SerializeToString ( ) #NEWLINE# self . handler . on_connection_made ( ) #NEWLINE# self . handler . receive_message ( data ) #NEWLINE# self . clock . advance ( ( 100 * constants . PACKET_TIMEOUT ) ) #NEWLINE# connection . REACTOR . runUntilCurrent ( ) #NEWLINE# m_calls = self . proto_mock . send_datagram . call_args_list #NEWLINE# sent_packet = packet . Packet . from_bytes ( self . proto_mock . send_datagram . call_args_list [ 0 ] [ 0 ] [ 0 ] ) #NEWLINE# received_message = sent_packet . payload #NEWLINE# m2 = message . Message ( ) #NEWLINE# m2 . ParseFromString ( received_message ) #NEWLINE# m2 . ClearField ( 'signature' ) #NEWLINE# received_message = m2 . SerializeToString ( ) #NEWLINE# self . assertEqual ( received_message , expected_message ) #NEWLINE# self . assertEqual ( len ( m_calls ) , 2 ) #NEWLINE# self . assertTrue ( ( self . storage . getSpecific ( digest ( 'Keyword' ) , 'Key' ) == self . protocol . sourceNode . getProto ( ) . SerializeToString ( ) ) )