2019-06-17 16:03:22 +03:00
|
|
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
# Licensed under the Apache 2.0 License.
|
2019-06-19 13:35:56 +03:00
|
|
|
import sys
|
2019-06-17 16:03:22 +03:00
|
|
|
import e2e_args
|
|
|
|
import infra.ccf
|
|
|
|
import infra.proc
|
|
|
|
import json
|
|
|
|
|
|
|
|
import logging
|
|
|
|
import time
|
|
|
|
|
|
|
|
from loguru import logger as LOG
|
|
|
|
|
|
|
|
|
|
|
|
def run(args):
|
|
|
|
hosts = ["localhost", "localhost"]
|
|
|
|
|
|
|
|
with infra.ccf.network(
|
|
|
|
hosts, args.build_dir, args.debug_nodes, args.perf_nodes, pdb=args.pdb
|
|
|
|
) as network:
|
|
|
|
primary, others = network.start_and_join(args)
|
|
|
|
|
|
|
|
# add a valid node
|
2019-06-26 17:51:10 +03:00
|
|
|
res = network.create_and_add_node("libloggingenc", args)
|
2019-07-12 17:32:10 +03:00
|
|
|
assert res[0]
|
2019-06-17 16:03:22 +03:00
|
|
|
new_node = res[1]
|
|
|
|
|
2019-07-04 11:59:35 +03:00
|
|
|
# attempt to add a node having the host and port fields
|
|
|
|
# similar to a the ones of an existing node
|
|
|
|
assert (
|
|
|
|
network.add_node(new_node.remote.info()).error["code"]
|
|
|
|
== infra.jsonrpc.ErrorCode.INVALID_PARAMS
|
|
|
|
)
|
|
|
|
|
2019-06-17 16:03:22 +03:00
|
|
|
# add an invalid node
|
2019-06-26 17:51:10 +03:00
|
|
|
assert network.create_and_add_node("libluagenericenc", args, False) == (
|
2019-06-17 16:03:22 +03:00
|
|
|
False,
|
|
|
|
infra.jsonrpc.ErrorCode.CODE_ID_NOT_FOUND,
|
|
|
|
)
|
|
|
|
|
2019-07-17 17:45:24 +03:00
|
|
|
new_node.join_network(network)
|
2019-06-26 17:51:10 +03:00
|
|
|
network.wait_for_node_commit_sync()
|
2019-06-17 16:03:22 +03:00
|
|
|
|
2019-07-12 17:32:10 +03:00
|
|
|
# retire a node
|
2019-07-17 18:32:26 +03:00
|
|
|
network.retire_node(1, primary, new_node.node_id)
|
2019-07-12 17:32:10 +03:00
|
|
|
|
2019-06-17 16:03:22 +03:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
|
|
|
def add(parser):
|
|
|
|
parser.add_argument(
|
|
|
|
"-p",
|
|
|
|
"--package",
|
|
|
|
help="The enclave package to load (e.g., libsimplebank)",
|
|
|
|
default="libloggingenc",
|
|
|
|
)
|
|
|
|
|
|
|
|
args = e2e_args.cli_args(add)
|
2019-06-19 13:35:56 +03:00
|
|
|
|
|
|
|
if args.enclave_type != "debug":
|
|
|
|
LOG.error("This test can only run in real enclaves, skipping")
|
|
|
|
sys.exit(0)
|
|
|
|
|
2019-06-17 16:03:22 +03:00
|
|
|
args.package = args.app_script and "libluagenericenc" or "libloggingenc"
|
|
|
|
run(args)
|