def test_immutable(self):
        tx = CTransaction()
        self.assertFalse(tx.is_coinbase())

        with self.assertRaises(AttributeError):
            tx.nVersion = 2
        with self.assertRaises(AttributeError):
            tx.vin.append(CTxIn())

        mtx = tx.to_mutable()
        mtx.nVersion = 2
        mtx.vin.append(CTxIn())

        itx = tx.to_immutable()

        with self.assertRaises(AttributeError):
            itx.nVersion = 2
        with self.assertRaises(AttributeError):
            itx.vin.append(CTxIn())
    def test_immutable(self) -> None:
        tx = CTransaction()
        self.assertFalse(tx.is_coinbase())

        # check that immutable property holds
        with self.assertRaises(AttributeError):
            tx.nVersion = 2  # type: ignore
        with self.assertRaises(AttributeError):
            tx.vin.append(CTxIn())  # type: ignore

        mtx = tx.to_mutable()
        mtx.nVersion = 2
        mtx.vin.append(CMutableTxIn())

        itx = tx.to_immutable()

        with self.assertRaises(AttributeError):
            itx.nVersion = 2  # type: ignore
        with self.assertRaises(AttributeError):
            itx.vin.append(CTxIn())  # type: ignore