Example #1
0
 def test_sendrawtransaction(self):
     num_outputs = 5
     given_transaction = CMutableTransaction(
         [], [make_txout() for x in range(0, num_outputs)])
     expected_txid = b2lx(given_transaction.GetHash())
     given_transaction_hex = b2x(given_transaction.serialize())
     proxy = FakeBitcoinProxy()
     resulting_txid = proxy.sendrawtransaction(given_transaction_hex)
     self.assertEqual(resulting_txid, expected_txid)
Example #2
0
    def test_fundrawtransaction_adds_output(self):
        num_outputs = 5
        unfunded_transaction = CMutableTransaction(
            [], [make_txout() for x in range(0, num_outputs)])
        proxy = FakeBitcoinProxy()

        funded_transaction_hex = proxy.fundrawtransaction(
            b2x(unfunded_transaction.serialize()))["hex"]
        funded_transaction = CMutableTransaction.deserialize(
            x(funded_transaction_hex))

        self.assertTrue(len(funded_transaction.vout) > num_outputs)
        self.assertEqual(len(funded_transaction.vout), num_outputs + 1)
Example #3
0
    def test_fundrawtransaction_hex_hash(self):
        unfunded_transaction = CMutableTransaction(
            [], [make_txout() for x in range(0, 5)])
        proxy = FakeBitcoinProxy()

        funded_transaction_hex = proxy.fundrawtransaction(
            b2x(unfunded_transaction.serialize()))["hex"]
        funded_transaction = CMutableTransaction.deserialize(
            x(funded_transaction_hex))

        self.assertTrue(unfunded_transaction is not funded_transaction)
        self.assertEqual(type(funded_transaction), type(unfunded_transaction))
        self.assertNotEqual(len(funded_transaction.vin), 0)
        self.assertTrue(
            len(funded_transaction.vin) > len(unfunded_transaction.vin))
        self.assertEqual(type(funded_transaction.vin[0]), CTxIn)
Example #4
0
    def test_signrawtransaction(self):
        num_outputs = 5
        given_transaction = CMutableTransaction(
            [], [make_txout() for x in range(0, num_outputs)])
        proxy = FakeBitcoinProxy()

        result = proxy.signrawtransaction(given_transaction)

        self.assertEqual(type(result), dict)
        self.assertTrue("hex" in result.keys())

        result_transaction_hex = result["hex"]
        result_transaction = CMutableTransaction.deserialize(
            x(result_transaction_hex))

        self.assertTrue(result_transaction is not given_transaction)
        self.assertTrue(result_transaction.vin is not given_transaction.vin)
        self.assertTrue(result_transaction.vout is not given_transaction.vout)
        self.assertEqual(len(result_transaction.vout),
                         len(given_transaction.vout))
        self.assertEqual(result_transaction.vout[0].scriptPubKey,
                         given_transaction.vout[0].scriptPubKey)