Merge #7863: getblockchaininfo: make bip9_softforks an object, not an array.
d12760b rpc-tests: handle KeyError nicely in test_framework.py (Rusty Russell) 85c807c getblockchaininfo: make bip9_softforks an object, not an array. (Rusty Russell)
This commit is contained in:
parent
5b1ad12d10
commit
cc3a06bf53
@ -77,11 +77,7 @@ class BIP9SoftForksTest(ComparisonTestFramework):
|
|||||||
|
|
||||||
def get_bip9_status(self, key):
|
def get_bip9_status(self, key):
|
||||||
info = self.nodes[0].getblockchaininfo()
|
info = self.nodes[0].getblockchaininfo()
|
||||||
for row in info['bip9_softforks']:
|
return info['bip9_softforks'][key]
|
||||||
if row['id'] == key:
|
|
||||||
return row
|
|
||||||
raise IndexError ('key:"%s" not found' % key)
|
|
||||||
|
|
||||||
|
|
||||||
def test_BIP(self, bipName, activated_version, invalidate, invalidatePostSignature, bitno):
|
def test_BIP(self, bipName, activated_version, invalidate, invalidatePostSignature, bitno):
|
||||||
wait_to_sync(self.nodes[0])
|
wait_to_sync(self.nodes[0])
|
||||||
|
@ -142,6 +142,9 @@ class BitcoinTestFramework(object):
|
|||||||
except AssertionError as e:
|
except AssertionError as e:
|
||||||
print("Assertion failed: "+ str(e))
|
print("Assertion failed: "+ str(e))
|
||||||
traceback.print_tb(sys.exc_info()[2])
|
traceback.print_tb(sys.exc_info()[2])
|
||||||
|
except KeyError as e:
|
||||||
|
print("key not found: "+ str(e))
|
||||||
|
traceback.print_tb(sys.exc_info()[2])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Unexpected exception caught during testing: " + repr(e))
|
print("Unexpected exception caught during testing: " + repr(e))
|
||||||
traceback.print_tb(sys.exc_info()[2])
|
traceback.print_tb(sys.exc_info()[2])
|
||||||
|
@ -605,7 +605,4 @@ def create_lots_of_big_transactions(node, txouts, utxos, fee):
|
|||||||
|
|
||||||
def get_bip9_status(node, key):
|
def get_bip9_status(node, key):
|
||||||
info = node.getblockchaininfo()
|
info = node.getblockchaininfo()
|
||||||
for row in info['bip9_softforks']:
|
return info['bip9_softforks'][key]
|
||||||
if row['id'] == key:
|
|
||||||
return row
|
|
||||||
raise IndexError ('key:"%s" not found' % key)
|
|
||||||
|
@ -801,10 +801,9 @@ static UniValue SoftForkDesc(const std::string &name, int version, CBlockIndex*
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
static UniValue BIP9SoftForkDesc(const std::string& name, const Consensus::Params& consensusParams, Consensus::DeploymentPos id)
|
static UniValue BIP9SoftForkDesc(const Consensus::Params& consensusParams, Consensus::DeploymentPos id)
|
||||||
{
|
{
|
||||||
UniValue rv(UniValue::VOBJ);
|
UniValue rv(UniValue::VOBJ);
|
||||||
rv.push_back(Pair("id", name));
|
|
||||||
const ThresholdState thresholdState = VersionBitsTipState(consensusParams, id);
|
const ThresholdState thresholdState = VersionBitsTipState(consensusParams, id);
|
||||||
switch (thresholdState) {
|
switch (thresholdState) {
|
||||||
case THRESHOLD_DEFINED: rv.push_back(Pair("status", "defined")); break;
|
case THRESHOLD_DEFINED: rv.push_back(Pair("status", "defined")); break;
|
||||||
@ -853,15 +852,14 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
|
|||||||
" \"reject\": { ... } (object) progress toward rejecting pre-softfork blocks (same fields as \"enforce\")\n"
|
" \"reject\": { ... } (object) progress toward rejecting pre-softfork blocks (same fields as \"enforce\")\n"
|
||||||
" }, ...\n"
|
" }, ...\n"
|
||||||
" ],\n"
|
" ],\n"
|
||||||
" \"bip9_softforks\": [ (array) status of BIP9 softforks in progress\n"
|
" \"bip9_softforks\": { (object) status of BIP9 softforks in progress\n"
|
||||||
" {\n"
|
" \"xxxx\" : { (string) name of the softfork\n"
|
||||||
" \"id\": \"xxxx\", (string) name of the softfork\n"
|
|
||||||
" \"status\": \"xxxx\", (string) one of \"defined\", \"started\", \"lockedin\", \"active\", \"failed\"\n"
|
" \"status\": \"xxxx\", (string) one of \"defined\", \"started\", \"lockedin\", \"active\", \"failed\"\n"
|
||||||
" \"bit\": xx, (numeric) the bit, 0-28, in the block version field used to signal this soft fork\n"
|
" \"bit\": xx, (numeric) the bit, 0-28, in the block version field used to signal this soft fork\n"
|
||||||
" \"startTime\": xx, (numeric) the minimum median time past of a block at which the bit gains its meaning\n"
|
" \"startTime\": xx, (numeric) the minimum median time past of a block at which the bit gains its meaning\n"
|
||||||
" \"timeout\": xx (numeric) the median time past of a block at which the deployment is considered failed if not yet locked in\n"
|
" \"timeout\": xx (numeric) the median time past of a block at which the deployment is considered failed if not yet locked in\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
" ]\n"
|
" }\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
"\nExamples:\n"
|
"\nExamples:\n"
|
||||||
+ HelpExampleCli("getblockchaininfo", "")
|
+ HelpExampleCli("getblockchaininfo", "")
|
||||||
@ -884,12 +882,12 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
|
|||||||
const Consensus::Params& consensusParams = Params().GetConsensus();
|
const Consensus::Params& consensusParams = Params().GetConsensus();
|
||||||
CBlockIndex* tip = chainActive.Tip();
|
CBlockIndex* tip = chainActive.Tip();
|
||||||
UniValue softforks(UniValue::VARR);
|
UniValue softforks(UniValue::VARR);
|
||||||
UniValue bip9_softforks(UniValue::VARR);
|
UniValue bip9_softforks(UniValue::VOBJ);
|
||||||
softforks.push_back(SoftForkDesc("bip34", 2, tip, consensusParams));
|
softforks.push_back(SoftForkDesc("bip34", 2, tip, consensusParams));
|
||||||
softforks.push_back(SoftForkDesc("bip66", 3, tip, consensusParams));
|
softforks.push_back(SoftForkDesc("bip66", 3, tip, consensusParams));
|
||||||
softforks.push_back(SoftForkDesc("bip65", 4, tip, consensusParams));
|
softforks.push_back(SoftForkDesc("bip65", 4, tip, consensusParams));
|
||||||
bip9_softforks.push_back(BIP9SoftForkDesc("csv", consensusParams, Consensus::DEPLOYMENT_CSV));
|
bip9_softforks.push_back(Pair("csv", BIP9SoftForkDesc(consensusParams, Consensus::DEPLOYMENT_CSV)));
|
||||||
bip9_softforks.push_back(BIP9SoftForkDesc("dip0001", consensusParams, Consensus::DEPLOYMENT_DIP0001));
|
bip9_softforks.push_back(Pair("dip0001", BIP9SoftForkDesc(consensusParams, Consensus::DEPLOYMENT_DIP0001)));
|
||||||
obj.push_back(Pair("softforks", softforks));
|
obj.push_back(Pair("softforks", softforks));
|
||||||
obj.push_back(Pair("bip9_softforks", bip9_softforks));
|
obj.push_back(Pair("bip9_softforks", bip9_softforks));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user