def test_payment_id(self): pid = PaymentID("0") self.assertTrue(pid.is_short()) self.assertEqual(pid, 0) self.assertEqual(pid, "0000000000000000") self.assertEqual(PaymentID(pid), pid) self.assertNotEqual(pid, None) pid = PaymentID("abcdef") self.assertTrue(pid.is_short()) self.assertEqual(pid, 0xABCDEF) self.assertEqual(pid, "0000000000abcdef") self.assertEqual(PaymentID(pid), pid) pid = PaymentID("1234567812345678") self.assertTrue(pid.is_short()) self.assertEqual(pid, 0x1234567812345678) self.assertEqual(pid, "1234567812345678") self.assertEqual(PaymentID(pid), pid) pid = PaymentID("a1234567812345678") self.assertFalse(pid.is_short()) self.assertEqual(pid, 0xA1234567812345678) self.assertEqual( pid, "00000000000000000000000000000000000000000000000a1234567812345678") self.assertEqual(PaymentID(pid), pid) self.assertRaises(ValueError, PaymentID, 2**256 + 1)
def test_payment_id(self): pid = PaymentID('0') self.assertTrue(pid.is_short()) self.assertEqual(pid, 0) self.assertEqual(pid, '0000000000000000') self.assertEqual(PaymentID(pid), pid) self.assertNotEqual(pid, None) pid = PaymentID('abcdef') self.assertTrue(pid.is_short()) self.assertEqual(pid, 0xabcdef) self.assertEqual(pid, '0000000000abcdef') self.assertEqual(PaymentID(pid), pid) pid = PaymentID('1234567812345678') self.assertTrue(pid.is_short()) self.assertEqual(pid, 0x1234567812345678) self.assertEqual(pid, '1234567812345678') self.assertEqual(PaymentID(pid), pid) pid = PaymentID('a1234567812345678') self.assertFalse(pid.is_short()) self.assertEqual(pid, 0xa1234567812345678) self.assertEqual( pid, '00000000000000000000000000000000000000000000000a1234567812345678') self.assertEqual(PaymentID(pid), pid) self.assertRaises(ValueError, PaymentID, 2**256 + 1)
def create_transaction(cls, text): p1 = PaymentID(cls.to_hex(text)) if p1.is_short(): sender = cls.wallet.addresses()[0] sender = sender.with_payment_id(p1) transaction = cls.wallet.transfer(sender, Decimal('0.000000000001')) return transaction