Changeset View
Changeset View
Standalone View
Standalone View
test/functional/rpc_rawtransaction.py
Show First 20 Lines • Show All 382 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
[rawTxPartialSigned1['hex'], rawTxPartialSigned2['hex']]) | [rawTxPartialSigned1['hex'], rawTxPartialSigned2['hex']]) | ||||
self.log.debug(rawTxComb) | self.log.debug(rawTxComb) | ||||
self.nodes[2].sendrawtransaction(rawTxComb) | self.nodes[2].sendrawtransaction(rawTxComb) | ||||
rawTx2 = self.nodes[0].decoderawtransaction(rawTxComb) | rawTx2 = self.nodes[0].decoderawtransaction(rawTxComb) | ||||
self.sync_all() | self.sync_all() | ||||
self.nodes[0].generate(1) | self.nodes[0].generate(1) | ||||
self.sync_all() | self.sync_all() | ||||
assert_equal(self.nodes[0].getbalance( | assert_equal(self.nodes[0].getbalance( | ||||
), bal+Decimal('50.00000000')+Decimal('2.19000000')) # block reward + tx | ), bal + Decimal('50.00000000') + Decimal('2.19000000')) # block reward + tx | ||||
# getrawtransaction tests | # getrawtransaction tests | ||||
# 1. valid parameters - only supply txid | # 1. valid parameters - only supply txid | ||||
txHash = rawTx["hash"] | txHash = rawTx["hash"] | ||||
assert_equal( | assert_equal( | ||||
self.nodes[0].getrawtransaction(txHash), rawTxSigned['hex']) | self.nodes[0].getrawtransaction(txHash), rawTxSigned['hex']) | ||||
# 2. valid parameters - supply txid and 0 for non-verbose | # 2. valid parameters - supply txid and 0 for non-verbose | ||||
▲ Show 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
self.nodes[0].decoderawtransaction(ToHex(tx)) | self.nodes[0].decoderawtransaction(ToHex(tx)) | ||||
# truncated push | # truncated push | ||||
tx.vin.append(CTxIn(COutPoint(42, 0), b'\x4e\x00\x00')) | tx.vin.append(CTxIn(COutPoint(42, 0), b'\x4e\x00\x00')) | ||||
tx.vin.append(CTxIn(COutPoint(42, 0), b'\x4c\x10TRUNC')) | tx.vin.append(CTxIn(COutPoint(42, 0), b'\x4c\x10TRUNC')) | ||||
tx.vout.append(CTxOut(0, b'\x4e\x00\x00')) | tx.vout.append(CTxOut(0, b'\x4e\x00\x00')) | ||||
tx.vout.append(CTxOut(0, b'\x4c\x10TRUNC')) | tx.vout.append(CTxOut(0, b'\x4c\x10TRUNC')) | ||||
self.nodes[0].decoderawtransaction(ToHex(tx)) | self.nodes[0].decoderawtransaction(ToHex(tx)) | ||||
# giant pushes and long scripts | # giant pushes and long scripts | ||||
tx.vin.append(CTxIn(COutPoint(42, 0), CScript([b'giant push'*10000]))) | tx.vin.append( | ||||
CTxIn(COutPoint(42, 0), CScript([b'giant push' * 10000]))) | |||||
tx.vout.append(CTxOut(0, CScript([b'giant push'*10000]))) | tx.vout.append(CTxOut(0, CScript([b'giant push' * 10000]))) | ||||
self.nodes[0].decoderawtransaction(ToHex(tx)) | self.nodes[0].decoderawtransaction(ToHex(tx)) | ||||
self.log.info('Refuse garbage after transaction') | self.log.info('Refuse garbage after transaction') | ||||
assert_raises_rpc_error(-22, 'TX decode failed', | assert_raises_rpc_error(-22, 'TX decode failed', | ||||
self.nodes[0].decoderawtransaction, ToHex(tx) + '00') | self.nodes[0].decoderawtransaction, ToHex(tx) + '00') | ||||
if __name__ == '__main__': | if __name__ == '__main__': | ||||
RawTransactionsTest().main() | RawTransactionsTest().main() |