'Test encoding and decoding of an offer sync'

def test_encode_decode_offer_sync(self):

    message = MockObject()
    meta_msg = self.market_community.get_meta_message(u'offer-sync')
    offer_payload = OfferSyncPayload.Implementation(meta_msg, TraderId('abc'), MessageNumber('3'), OrderNumber(4), Price(5, 'BTC'), Quantity(6, 'MC'), Timeout(3600), Timestamp.now(), 'a', 'b', Ttl(3), '1.2.3.4', 1234, True)
    message.payload = offer_payload
    (packet,) = self.conversion._encode_offer_sync(message)
    self.assertTrue(packet)
    (_, decoded) = self.conversion._decode_offer_sync(self.get_placeholder_msg(u'offer-sync'), 0, packet)
    self.assertTrue(decoded)
    self.assertEqual(decoded.price, Price(5, 'BTC'))
    self.assertEqual(int(decoded.ttl), 3)
    self.assertTrue(decoded.is_ask)
