Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet_listsinceblock.py
Show All 28 Lines | def run_test(self): | ||||
self.nodes[2].generate(101) | self.nodes[2].generate(101) | ||||
self.sync_all() | self.sync_all() | ||||
self.test_no_blockhash() | self.test_no_blockhash() | ||||
self.test_invalid_blockhash() | self.test_invalid_blockhash() | ||||
self.test_reorg() | self.test_reorg() | ||||
self.test_double_spend() | self.test_double_spend() | ||||
self.test_double_send() | self.test_double_send() | ||||
self.test_targetconfirmations() | |||||
def test_no_blockhash(self): | def test_no_blockhash(self): | ||||
self.log.info("Test no blockhash") | self.log.info("Test no blockhash") | ||||
txid = self.nodes[2].sendtoaddress( | txid = self.nodes[2].sendtoaddress( | ||||
self.nodes[0].getnewaddress(), 1000000) | self.nodes[0].getnewaddress(), 1000000) | ||||
blockhash, = self.nodes[2].generate(1) | blockhash, = self.nodes[2].generate(1) | ||||
blockheight = self.nodes[2].getblockheader(blockhash)['height'] | blockheight = self.nodes[2].getblockheader(blockhash)['height'] | ||||
self.sync_all() | self.sync_all() | ||||
Show All 23 Lines | def test_invalid_blockhash(self): | ||||
"42759cde25462784395a337460bde75f58e73d3f08bd31fdc3507cbac856a2c4") | "42759cde25462784395a337460bde75f58e73d3f08bd31fdc3507cbac856a2c4") | ||||
assert_raises_rpc_error(-5, "Block not found", self.nodes[0].listsinceblock, | assert_raises_rpc_error(-5, "Block not found", self.nodes[0].listsinceblock, | ||||
"0000000000000000000000000000000000000000000000000000000000000000") | "0000000000000000000000000000000000000000000000000000000000000000") | ||||
assert_raises_rpc_error(-8, "blockhash must be of length 64 (not 11, for 'invalid-hex')", self.nodes[0].listsinceblock, | assert_raises_rpc_error(-8, "blockhash must be of length 64 (not 11, for 'invalid-hex')", self.nodes[0].listsinceblock, | ||||
"invalid-hex") | "invalid-hex") | ||||
assert_raises_rpc_error(-8, "blockhash must be hexadecimal string (not 'Z000000000000000000000000000000000000000000000000000000000000000')", self.nodes[0].listsinceblock, | assert_raises_rpc_error(-8, "blockhash must be hexadecimal string (not 'Z000000000000000000000000000000000000000000000000000000000000000')", self.nodes[0].listsinceblock, | ||||
"Z000000000000000000000000000000000000000000000000000000000000000") | "Z000000000000000000000000000000000000000000000000000000000000000") | ||||
def test_targetconfirmations(self): | |||||
''' | |||||
This tests when the value of target_confirmations exceeds the number of | |||||
blocks in the main chain. In this case, the genesis block hash should be | |||||
given for the `lastblock` property. If target_confirmations is < 1, then | |||||
a -8 invalid parameter error is thrown. | |||||
''' | |||||
self.log.info("Test target_confirmations") | |||||
blockhash, = self.nodes[2].generate(1) | |||||
blockheight = self.nodes[2].getblockheader(blockhash)['height'] | |||||
self.sync_all() | |||||
assert_equal( | |||||
self.nodes[0].getblockhash(0), | |||||
self.nodes[0].listsinceblock(blockhash, blockheight + 1)['lastblock']) | |||||
assert_equal( | |||||
self.nodes[0].getblockhash(0), | |||||
self.nodes[0].listsinceblock(blockhash, blockheight + 1000)['lastblock']) | |||||
assert_raises_rpc_error(-8, "Invalid parameter", | |||||
self.nodes[0].listsinceblock, blockhash, 0) | |||||
def test_reorg(self): | def test_reorg(self): | ||||
''' | ''' | ||||
`listsinceblock` did not behave correctly when handed a block that was | `listsinceblock` did not behave correctly when handed a block that was | ||||
no longer in the main chain: | no longer in the main chain: | ||||
ab0 | ab0 | ||||
/ \ | / \ | ||||
aa1 [tx0] bb1 | aa1 [tx0] bb1 | ||||
▲ Show 20 Lines • Show All 234 Lines • Show Last 20 Lines |