def test_state_get(self): """Tests that State gets addresses correctly.""" self.mock_stream.send.return_value = self._make_future( message_type=Message.TP_STATE_GET_RESPONSE, content=TpStateGetResponse( status=TpStateGetResponse.OK, entries=self._make_entries()).SerializeToString()) self.context.get_state(self.addresses) self.mock_stream.send.assert_called_with( Message.TP_STATE_GET_REQUEST, TpStateGetRequest(context_id=self.context_id, addresses=self.addresses).SerializeToString())
def create_get_response(self, address_data_map): # Each Entry has an address, and data. # Data can be anything, but transaction processors may assum a # certain data type. For example, intkey assumes a dictionary # with "Name" in it and stores the "Value". A dictionary is # used to deal with hash collisions. # GetResponse object has a list of Entry objects entries = [ Entry(address=address, data=data) for address, data in address_data_map.items() ] # Create a GetResponse object return TpStateGetResponse(entries=entries)