Example #1
0
 def test_simple_numbers(self):
     self.assertEqual(to_atomic(Decimal("0")), 0)
     self.assertEqual(from_atomic(0), Decimal("0"))
     self.assertEqual(to_atomic(Decimal("1")), 1000000000000)
     self.assertEqual(from_atomic(1000000000000), Decimal("1"))
     self.assertEqual(to_atomic(Decimal("0.000000000001")), 1)
     self.assertEqual(from_atomic(1), Decimal("0.000000000001"))
Example #2
0
 def test_numeric_types(self):
     "Only check if conversion of given type succeeds or fails."
     self.assertTrue(to_atomic(1))
     self.assertTrue(to_atomic(1.0))
     if hasattr(sys, "maxint"):  # Python 2.x
         self.assertTrue(to_atomic(sys.maxint + 1))
     self.assertRaises(ValueError, to_atomic, "1")
Example #3
0
    def transfer(self, destinations : list, priority = 0,
            payment_id=None, unlock_time=0, account=0,relay=False):

        dests = [(dst['address'], dst['amount']) for dst in  destinations]

        params = {
            'account_index': account,
            'destinations': list(map(lambda dst: {'address': dst[0], 'amount': to_atomic(dst[1])}, dests)),
            'priority': priority,
            'unlock_time': 0,
            'get_tx_keys': False,
            'get_tx_hex': False,
            'do_not_relay': not relay,
        }

        # 参考: https://github.com/monero-project/monero/blob/master/src/wallet/wallet2.cpp#L109
        # unsigned_txset 开头固定是 4d6f6e65726f20756e7369676e65642074782073657404
        # 即:
        # binascii.b2a_hex( b'Monero unsigned tx set\004'  )
        # b'4d6f6e65726f20756e7369676e65642074782073657404'

        rawtxs = self.raw_request('transfer_split', params=params)
        return rawtxs
Example #4
0
 def test_rounding(self):
     self.assertEqual(to_atomic(Decimal("1.0000000000004")), 1000000000000)
     self.assertEqual(as_monero(Decimal("1.0000000000014")),
                      Decimal("1.000000000001"))
Example #5
0
 def test_rounding(self):
     self.assertEqual(to_atomic(Decimal('1.0000000000004')), 1000000000000)
Example #6
0
    def test_amount(self):
        amount = 100
        dummy_output = Output(atomic_amount=to_atomic(amount))

        assert dummy_output.amount == amount