def testProfileHash(self): # Clear out and reset own profile myTorId = "ABC123DEF456GH78" myprofile = {"name" : "Constantin Taylor", "keyid" : "someKeyId", "displayName" : "Me", "status" : "self", "ownprofile" : True, "description":"Some fairly descriptive text", "birthday":None, "interests":"chocolate pudding with fudge"} DbClient.updateContact(myTorId, myprofile) firstHash = DbClient.calculateHash(DbClient.getProfile()) self.assertEqual(firstHash, "12ae5c8dc8e1c2186b4ed4918040bb16", "First hash not what I was expecting") # Now change interests and check that hash changes DbClient.updateContact(myTorId, {"interests":"roasted vegetables and hummus"}) secondHash = DbClient.calculateHash(DbClient.getProfile()) self.assertNotEqual(firstHash, secondHash, "Profile hash should have changed")
def _createSubpayload(self): '''Use the stored fields to pack the payload contents together''' if self.profileHash is None or self.profileHash == "": self.profileHash = DbClient.calculateHash(DbClient.getProfile()) return self.packBytesTogether([ self.encodeNumberToBytes(1 if self.online else 0, 1), self.encodeNumberToBytes(1 if self.ping else 0, 1), self.profileHash])
def _createSubpayload(self): '''Use the stored fields to pack the payload contents together''' if self.infoType is None: self.infoType = InfoRequestMessage.INFO_PROFILE if self.profileString is None: self.profileString = dbutils.getOwnProfileAsString() self.profileHash = DbClient.calculateHash(DbClient.getProfile()) return self.packBytesTogether([ self.encodeNumberToBytes(self.infoType), self.encodeNumberToBytes(len(self.profileString), 4), self.profileString, self.encodeNumberToBytes(len(self.profileHash), 4), self.profileHash])