зеркало из https://github.com/microsoft/CCF.git
PascalCase enum members in REST API responses (#2323)
This commit is contained in:
Родитель
9292b824d1
Коммит
674c4f190b
|
@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||
- String values in query parameters no longer need to be quoted. For instance, you should now call `/network/nodes?host=127.0.0.1` rather than `/network/nodes?host="127.0.0.1"`.
|
||||
- Schema documentation for query parameters should now be added with `add_query_parameter`, rather than `set_auto_schema`. The `In` type of `set_auto_schema` should only be used to describe the request body.
|
||||
- `json_adapter` will no longer try to convert query parameters to a JSON object. The JSON passed as an argument to these handlers will now be populated only by the request body. The query string should be parsed separately, and `http::parse_query(s)` is added as a starting point. This means strings in query parameters no longer need to be quoted.
|
||||
- Enum values returned by built-in REST API endpoints are now PascalCase. Lua governance scripts that use enum values need to be updated as well, for example, `"ACTIVE"` becomes `"Active"` for member info. The same applies when using the `/gov/query` endpoint (#2152).
|
||||
|
||||
## [0.19.1]
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"schemas": {
|
||||
"CodeStatus": {
|
||||
"enum": [
|
||||
"ALLOWED_TO_JOIN"
|
||||
"AllowedToJoin"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
|
@ -297,10 +297,10 @@
|
|||
},
|
||||
"TxStatus": {
|
||||
"enum": [
|
||||
"UNKNOWN",
|
||||
"PENDING",
|
||||
"COMMITTED",
|
||||
"INVALID"
|
||||
"Unknown",
|
||||
"Pending",
|
||||
"Committed",
|
||||
"Invalid"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"schemas": {
|
||||
"CodeStatus": {
|
||||
"enum": [
|
||||
"ALLOWED_TO_JOIN"
|
||||
"AllowedToJoin"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
|
@ -261,11 +261,11 @@
|
|||
},
|
||||
"ProposalState": {
|
||||
"enum": [
|
||||
"OPEN",
|
||||
"ACCEPTED",
|
||||
"WITHDRAWN",
|
||||
"REJECTED",
|
||||
"FAILED"
|
||||
"Open",
|
||||
"Accepted",
|
||||
"Withdrawn",
|
||||
"Rejected",
|
||||
"Failed"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
|
@ -333,10 +333,10 @@
|
|||
},
|
||||
"TxStatus": {
|
||||
"enum": [
|
||||
"UNKNOWN",
|
||||
"PENDING",
|
||||
"COMMITTED",
|
||||
"INVALID"
|
||||
"Unknown",
|
||||
"Pending",
|
||||
"Committed",
|
||||
"Invalid"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"schemas": {
|
||||
"CodeStatus": {
|
||||
"enum": [
|
||||
"ALLOWED_TO_JOIN"
|
||||
"AllowedToJoin"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
|
@ -297,9 +297,9 @@
|
|||
},
|
||||
"NodeStatus": {
|
||||
"enum": [
|
||||
"PENDING",
|
||||
"TRUSTED",
|
||||
"RETIRED"
|
||||
"Pending",
|
||||
"Trusted",
|
||||
"Retired"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
|
@ -343,10 +343,10 @@
|
|||
},
|
||||
"ServiceStatus": {
|
||||
"enum": [
|
||||
"OPENING",
|
||||
"OPEN",
|
||||
"WAITING_FOR_RECOVERY_SHARES",
|
||||
"CLOSED"
|
||||
"Opening",
|
||||
"Open",
|
||||
"WaitingForRecoveryShares",
|
||||
"Closed"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
|
@ -356,10 +356,10 @@
|
|||
},
|
||||
"TxStatus": {
|
||||
"enum": [
|
||||
"UNKNOWN",
|
||||
"PENDING",
|
||||
"COMMITTED",
|
||||
"INVALID"
|
||||
"Unknown",
|
||||
"Pending",
|
||||
"Committed",
|
||||
"Invalid"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
|
@ -368,14 +368,14 @@
|
|||
},
|
||||
"ccf__State": {
|
||||
"enum": [
|
||||
"uninitialized",
|
||||
"initialized",
|
||||
"pending",
|
||||
"partOfPublicNetwork",
|
||||
"partOfNetwork",
|
||||
"readingPublicLedger",
|
||||
"readingPrivateLedger",
|
||||
"verifyingSnapshot"
|
||||
"Uninitialized",
|
||||
"Initialized",
|
||||
"Pending",
|
||||
"PartOfPublicNetwork",
|
||||
"PartOfNetwork",
|
||||
"ReadingPublicLedger",
|
||||
"ReadingPrivateLedger",
|
||||
"VerifyingSnapshot"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
|
|
|
@ -5,7 +5,7 @@ from enum import Enum
|
|||
|
||||
|
||||
class TxStatus(Enum):
|
||||
Unknown = "UNKNOWN"
|
||||
Pending = "PENDING"
|
||||
Committed = "COMMITTED"
|
||||
Invalid = "INVALID"
|
||||
Unknown = "Unknown"
|
||||
Pending = "Pending"
|
||||
Committed = "Committed"
|
||||
Invalid = "Invalid"
|
||||
|
|
|
@ -49,7 +49,7 @@ done
|
|||
if [ ${#trusted_mrenclaves[@]} -eq 0 ]; then
|
||||
for code_id in $(curl -sS --fail -X GET "${node_address}"/node/code "${@}" | jq .versions | jq -c ".[]"); do
|
||||
code_status=$(echo "${code_id}" | jq -r .status)
|
||||
if [ "${code_status}" = "ALLOWED_TO_JOIN" ]; then
|
||||
if [ "${code_status}" = "AllowedToJoin" ]; then
|
||||
trusted_mrenclaves+=($(echo "${code_id}" | jq -r .digest))
|
||||
fi
|
||||
done
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace ccf
|
|||
ALLOWED_TO_JOIN = 0
|
||||
};
|
||||
DECLARE_JSON_ENUM(
|
||||
CodeStatus, {{CodeStatus::ALLOWED_TO_JOIN, "ALLOWED_TO_JOIN"}});
|
||||
CodeStatus, {{CodeStatus::ALLOWED_TO_JOIN, "AllowedToJoin"}});
|
||||
}
|
||||
|
||||
MSGPACK_ADD_ENUM(ccf::CodeStatus);
|
||||
|
|
|
@ -20,9 +20,9 @@ namespace ccf
|
|||
};
|
||||
DECLARE_JSON_ENUM(
|
||||
MemberStatus,
|
||||
{{MemberStatus::ACCEPTED, "ACCEPTED"},
|
||||
{MemberStatus::ACTIVE, "ACTIVE"},
|
||||
{MemberStatus::RETIRED, "RETIRED"}});
|
||||
{{MemberStatus::ACCEPTED, "Accepted"},
|
||||
{MemberStatus::ACTIVE, "Active"},
|
||||
{MemberStatus::RETIRED, "Retired"}});
|
||||
}
|
||||
|
||||
MSGPACK_ADD_ENUM(ccf::MemberStatus);
|
||||
|
|
|
@ -21,9 +21,9 @@ namespace ccf
|
|||
};
|
||||
DECLARE_JSON_ENUM(
|
||||
NodeStatus,
|
||||
{{NodeStatus::PENDING, "PENDING"},
|
||||
{NodeStatus::TRUSTED, "TRUSTED"},
|
||||
{NodeStatus::RETIRED, "RETIRED"}});
|
||||
{{NodeStatus::PENDING, "Pending"},
|
||||
{NodeStatus::TRUSTED, "Trusted"},
|
||||
{NodeStatus::RETIRED, "Retired"}});
|
||||
}
|
||||
|
||||
MSGPACK_ADD_ENUM(ccf::NodeStatus);
|
||||
|
|
|
@ -59,11 +59,11 @@ namespace ccf
|
|||
};
|
||||
DECLARE_JSON_ENUM(
|
||||
ProposalState,
|
||||
{{ProposalState::OPEN, "OPEN"},
|
||||
{ProposalState::ACCEPTED, "ACCEPTED"},
|
||||
{ProposalState::WITHDRAWN, "WITHDRAWN"},
|
||||
{ProposalState::REJECTED, "REJECTED"},
|
||||
{ProposalState::FAILED, "FAILED"}});
|
||||
{{ProposalState::OPEN, "Open"},
|
||||
{ProposalState::ACCEPTED, "Accepted"},
|
||||
{ProposalState::WITHDRAWN, "Withdrawn"},
|
||||
{ProposalState::REJECTED, "Rejected"},
|
||||
{ProposalState::FAILED, "Failed"}});
|
||||
|
||||
struct Proposal
|
||||
{
|
||||
|
|
|
@ -11,14 +11,14 @@ namespace ccf
|
|||
{
|
||||
DECLARE_JSON_ENUM(
|
||||
ccf::State,
|
||||
{{ccf::State::uninitialized, "uninitialized"},
|
||||
{ccf::State::initialized, "initialized"},
|
||||
{ccf::State::pending, "pending"},
|
||||
{ccf::State::partOfPublicNetwork, "partOfPublicNetwork"},
|
||||
{ccf::State::partOfNetwork, "partOfNetwork"},
|
||||
{ccf::State::readingPublicLedger, "readingPublicLedger"},
|
||||
{ccf::State::readingPrivateLedger, "readingPrivateLedger"},
|
||||
{ccf::State::verifyingSnapshot, "verifyingSnapshot"}})
|
||||
{{ccf::State::uninitialized, "Uninitialized"},
|
||||
{ccf::State::initialized, "Initialized"},
|
||||
{ccf::State::pending, "Pending"},
|
||||
{ccf::State::partOfPublicNetwork, "PartOfPublicNetwork"},
|
||||
{ccf::State::partOfNetwork, "PartOfNetwork"},
|
||||
{ccf::State::readingPublicLedger, "ReadingPublicLedger"},
|
||||
{ccf::State::readingPrivateLedger, "ReadingPrivateLedger"},
|
||||
{ccf::State::verifyingSnapshot, "VerifyingSnapshot"}})
|
||||
DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS(GetState::Out)
|
||||
DECLARE_JSON_REQUIRED_FIELDS(GetState::Out, node_id, state, last_signed_seqno)
|
||||
DECLARE_JSON_OPTIONAL_FIELDS(
|
||||
|
|
|
@ -36,19 +36,19 @@ namespace ccf
|
|||
{
|
||||
case TxStatus::Unknown:
|
||||
{
|
||||
return "UNKNOWN";
|
||||
return "Unknown";
|
||||
}
|
||||
case TxStatus::Pending:
|
||||
{
|
||||
return "PENDING";
|
||||
return "Pending";
|
||||
}
|
||||
case TxStatus::Committed:
|
||||
{
|
||||
return "COMMITTED";
|
||||
return "Committed";
|
||||
}
|
||||
case TxStatus::Invalid:
|
||||
{
|
||||
return "INVALID";
|
||||
return "Invalid";
|
||||
}
|
||||
default:
|
||||
{
|
||||
|
|
|
@ -20,11 +20,10 @@ namespace ccf
|
|||
|
||||
DECLARE_JSON_ENUM(
|
||||
ServiceStatus,
|
||||
{{ServiceStatus::OPENING, "OPENING"},
|
||||
{ServiceStatus::OPEN, "OPEN"},
|
||||
{ServiceStatus::WAITING_FOR_RECOVERY_SHARES,
|
||||
"WAITING_FOR_RECOVERY_SHARES"},
|
||||
{ServiceStatus::CLOSED, "CLOSED"}});
|
||||
{{ServiceStatus::OPENING, "Opening"},
|
||||
{ServiceStatus::OPEN, "Open"},
|
||||
{ServiceStatus::WAITING_FOR_RECOVERY_SHARES, "WaitingForRecoveryShares"},
|
||||
{ServiceStatus::CLOSED, "Closed"}});
|
||||
}
|
||||
|
||||
MSGPACK_ADD_ENUM(ccf::ServiceStatus);
|
||||
|
|
|
@ -257,7 +257,7 @@ namespace timing
|
|||
// NB: Eventual header re-org should be exposing API types so
|
||||
// they can be consumed cleanly from C++ clients
|
||||
const auto tx_status = body["status"];
|
||||
if (tx_status == "PENDING" || tx_status == "UNKNOWN")
|
||||
if (tx_status == "Pending" || tx_status == "Unknown")
|
||||
{
|
||||
if (record)
|
||||
{
|
||||
|
@ -268,7 +268,7 @@ namespace timing
|
|||
this_thread::sleep_for(10us);
|
||||
continue;
|
||||
}
|
||||
else if (tx_status == "COMMITTED")
|
||||
else if (tx_status == "Committed")
|
||||
{
|
||||
LOG_INFO_FMT("Found global commit {}.{}", target.view, target.seqno);
|
||||
if (tx_id.has_value())
|
||||
|
@ -293,7 +293,7 @@ namespace timing
|
|||
}
|
||||
return;
|
||||
}
|
||||
else if (tx_status == "INVALID")
|
||||
else if (tx_status == "Invalid")
|
||||
{
|
||||
throw std::logic_error(fmt::format(
|
||||
"Transaction {}.{} is now marked as invalid",
|
||||
|
|
|
@ -10,7 +10,7 @@ return {
|
|||
PASSED = 1
|
||||
PENDING = 0
|
||||
REJECTED = -1
|
||||
STATE_ACTIVE = "ACTIVE"
|
||||
STATE_ACTIVE = "Active"
|
||||
|
||||
-- count member votes
|
||||
member_votes = 0
|
||||
|
|
|
@ -10,7 +10,7 @@ return {
|
|||
PASSED = 1
|
||||
PENDING = 0
|
||||
REJECTED = -1
|
||||
STATE_ACTIVE = "ACTIVE"
|
||||
STATE_ACTIVE = "Active"
|
||||
|
||||
-- count member votes
|
||||
member_votes = 0
|
||||
|
|
|
@ -10,7 +10,7 @@ return {
|
|||
PASSED = 1
|
||||
PENDING = 0
|
||||
REJECTED = -1
|
||||
STATE_ACTIVE = "ACTIVE"
|
||||
STATE_ACTIVE = "Active"
|
||||
|
||||
-- returns true if the member is a recovery member
|
||||
function is_recovery_member(member)
|
||||
|
|
|
@ -102,8 +102,8 @@ def test_update_all_nodes(network, args):
|
|||
versions = sorted(r.body.json()["versions"], key=lambda x: x["digest"])
|
||||
expected = sorted(
|
||||
[
|
||||
{"digest": first_code_id, "status": "ALLOWED_TO_JOIN"},
|
||||
{"digest": new_code_id, "status": "ALLOWED_TO_JOIN"},
|
||||
{"digest": first_code_id, "status": "AllowedToJoin"},
|
||||
{"digest": new_code_id, "status": "AllowedToJoin"},
|
||||
],
|
||||
key=lambda x: x["digest"],
|
||||
)
|
||||
|
@ -116,7 +116,7 @@ def test_update_all_nodes(network, args):
|
|||
versions = sorted(r.body.json()["versions"], key=lambda x: x["digest"])
|
||||
expected = sorted(
|
||||
[
|
||||
{"digest": new_code_id, "status": "ALLOWED_TO_JOIN"},
|
||||
{"digest": new_code_id, "status": "AllowedToJoin"},
|
||||
],
|
||||
key=lambda x: x["digest"],
|
||||
)
|
||||
|
|
|
@ -9,7 +9,7 @@ import infra.logging_app as app
|
|||
import time
|
||||
import json
|
||||
import sys
|
||||
from enum import Enum
|
||||
from enum import Enum, auto
|
||||
import random
|
||||
import os
|
||||
import re
|
||||
|
@ -18,9 +18,9 @@ from loguru import logger as LOG
|
|||
|
||||
|
||||
class TestStatus(Enum):
|
||||
success = 1
|
||||
failure = 2
|
||||
skipped = 3
|
||||
success = auto()
|
||||
failure = auto()
|
||||
skipped = auto()
|
||||
|
||||
|
||||
def mem_stats(network):
|
||||
|
|
|
@ -8,6 +8,7 @@ import infra.network
|
|||
import infra.path
|
||||
import infra.proc
|
||||
import infra.net
|
||||
from infra.node import NodeStatus
|
||||
import infra.e2e_args
|
||||
import suite.test_requirements as reqs
|
||||
import infra.logging_app as app
|
||||
|
@ -153,7 +154,7 @@ def test_node_ids(network, args):
|
|||
info = r.body.json()["nodes"]
|
||||
assert len(info) == 1
|
||||
assert info[0]["node_id"] == node.node_id
|
||||
assert info[0]["status"] == "TRUSTED"
|
||||
assert info[0]["status"] == NodeStatus.TRUSTED.value
|
||||
return network
|
||||
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ def run(args):
|
|||
primary, new_member_proposal, careful_vote
|
||||
)
|
||||
votes_issued += p.votes_for
|
||||
assert new_member_proposal.state == infra.proposal.ProposalState.Accepted
|
||||
assert new_member_proposal.state == infra.proposal.ProposalState.ACCEPTED
|
||||
|
||||
LOG.info("Create new proposal but withdraw it before it is accepted")
|
||||
new_member_proposal, _, _ = network.consortium.generate_and_propose_new_member(
|
||||
|
@ -113,7 +113,7 @@ def run(args):
|
|||
).withdraw(primary, new_member_proposal)
|
||||
infra.checker.Checker(c)(response)
|
||||
assert response.status_code == http.HTTPStatus.OK.value
|
||||
assert response.body.json()["state"] == ProposalState.Withdrawn.value
|
||||
assert response.body.json()["state"] == ProposalState.WITHDRAWN.value
|
||||
withdrawals_issued += 1
|
||||
|
||||
# Refresh ledger to beginning
|
||||
|
|
|
@ -86,7 +86,7 @@ class Consortium:
|
|||
"text": """tables = ...
|
||||
non_retired_members = {}
|
||||
tables["public:ccf.gov.members.info"]:foreach(function(service_id, info)
|
||||
if info["status"] ~= "RETIRED" then
|
||||
if info["status"] ~= "Retired" then
|
||||
table.insert(non_retired_members, {service_id, info})
|
||||
end
|
||||
end)
|
||||
|
@ -242,7 +242,7 @@ class Consortium:
|
|||
):
|
||||
response = None
|
||||
|
||||
if proposal.state != ProposalState.Accepted:
|
||||
if proposal.state != ProposalState.ACCEPTED:
|
||||
active_members = self.get_active_members()
|
||||
majority_count = int(len(self.get_active_members()) / 2 + 1)
|
||||
|
||||
|
@ -272,7 +272,7 @@ class Consortium:
|
|||
view = response.view
|
||||
ccf.commit.wait_for_commit(c, seqno, view, timeout=timeout)
|
||||
|
||||
if proposal.state != ProposalState.Accepted:
|
||||
if proposal.state != ProposalState.ACCEPTED:
|
||||
raise infra.proposal.ProposalNotAccepted(proposal)
|
||||
return proposal
|
||||
|
||||
|
@ -314,7 +314,7 @@ class Consortium:
|
|||
"/gov/read",
|
||||
{"table": "public:ccf.gov.nodes.info", "key": node_to_retire.node_id},
|
||||
)
|
||||
assert r.body.json()["status"] == infra.node.NodeStatus.RETIRED.name
|
||||
assert r.body.json()["status"] == infra.node.NodeStatus.RETIRED.value
|
||||
|
||||
def trust_node(self, remote_node, node_id, timeout=3):
|
||||
if not self._check_node_exists(
|
||||
|
@ -486,7 +486,7 @@ class Consortium:
|
|||
proposal = self.get_any_active_member().propose(remote_node, proposal_body)
|
||||
proposal.vote_for = careful_vote
|
||||
r = self.vote_using_majority(remote_node, proposal, careful_vote)
|
||||
if proposal.state == infra.proposal.ProposalState.Accepted:
|
||||
if proposal.state == infra.proposal.ProposalState.ACCEPTED:
|
||||
self.recovery_threshold = recovery_threshold
|
||||
return r
|
||||
|
||||
|
@ -544,8 +544,8 @@ class Consortium:
|
|||
current_cert == expected_cert[:-1].decode()
|
||||
), "Current service certificate did not match with networkcert.pem"
|
||||
assert (
|
||||
current_status == status.name
|
||||
), f"Service status {current_status} (expected {status.name})"
|
||||
current_status == status.value
|
||||
), f"Service status {current_status} (expected {status.value})"
|
||||
|
||||
def _check_node_exists(self, remote_node, node_id, node_status=None):
|
||||
member = self.get_any_active_member()
|
||||
|
@ -555,7 +555,7 @@ class Consortium:
|
|||
)
|
||||
|
||||
if r.status_code != http.HTTPStatus.OK.value or (
|
||||
node_status and r.body.json()["status"] != node_status.name
|
||||
node_status and r.body.json()["status"] != node_status.value
|
||||
):
|
||||
return False
|
||||
|
||||
|
@ -581,7 +581,7 @@ class Consortium:
|
|||
if not exists:
|
||||
raise TimeoutError(
|
||||
f"Node {node_id} has not yet been recorded in the store"
|
||||
+ getattr(node_status, f" with status {node_status.name}", "")
|
||||
+ getattr(node_status, f" with status {node_status.value}", "")
|
||||
)
|
||||
|
||||
def wait_for_all_nodes_to_be_trusted(self, remote_node, nodes, timeout=3):
|
||||
|
|
|
@ -22,9 +22,9 @@ class NoRecoveryShareFound(Exception):
|
|||
|
||||
|
||||
class MemberStatus(Enum):
|
||||
ACCEPTED = 0
|
||||
ACTIVE = 1
|
||||
RETIRED = 2
|
||||
ACCEPTED = "Accepted"
|
||||
ACTIVE = "Active"
|
||||
RETIRED = "Retired"
|
||||
|
||||
|
||||
class MemberInfo(NamedTuple):
|
||||
|
@ -141,7 +141,7 @@ class Member:
|
|||
with remote_node.client(*self.auth(write=True)) as c:
|
||||
r = c.post(f"/gov/proposals/{proposal.proposal_id}/withdraw")
|
||||
if r.status_code == http.HTTPStatus.OK.value:
|
||||
proposal.state = infra.proposal.ProposalState.Withdrawn
|
||||
proposal.state = infra.proposal.ProposalState.WITHDRAWN
|
||||
return r
|
||||
|
||||
def update_ack_state_digest(self, remote_node):
|
||||
|
|
|
@ -4,7 +4,7 @@ import os
|
|||
import time
|
||||
import logging
|
||||
from contextlib import contextmanager
|
||||
from enum import Enum, IntEnum
|
||||
from enum import Enum, IntEnum, auto
|
||||
from ccf.clients import CCFConnectionException, flush_info
|
||||
import infra.path
|
||||
import infra.proc
|
||||
|
@ -27,15 +27,15 @@ COMMON_FOLDER = "common"
|
|||
|
||||
|
||||
class NodeRole(Enum):
|
||||
ANY = 0
|
||||
PRIMARY = 1
|
||||
BACKUP = 2
|
||||
ANY = auto()
|
||||
PRIMARY = auto()
|
||||
BACKUP = auto()
|
||||
|
||||
|
||||
class ServiceStatus(Enum):
|
||||
OPENING = 1
|
||||
OPEN = 2
|
||||
CLOSED = 3
|
||||
OPENING = "Opening"
|
||||
OPEN = "Open"
|
||||
CLOSED = "Closed"
|
||||
|
||||
|
||||
class ParticipantsCurve(IntEnum):
|
||||
|
@ -286,7 +286,7 @@ class Network:
|
|||
)
|
||||
self.wait_for_state(
|
||||
node,
|
||||
"partOfPublicNetwork",
|
||||
infra.node.State.PART_OF_PUBLIC_NETWORK.value,
|
||||
timeout=args.ledger_recovery_timeout,
|
||||
)
|
||||
else:
|
||||
|
@ -447,7 +447,9 @@ class Network:
|
|||
|
||||
for node in self.get_joined_nodes():
|
||||
self.wait_for_state(
|
||||
node, "partOfPublicNetwork", timeout=args.ledger_recovery_timeout
|
||||
node,
|
||||
infra.node.State.PART_OF_PUBLIC_NETWORK.value,
|
||||
timeout=args.ledger_recovery_timeout,
|
||||
)
|
||||
self.wait_for_all_nodes_to_catch_up(primary)
|
||||
LOG.success("All nodes joined public network")
|
||||
|
@ -465,7 +467,9 @@ class Network:
|
|||
|
||||
for node in self.get_joined_nodes():
|
||||
self.wait_for_state(
|
||||
node, "partOfNetwork", timeout=args.ledger_recovery_timeout
|
||||
node,
|
||||
infra.node.State.PART_OF_NETWORK.value,
|
||||
timeout=args.ledger_recovery_timeout,
|
||||
)
|
||||
self._wait_for_app_open(node)
|
||||
|
||||
|
@ -677,7 +681,7 @@ class Network:
|
|||
raise TimeoutError(
|
||||
f"Timed out waiting for state {state} on node {node.node_id}"
|
||||
)
|
||||
if state == "partOfNetwork":
|
||||
if state == infra.node.State.PART_OF_NETWORK.value:
|
||||
self.status = ServiceStatus.OPEN
|
||||
|
||||
def _wait_for_app_open(self, node, timeout=3):
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# Licensed under the Apache 2.0 License.
|
||||
|
||||
from contextlib import contextmanager, closing
|
||||
from enum import Enum
|
||||
from enum import Enum, auto
|
||||
import infra.crypto
|
||||
import infra.remote
|
||||
import infra.net
|
||||
|
@ -16,15 +16,26 @@ from loguru import logger as LOG
|
|||
|
||||
|
||||
class NodeNetworkState(Enum):
|
||||
stopped = 0
|
||||
started = 1
|
||||
joined = 2
|
||||
stopped = auto()
|
||||
started = auto()
|
||||
joined = auto()
|
||||
|
||||
|
||||
class NodeStatus(Enum):
|
||||
PENDING = 0
|
||||
TRUSTED = 1
|
||||
RETIRED = 2
|
||||
PENDING = "Pending"
|
||||
TRUSTED = "Trusted"
|
||||
RETIRED = "Retired"
|
||||
|
||||
|
||||
class State(Enum):
|
||||
UNINITIALIZED = "Uninitialized"
|
||||
INITIALIZED = "Initialized"
|
||||
PENDING = "Pending"
|
||||
PART_OF_PUBLIC_NETWORK = "PartOfPublicNetwork"
|
||||
PART_OF_NETWORK = "PartOfNetwork"
|
||||
READING_PUBLIC_LEDGER = "ReadingPublicLedger"
|
||||
READING_PRIVATE_LEDGER = "ReadingPrivateLedger"
|
||||
VERIFYING_SNAPSHOT = "VerifyingSnapshot"
|
||||
|
||||
|
||||
def is_addr_local(host, port):
|
||||
|
|
|
@ -18,11 +18,11 @@ class ProposalNotAccepted(Exception):
|
|||
|
||||
# Values defined in node/proposals.h
|
||||
class ProposalState(Enum):
|
||||
Open = "OPEN"
|
||||
Accepted = "ACCEPTED"
|
||||
Withdrawn = "WITHDRAWN"
|
||||
Rejected = "REJECTED"
|
||||
Failed = "FAILED"
|
||||
OPEN = "Open"
|
||||
ACCEPTED = "Accepted"
|
||||
WITHDRAWN = "Withdrawn"
|
||||
REJECTED = "Rejected"
|
||||
FAILED = "Failed"
|
||||
|
||||
|
||||
class Proposal:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# Licensed under the Apache 2.0 License.
|
||||
import os
|
||||
import time
|
||||
from enum import Enum
|
||||
from enum import Enum, auto
|
||||
import paramiko
|
||||
import subprocess
|
||||
from contextlib import contextmanager
|
||||
|
@ -832,6 +832,6 @@ class CCFRemote(object):
|
|||
|
||||
|
||||
class StartType(Enum):
|
||||
new = 0
|
||||
join = 1
|
||||
recover = 2
|
||||
new = auto()
|
||||
join = auto()
|
||||
recover = auto()
|
||||
|
|
|
@ -124,7 +124,7 @@ def test_governance(network, args):
|
|||
try:
|
||||
network.consortium.open_network(node)
|
||||
except infra.proposal.ProposalNotAccepted as e:
|
||||
assert e.proposal.state == infra.proposal.ProposalState.Failed
|
||||
assert e.proposal.state == infra.proposal.ProposalState.FAILED
|
||||
|
||||
LOG.info("Proposal to add a new member (with different curve)")
|
||||
(
|
||||
|
@ -143,11 +143,11 @@ def test_governance(network, args):
|
|||
None,
|
||||
)
|
||||
assert proposal_entry
|
||||
assert proposal_entry.state == ProposalState.Open
|
||||
assert proposal_entry.state == ProposalState.OPEN
|
||||
|
||||
LOG.info("Rest of consortium accept the proposal")
|
||||
network.consortium.vote_using_majority(node, new_member_proposal, careful_vote)
|
||||
assert new_member_proposal.state == ProposalState.Accepted
|
||||
assert new_member_proposal.state == ProposalState.ACCEPTED
|
||||
|
||||
# Manually add new member to consortium
|
||||
network.consortium.members.append(new_member)
|
||||
|
@ -194,7 +194,7 @@ def test_governance(network, args):
|
|||
|
||||
LOG.debug("Members vote for proposal")
|
||||
network.consortium.vote_using_majority(node, proposal, careful_vote)
|
||||
assert proposal.state == infra.proposal.ProposalState.Accepted
|
||||
assert proposal.state == infra.proposal.ProposalState.ACCEPTED
|
||||
|
||||
LOG.info("New member makes a new proposal")
|
||||
(
|
||||
|
@ -212,7 +212,7 @@ def test_governance(network, args):
|
|||
LOG.debug("Proposer withdraws their proposal")
|
||||
response = new_member.withdraw(node, proposal)
|
||||
assert response.status_code == http.HTTPStatus.OK.value
|
||||
assert proposal.state == infra.proposal.ProposalState.Withdrawn
|
||||
assert proposal.state == infra.proposal.ProposalState.WITHDRAWN
|
||||
|
||||
proposals = network.consortium.get_proposals(primary)
|
||||
proposal_entry = next(
|
||||
|
@ -220,7 +220,7 @@ def test_governance(network, args):
|
|||
None,
|
||||
)
|
||||
assert proposal_entry
|
||||
assert proposal_entry.state == ProposalState.Withdrawn
|
||||
assert proposal_entry.state == ProposalState.WITHDRAWN
|
||||
|
||||
LOG.debug("Further withdraw proposals fail")
|
||||
response = new_member.withdraw(node, proposal)
|
||||
|
|
|
@ -170,7 +170,7 @@ def recovery_shares_scenario(args):
|
|||
test_retire_member(network, args, recovery_member=True)
|
||||
assert False, "Retiring a recovery member should not be possible"
|
||||
except infra.proposal.ProposalNotAccepted as e:
|
||||
assert e.proposal.state == infra.proposal.ProposalState.Failed
|
||||
assert e.proposal.state == infra.proposal.ProposalState.FAILED
|
||||
|
||||
# However, retiring a non-recovery member is allowed
|
||||
LOG.info("Retiring a non-recovery member is still possible")
|
||||
|
@ -216,7 +216,7 @@ def recovery_shares_scenario(args):
|
|||
test_set_recovery_threshold(network, args, recovery_threshold=0)
|
||||
assert False, "Setting recovery threshold to 0 should not be possible"
|
||||
except infra.proposal.ProposalNotAccepted as e:
|
||||
assert e.proposal.state == infra.proposal.ProposalState.Failed
|
||||
assert e.proposal.state == infra.proposal.ProposalState.FAILED
|
||||
|
||||
LOG.info(
|
||||
"Set recovery threshold to more that number of active recovery members is impossible"
|
||||
|
@ -232,7 +232,7 @@ def recovery_shares_scenario(args):
|
|||
False
|
||||
), "Setting recovery threshold to more than number of active recovery members should not be possible"
|
||||
except infra.proposal.ProposalNotAccepted as e:
|
||||
assert e.proposal.state == infra.proposal.ProposalState.Failed
|
||||
assert e.proposal.state == infra.proposal.ProposalState.FAILED
|
||||
|
||||
LOG.info(
|
||||
"Setting recovery threshold to current threshold does not update shares"
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
# Licensed under the Apache 2.0 License.
|
||||
import infra.e2e_args
|
||||
import infra.network
|
||||
import infra.node
|
||||
import infra.logging_app as app
|
||||
import infra.checker
|
||||
import suite.test_requirements as reqs
|
||||
|
@ -91,7 +92,9 @@ def test_share_resilience(network, args, from_snapshot=False):
|
|||
|
||||
for node in recovered_network.get_joined_nodes():
|
||||
recovered_network.wait_for_state(
|
||||
node, "partOfNetwork", timeout=args.ledger_recovery_timeout
|
||||
node,
|
||||
infra.node.State.PART_OF_NETWORK.value,
|
||||
timeout=args.ledger_recovery_timeout,
|
||||
)
|
||||
|
||||
recovered_network.consortium.check_for_service(
|
||||
|
|
|
@ -105,7 +105,7 @@ def can_kill_n_nodes(nodes_to_kill_count):
|
|||
"text": """tables = ...
|
||||
trusted_nodes_count = 0
|
||||
tables["public:ccf.gov.nodes.info"]:foreach(function(node_id, details)
|
||||
if details["status"] == "TRUSTED" then
|
||||
if details["status"] == "Trusted" then
|
||||
trusted_nodes_count = trusted_nodes_count + 1
|
||||
end
|
||||
end)
|
||||
|
|
Загрузка…
Ссылка в новой задаче