def test_sign_message(self):
    builder = EventBuilder({'content': {'body': 'Here is the message content'}, 'event_id': '$0:domain', 'origin': 'domain', 'origin_server_ts': 1000000, 'type': 'm.room.message', 'room_id': '!r:domain', 'sender': '@u:domain', 'signatures': {}, 'unsigned': {'age_ts': 1000000}})
    add_hashes_and_signatures(builder, HOSTNAME, self.signing_key)
    event = builder.build()
    self.assertTrue(hasattr(event, 'hashes'))
    self.assertIn('sha256', event.hashes)
    self.assertEquals(event.hashes['sha256'], 'onLKD1bGljeBWQhWZ1kaP9SorVmRQNdN5aM2JYU2n/g')
    self.assertTrue(hasattr(event, 'signatures'))
    self.assertIn(HOSTNAME, event.signatures)
    self.assertIn(KEY_NAME, event.signatures['domain'])
    self.assertEquals(event.signatures[HOSTNAME][KEY_NAME], 'Wm+VzmOUOz08Ds+0NTWb1d4CZrVsJSikkeRxh6aCcUwu6pNC78FunoD7KNWzqFn241eYHYMGCA5McEiVPdhzBA')
def test_sign_message(self):
    builder = EventBuilder({'content': {'body': 'Here is the message content'}, 'event_id': '$0:domain', 'origin': 'domain', 'origin_server_ts': 1000000, 'type': 'm.room.message', 'room_id': '!r:domain', 'sender': '@u:domain', 'signatures': {}, 'unsigned': {'age_ts': 1000000}})
    add_hashes_and_signatures(builder, HOSTNAME, self.signing_key)
    event = builder.build()
    self.assertTrue(hasattr(event, 'hashes'))
    self.assertIn('sha256', event.hashes)
    self.assertEquals(event.hashes['sha256'], 'onLKD1bGljeBWQhWZ1kaP9SorVmRQNdN5aM2JYU2n/g')
    self.assertTrue(hasattr(event, 'signatures'))
    self.assertIn(HOSTNAME, event.signatures)
    self.assertIn(KEY_NAME, event.signatures['domain'])
    self.assertEquals(event.signatures[HOSTNAME][KEY_NAME], 'Wm+VzmOUOz08Ds+0NTWb1d4CZrVsJSikkeRxh6aCcUwu6pNC78FunoD7KNWzqFn241eYHYMGCA5McEiVPdhzBA')