mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-13 07:28:59 +01:00
Merge #20120: net, rpc, test, bugfix: update GetNetworkName, GetNetworksInfo, regression tests
7b5bd3102etest: add getnetworkinfo network name regression tests (Jon Atack)9a75e1e569rpc: update GetNetworksInfo() to not return unsupported networks (Jon Atack)ba8997fb2enet: update GetNetworkName() with all enum Network cases (Jon Atack) Pull request description: Following up on the BIP155 addrv2 changes, and starting with7be6ff6in #19845, RPC getnetworkinfo began returning networks with empty names. <details><summary><code>getnetworkinfo</code> on current master</summary><p> ``` "networks": [ { "name": "ipv4", "limited": false, "reachable": true, "proxy": "", "proxy_randomize_credentials": false }, { "name": "ipv6", "limited": false, "reachable": true, "proxy": "", "proxy_randomize_credentials": false }, { "name": "onion", "limited": false, "reachable": true, "proxy": "127.0.0.1:9050", "proxy_randomize_credentials": true }, { "name": "", "limited": false, "reachable": true, "proxy": "", "proxy_randomize_credentials": false }, { "name": "", "limited": false, "reachable": true, "proxy": "", "proxy_randomize_credentials": false } ], ``` </p></details> <details><summary><code>getnetworkinfo</code> on this branch</summary><p> ``` "networks": [ { "name": "ipv4", "limited": false, "reachable": true, "proxy": "", "proxy_randomize_credentials": false }, { "name": "ipv6", "limited": false, "reachable": true, "proxy": "", "proxy_randomize_credentials": false }, { "name": "onion", "limited": false, "reachable": true, "proxy": "127.0.0.1:9050", "proxy_randomize_credentials": true } ], ``` </p></details> This patch: - updates `GetNetworkName()` to the current Network enum - updates `getNetworksInfo()` to ignore as-yet unsupported networks - adds regression tests ACKs for top commit: hebasto: re-ACK7b5bd3102evasild: ACK7b5bd3102Tree-SHA512: 8f12363eb430e6f45e59e3b1d69c2f2eb5ead254ce7a67547d116c3b70138d763157335a3c85b51f684a3b3b502c6aace4f6fa60ac3b988cf7a9475a7423c4d7
This commit is contained in:
@@ -52,14 +52,20 @@ enum Network ParseNetwork(const std::string& net_in) {
|
||||
return NET_UNROUTABLE;
|
||||
}
|
||||
|
||||
std::string GetNetworkName(enum Network net) {
|
||||
switch(net)
|
||||
{
|
||||
std::string GetNetworkName(enum Network net)
|
||||
{
|
||||
switch (net) {
|
||||
case NET_UNROUTABLE: return "unroutable";
|
||||
case NET_IPV4: return "ipv4";
|
||||
case NET_IPV6: return "ipv6";
|
||||
case NET_ONION: return "onion";
|
||||
default: return "";
|
||||
}
|
||||
case NET_I2P: return "i2p";
|
||||
case NET_CJDNS: return "cjdns";
|
||||
case NET_INTERNAL: return "internal";
|
||||
case NET_MAX: assert(false);
|
||||
} // no default case, so the compiler can warn about missing cases
|
||||
|
||||
assert(false);
|
||||
}
|
||||
|
||||
bool static LookupIntern(const std::string& name, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup)
|
||||
|
||||
@@ -497,11 +497,9 @@ static RPCHelpMan getnettotals()
|
||||
static UniValue GetNetworksInfo()
|
||||
{
|
||||
UniValue networks(UniValue::VARR);
|
||||
for(int n=0; n<NET_MAX; ++n)
|
||||
{
|
||||
for (int n = 0; n < NET_MAX; ++n) {
|
||||
enum Network network = static_cast<enum Network>(n);
|
||||
if(network == NET_UNROUTABLE || network == NET_INTERNAL)
|
||||
continue;
|
||||
if (network == NET_UNROUTABLE || network == NET_I2P || network == NET_CJDNS || network == NET_INTERNAL) continue;
|
||||
proxyType proxy;
|
||||
UniValue obj(UniValue::VOBJ);
|
||||
GetProxy(network, proxy);
|
||||
|
||||
Reference in New Issue
Block a user