'Test encoding and decoding of a payment'

def test_encode_decode_payment(self):

    message = MockObject()
    meta_msg = self.market_community.get_meta_message(u'payment')
    payment_payload = PaymentPayload.Implementation(meta_msg, TraderId('abc'), MessageNumber('3'), TraderId('def'), TransactionNumber(5), Quantity(5, 'MC'), Price(6, 'BTC'), WalletAddress('a'), WalletAddress('b'), PaymentId('abc'), Timestamp.now(), False)
    message.payload = payment_payload
    (packet,) = self.conversion._encode_payment(message)
    self.assertTrue(packet)
    (_, decoded) = self.conversion._decode_payment(self.get_placeholder_msg(u'payment'), 0, packet)
    self.assertTrue(decoded)
    self.assertEqual(decoded.trader_id, TraderId('abc'))
    self.assertEqual(decoded.transaction_trader_id, TraderId('def'))
    self.assertEqual(decoded.payment_id, PaymentId('abc'))
    self.assertEqual(decoded.success, False)
