Exemplo n.º 1
0
 def test_amount_calculation_outgoing(self):
     inputs = (
         Input(
             "0000000000000000000000000000000000000000000000000000000000000000",
             "addr_test1qqr585tvlc7ylnqvz8pyqwauzrdu0mxag3m7q56grgmgu7sxu2hyfhlkwuxupa9d5085eunq2qywy7hvmvej456flknswgndm3",
             Decimal(100),
         ),
     )
     outputs = (
         # this is a change output
         Output(
             "addr_test1qqd86dlwasc5kwe39m0qvu4v6krd24qek0g9pv9f2kq9x28d56vd3zqzthdaweyrktfm3h5cz4je9h5j6s0f24pryswqgepa9e",
             Decimal(30),
         ),
         # this is a real outgoing output
         Output(
             "addr_test1qpyppguxp7vlr77eywsvx9f9l0w07fkx7echm0wldaud9ucxu2hyfhlkwuxupa9d5085eunq2qywy7hvmvej456flkns8556zj",
             Decimal(69),
         ),
     )
     tx = Transaction(
         "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
         fee=Decimal(1),
         inputs=inputs,
         outputs=outputs,
         local_inputs=inputs,
         local_outputs=(outputs[0],),
     )
     self.assertEqual(tx.amount_in, 0)
     self.assertEqual(tx.amount_out, 69)
Exemplo n.º 2
0
 def test_simple(self):
     tx = Transaction(
         txid=
         "0b048162778e29e98d833d948a3be7f18f9ce8693d7ee407c7d38b6ef2a5a264")
     self.assertEqual(tx.amount_in, 0)
     self.assertEqual(tx.amount_out, 0)
     self.assertIsNone(tx.fee)
     self.assertIsInstance(tx.inputs, list)
     self.assertIsInstance(tx.outputs, list)
     self.assertEqual(len(tx.inputs), 0)
     self.assertEqual(len(tx.outputs), 0)
Exemplo n.º 3
0
 def test_args(self):
     inp = Input("f9ab4d2dbb270370172d28cb280c2351771998ab4405fb90fb93bb18aee216fa")
     tx = Transaction(
         txid="88633270f854eea5b2f35a863d748b294299deecf62ec9629ff08fca87fff45c",
         fee=Decimal("0.168801"),
         inputs=[inp],
     )
     self.assertEqual(len(tx.inputs), 1)
     self.assertEqual(len(tx.local_inputs), 0)
     self.assertIsInstance(tx.amount_in, Decimal)
     self.assertEqual(tx.amount_in, Decimal("0"))
     self.assertIsInstance(tx.amount_out, Decimal)
     self.assertEqual(tx.amount_out, Decimal("0"))
Exemplo n.º 4
0
 def setUp(self):
     self.txset = [
         # mempool
         Transaction(
             txid="52e9167c6292f74b08c9a6e8e9c1f68220ad1d08a404b6f906c51e67bea4699c",
             status="pending",
             inputs=(
                 Input(
                     "0000000000000000000000000000000000000000000000000000000000000000",
                     "addr_test1qqr585tvlc7ylnqvz8pyqwauzrdu0mxag3m7q56grgmgu7sxu2hyfhlkwuxupa9d5085eunq2qywy7hvmvej456flknswgndm3",
                     Decimal(100),
                 ),
             ),
             outputs=(
                 # this is a change output
                 Output(
                     "addr_test1qqd86dlwasc5kwe39m0qvu4v6krd24qek0g9pv9f2kq9x28d56vd3zqzthdaweyrktfm3h5cz4je9h5j6s0f24pryswqgepa9e",
                     Decimal(30),
                 ),
                 # this is a real outgoing output
                 Output(
                     "addr_test1qpyppguxp7vlr77eywsvx9f9l0w07fkx7echm0wldaud9ucxu2hyfhlkwuxupa9d5085eunq2qywy7hvmvej456flkns8556zj",
                     Decimal(69),
                 ),
             ),
         ),
         # in ledger
         Transaction(
             txid="1f2f3c0bb8bffe6b01c7dd15255b9d125e1e72c630c4f13f2d96e055c364349b",
             inserted_at=BlockPosition(
                 epoch=123, slot=140937, absolute_slot=22907337, height=2458048
             ),
             status="in_ledger",
             inputs=(
                 Input(
                     "0000000000000000000000000000000000000000000000000000000000000000",
                     "addr_test1qqd86dlwasc5kwe39m0qvu4v6krd24qek0g9pv9f2kq9x28d56vd3zqzthdaweyrktfm3h5cz4je9h5j6s0f24pryswqgepa9e",
                     Decimal(100),
                 ),
             ),
             outputs=(
                 Output(
                     "addr_test1qqr585tvlc7ylnqvz8pyqwauzrdu0mxag3m7q56grgmgu7sxu2hyfhlkwuxupa9d5085eunq2qywy7hvmvej456flknswgndm3",
                     Decimal(30),
                 ),
                 Output(
                     "addr_test1qpyppguxp7vlr77eywsvx9f9l0w07fkx7echm0wldaud9ucxu2hyfhlkwuxupa9d5085eunq2qywy7hvmvej456flkns8556zj",
                     Decimal(69),
                 ),
             ),
         ),
         # the following two share the same block
         Transaction(
             txid="747787b69580e56649963d2bbedc067e57265ef385b0546bc38c8bc565ed00fa",
             inserted_at=BlockPosition(
                 epoch=122, slot=262150, absolute_slot=22596550, height=2447816
             ),
             status="in_ledger",
         ),
         Transaction(
             txid="b5876751c9cec196db1d98c2e9335b94ef5974ece7b57f2afed337f9be7ceaad",
             inserted_at=BlockPosition(
                 epoch=122, slot=262150, absolute_slot=22596550, height=2447816
             ),
             status="in_ledger",
         ),
         # this one is just a block later
         Transaction(
             txid="ad39ce00981de18919933d39576f80c0cbc1f5b20ef9e1ecbaa454873d8b6828",
             inserted_at=BlockPosition(
                 epoch=122, slot=262151, absolute_slot=24478170, height=2447817
             ),
             status="in_ledger",
         ),
         Transaction(
             txid="c352a31f22d7b3265284501274535cf0de3a9d59ab47ce16cf851057dbb0b090",
             inserted_at=BlockPosition(
                 epoch=131, slot=8876, absolute_slot=25010210, height=2487126
             ),
             status="in_ledger",
         ),
         # mempool
         Transaction(
             txid="7000bceff12b142009d6967259bddfb93afea9c3d1bfac7cc3a0306785c24ee8",
             status="pending",
         ),
     ]