From 7c5a791b73775c4c51767113d50cb4f931a53591 Mon Sep 17 00:00:00 2001 From: Larry Ruane Date: Fri, 9 Aug 2019 15:27:52 -0600 Subject: [PATCH] insightexplorer: formatting, pyflakes cleanups --- qa/rpc-tests/addressindex.py | 21 ++++++++++----------- qa/rpc-tests/spentindex.py | 27 ++++++++++++++++----------- src/rpc/misc.cpp | 4 ++-- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/qa/rpc-tests/addressindex.py b/qa/rpc-tests/addressindex.py index f924f0875..b4562f9ef 100755 --- a/qa/rpc-tests/addressindex.py +++ b/qa/rpc-tests/addressindex.py @@ -1,8 +1,7 @@ #!/usr/bin/env python # Copyright (c) 2019 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. - +# file COPYING or https://www.opensource.org/licenses/mit-license.php . # # Test addressindex generation and fetching for insightexplorer # @@ -13,23 +12,20 @@ # getaddressdeltas # getaddressutxos # getaddressmempool -# import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x." from test_framework.test_framework import BitcoinTestFramework - from test_framework.util import ( assert_equal, initialize_chain_clean, start_nodes, stop_nodes, connect_nodes, + wait_bitcoinds, ) -from test_framework.util import wait_bitcoinds - from test_framework.script import ( CScript, OP_HASH160, @@ -38,8 +34,11 @@ from test_framework.script import ( OP_DROP, ) -from test_framework.mininode import COIN, CTransaction -from test_framework.mininode import CTxIn, CTxOut, COutPoint +from test_framework.mininode import ( + COIN, + CTransaction, + CTxIn, CTxOut, COutPoint, +) from binascii import hexlify @@ -100,7 +99,7 @@ class AddressIndexTest(BitcoinTestFramework): assert_equal(self.nodes[1].getbalance(), 0) # only the oldest 5; subsequent are not yet mature - unspent_txids = [ u['txid'] for u in self.nodes[0].listunspent() ] + unspent_txids = [u['txid'] for u in self.nodes[0].listunspent()] # Currently our only unspents are coinbase transactions, choose any one tx = self.nodes[0].getrawtransaction(unspent_txids[0], 1) @@ -139,7 +138,7 @@ class AddressIndexTest(BitcoinTestFramework): txids_a1 = [] addr1 = self.nodes[1].getnewaddress() expected = 0 - expected_deltas = [] # for checking getaddressdeltas (below) + expected_deltas = [] # for checking getaddressdeltas (below) for i in range(5): # first transaction happens at height 105, mined in block 106 txid = self.nodes[0].sendtoaddress(addr1, i + 1) @@ -213,7 +212,7 @@ class AddressIndexTest(BitcoinTestFramework): 'satoshis': (-4) * COIN, 'txid': txid, }) - self.sync_all() # ensure transaction is included in the next block + self.sync_all() # ensure transaction is included in the next block self.nodes[0].generate(1) self.sync_all() diff --git a/qa/rpc-tests/spentindex.py b/qa/rpc-tests/spentindex.py index 28e626573..dbda29090 100755 --- a/qa/rpc-tests/spentindex.py +++ b/qa/rpc-tests/spentindex.py @@ -1,25 +1,28 @@ #!/usr/bin/env python # Copyright (c) 2019 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. - -# -# Test spentindex generation and fetching +# file COPYING or https://www.opensource.org/licenses/mit-license.php . # +# Test spentindex generation and fetching for insightexplorer import sys; assert sys.version_info < (3,), ur"This script does not run under Python 3. Please use Python 2.7.x." from test_framework.test_framework import BitcoinTestFramework from test_framework.authproxy import JSONRPCException -from test_framework.util import assert_equal -from test_framework.util import initialize_chain_clean -from test_framework.util import start_nodes, stop_nodes, connect_nodes -from test_framework.util import wait_bitcoinds -from test_framework.util import fail +from test_framework.util import ( + assert_equal, + initialize_chain_clean, + start_nodes, + stop_nodes, + connect_nodes, + wait_bitcoinds, + fail, +) from test_framework.mininode import COIN + class SpentIndexTest(BitcoinTestFramework): def setup_chain(self): @@ -29,7 +32,8 @@ class SpentIndexTest(BitcoinTestFramework): def setup_network(self): # -insightexplorer causes spentindex to be enabled (fSpentIndex = true) - self.nodes = start_nodes(3, self.options.tmpdir, + self.nodes = start_nodes( + 3, self.options.tmpdir, [['-debug', '-txindex', '-experimentalfeatures', '-insightexplorer']]*3) connect_nodes(self.nodes[0], 1) connect_nodes(self.nodes[0], 2) @@ -74,7 +78,7 @@ class SpentIndexTest(BitcoinTestFramework): # Check new fields added to getrawtransaction tx1 = self.nodes[2].getrawtransaction(txid1, 1) - assert_equal(tx1['vin'][0]['value'], 10) # coinbase + assert_equal(tx1['vin'][0]['value'], 10) # coinbase assert_equal(tx1['vin'][0]['valueSat'], 10*COIN) # we want the non-change (payment) output vout = filter(lambda o: o['value'] == 2, tx1['vout']) @@ -178,5 +182,6 @@ class SpentIndexTest(BitcoinTestFramework): assert_equal(len(out), 1) assert_equal(out[0]['address'], addr2) + if __name__ == '__main__': SpentIndexTest().main() diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 84a2b47a1..00e76a81d 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -1077,8 +1077,8 @@ UniValue getspentinfo(const UniValue& params, bool fHelp) " ,...\n" "}\n" "\nExamples:\n" - + HelpExampleCli("getspentinfo", "'{\"txid\": \"0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9\", \"index\": 0}'") - + HelpExampleRpc("getspentinfo", "{\"txid\": \"0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9\", \"index\": 0}") + + HelpExampleCli("getspentinfo", "'{\"txid\": \"33990288fb116981260be1de10b8c764f997674545ab14f9240f00346333b780\", \"index\": 4}'") + + HelpExampleRpc("getspentinfo", "{\"txid\": \"33990288fb116981260be1de10b8c764f997674545ab14f9240f00346333b780\", \"index\": 4}") ); if (!enabled) {