Changeset View
Changeset View
Standalone View
Standalone View
test/functional/rpc_rawtransaction.py
Show First 20 Lines • Show All 203 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
##################################### | ##################################### | ||||
# getrawtransaction with block hash # | # getrawtransaction with block hash # | ||||
##################################### | ##################################### | ||||
# make a tx by sending then generate 2 blocks; block1 has the tx in it | # make a tx by sending then generate 2 blocks; block1 has the tx in it | ||||
tx = self.nodes[2].sendtoaddress(self.nodes[1].getnewaddress(), 1) | tx = self.nodes[2].sendtoaddress(self.nodes[1].getnewaddress(), 1) | ||||
block1, block2 = self.nodes[2].generate(2) | block1, block2 = self.nodes[2].generate(2) | ||||
self.sync_all() | self.sync_all() | ||||
# We should be able to get the raw transaction by providing the correct block | # We should be able to get the raw transaction by providing the correct | ||||
# block | |||||
gottx = self.nodes[0].getrawtransaction(tx, True, block1) | gottx = self.nodes[0].getrawtransaction(tx, True, block1) | ||||
assert_equal(gottx['txid'], tx) | assert_equal(gottx['txid'], tx) | ||||
assert_equal(gottx['in_active_chain'], True) | assert_equal(gottx['in_active_chain'], True) | ||||
# We should not have the 'in_active_chain' flag when we don't provide a block | # We should not have the 'in_active_chain' flag when we don't provide a | ||||
# block | |||||
gottx = self.nodes[0].getrawtransaction(tx, True) | gottx = self.nodes[0].getrawtransaction(tx, True) | ||||
assert_equal(gottx['txid'], tx) | assert_equal(gottx['txid'], tx) | ||||
assert 'in_active_chain' not in gottx | assert 'in_active_chain' not in gottx | ||||
# We should not get the tx if we provide an unrelated block | # We should not get the tx if we provide an unrelated block | ||||
assert_raises_rpc_error(-5, "No such transaction found", | assert_raises_rpc_error(-5, "No such transaction found", | ||||
self.nodes[0].getrawtransaction, tx, True, block2) | self.nodes[0].getrawtransaction, tx, True, block2) | ||||
# An invalid block hash should raise the correct errors | # An invalid block hash should raise the correct errors | ||||
assert_raises_rpc_error(-8, "parameter 3 must be hexadecimal", | assert_raises_rpc_error(-8, "parameter 3 must be hexadecimal", | ||||
Show All 23 Lines | def run_test(self): | ||||
addr2Obj = self.nodes[2].getaddressinfo(addr2) | addr2Obj = self.nodes[2].getaddressinfo(addr2) | ||||
# Tests for createmultisig and addmultisigaddress | # Tests for createmultisig and addmultisigaddress | ||||
assert_raises_rpc_error(-5, "Invalid public key", | assert_raises_rpc_error(-5, "Invalid public key", | ||||
self.nodes[0].createmultisig, 1, ["01020304"]) | self.nodes[0].createmultisig, 1, ["01020304"]) | ||||
# createmultisig can only take public keys | # createmultisig can only take public keys | ||||
self.nodes[0].createmultisig( | self.nodes[0].createmultisig( | ||||
2, [addr1Obj['pubkey'], addr2Obj['pubkey']]) | 2, [addr1Obj['pubkey'], addr2Obj['pubkey']]) | ||||
# addmultisigaddress can take both pubkeys and addresses so long as they are in the wallet, which is tested here. | # addmultisigaddress can take both pubkeys and addresses so long as | ||||
# they are in the wallet, which is tested here. | |||||
assert_raises_rpc_error(-5, "Invalid public key", | assert_raises_rpc_error(-5, "Invalid public key", | ||||
self.nodes[0].createmultisig, 2, [addr1Obj['pubkey'], addr1]) | self.nodes[0].createmultisig, 2, [addr1Obj['pubkey'], addr1]) | ||||
mSigObj = self.nodes[2].addmultisigaddress( | mSigObj = self.nodes[2].addmultisigaddress( | ||||
2, [addr1Obj['pubkey'], addr1])['address'] | 2, [addr1Obj['pubkey'], addr1])['address'] | ||||
# use balance deltas instead of absolute values | # use balance deltas instead of absolute values | ||||
bal = self.nodes[2].getbalance() | bal = self.nodes[2].getbalance() | ||||
▲ Show 20 Lines • Show All 217 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
rawtx = self.nodes[0].createrawtransaction(inputs, outputs) | rawtx = self.nodes[0].createrawtransaction(inputs, outputs) | ||||
decrawtx = self.nodes[0].decoderawtransaction(rawtx) | decrawtx = self.nodes[0].decoderawtransaction(rawtx) | ||||
assert_equal(decrawtx['vin'][0]['sequence'], 4294967294) | assert_equal(decrawtx['vin'][0]['sequence'], 4294967294) | ||||
#################################### | #################################### | ||||
# TRANSACTION VERSION NUMBER TESTS # | # TRANSACTION VERSION NUMBER TESTS # | ||||
#################################### | #################################### | ||||
# Test the minimum transaction version number that fits in a signed 32-bit integer. | # Test the minimum transaction version number that fits in a signed | ||||
# 32-bit integer. | |||||
tx = CTransaction() | tx = CTransaction() | ||||
tx.nVersion = -0x80000000 | tx.nVersion = -0x80000000 | ||||
rawtx = ToHex(tx) | rawtx = ToHex(tx) | ||||
decrawtx = self.nodes[0].decoderawtransaction(rawtx) | decrawtx = self.nodes[0].decoderawtransaction(rawtx) | ||||
assert_equal(decrawtx['version'], -0x80000000) | assert_equal(decrawtx['version'], -0x80000000) | ||||
# Test the maximum transaction version number that fits in a signed 32-bit integer. | # Test the maximum transaction version number that fits in a signed | ||||
# 32-bit integer. | |||||
tx = CTransaction() | tx = CTransaction() | ||||
tx.nVersion = 0x7fffffff | tx.nVersion = 0x7fffffff | ||||
rawtx = ToHex(tx) | rawtx = ToHex(tx) | ||||
decrawtx = self.nodes[0].decoderawtransaction(rawtx) | decrawtx = self.nodes[0].decoderawtransaction(rawtx) | ||||
assert_equal(decrawtx['version'], 0x7fffffff) | assert_equal(decrawtx['version'], 0x7fffffff) | ||||
########################################## | ########################################## | ||||
# Decoding weird scripts in transactions # | # Decoding weird scripts in transactions # | ||||
Show All 25 Lines |