зеркало из https://github.com/microsoft/CCF.git
Fix Python formatting
This commit is contained in:
Родитель
7baaab2e47
Коммит
3db24e8eb7
|
@ -268,7 +268,7 @@ def set_js_app(app_script_path: str, **kwargs):
|
|||
|
||||
@cli_proposal
|
||||
def set_module(module_name, module_path, **kwargs):
|
||||
if module_name.endswith(".js"):
|
||||
if module_name.endswith(".js"):
|
||||
with open(module_path) as f:
|
||||
js = f.read()
|
||||
proposal_args = {"name": module_name, "module": {"js": js}}
|
||||
|
|
|
@ -33,67 +33,72 @@ return {
|
|||
}
|
||||
"""
|
||||
|
||||
|
||||
@reqs.description("Test module set and remove")
|
||||
def test_module_set_and_remove(network, args):
|
||||
primary, _ = network.find_nodes()
|
||||
|
||||
LOG.info("Member makes a module update proposal")
|
||||
with tempfile.NamedTemporaryFile('w') as f:
|
||||
with tempfile.NamedTemporaryFile("w") as f:
|
||||
f.write(MODULE_CONTENT)
|
||||
f.flush()
|
||||
proposal_body, _ = ccf.proposal_generator.set_module("foo.js", f.name)
|
||||
proposal = network.consortium.get_any_active_member().propose(primary, proposal_body)
|
||||
proposal = network.consortium.get_any_active_member().propose(
|
||||
primary, proposal_body
|
||||
)
|
||||
network.consortium.vote_using_majority(primary, proposal)
|
||||
|
||||
with primary.client(f"member{network.consortium.get_any_active_member().member_id}") as c:
|
||||
r = c.post(
|
||||
"/gov/read", {"table": "ccf.modules", "key": "foo.js"}
|
||||
)
|
||||
|
||||
with primary.client(
|
||||
f"member{network.consortium.get_any_active_member().member_id}"
|
||||
) as c:
|
||||
r = c.post("/gov/read", {"table": "ccf.modules", "key": "foo.js"})
|
||||
assert r.status_code == 200, r.status_code
|
||||
assert r.body['js'] == MODULE_CONTENT, r.body
|
||||
assert r.body["js"] == MODULE_CONTENT, r.body
|
||||
|
||||
LOG.info("Member makes a module remove proposal")
|
||||
proposal_body, _ = ccf.proposal_generator.remove_module("foo.js")
|
||||
proposal = network.consortium.get_any_active_member().propose(primary, proposal_body)
|
||||
proposal = network.consortium.get_any_active_member().propose(
|
||||
primary, proposal_body
|
||||
)
|
||||
network.consortium.vote_using_majority(primary, proposal)
|
||||
|
||||
with primary.client(f"member{network.consortium.get_any_active_member().member_id}") as c:
|
||||
r = c.post(
|
||||
"/gov/read", {"table": "ccf.modules", "key": "foo.js"}
|
||||
)
|
||||
with primary.client(
|
||||
f"member{network.consortium.get_any_active_member().member_id}"
|
||||
) as c:
|
||||
r = c.post("/gov/read", {"table": "ccf.modules", "key": "foo.js"})
|
||||
assert r.status_code == 400, r.status_code
|
||||
|
||||
return network
|
||||
|
||||
|
||||
@reqs.description("Test module import")
|
||||
def test_module_import(network, args):
|
||||
primary, _ = network.find_nodes()
|
||||
|
||||
# Add module
|
||||
with tempfile.NamedTemporaryFile('w') as f:
|
||||
with tempfile.NamedTemporaryFile("w") as f:
|
||||
f.write(MODULE_CONTENT)
|
||||
f.flush()
|
||||
proposal_body, _ = ccf.proposal_generator.set_module("foo.js", f.name)
|
||||
proposal = network.consortium.get_any_active_member().propose(primary, proposal_body)
|
||||
proposal = network.consortium.get_any_active_member().propose(
|
||||
primary, proposal_body
|
||||
)
|
||||
network.consortium.vote_using_majority(primary, proposal)
|
||||
|
||||
# Update JS app which imports module
|
||||
with tempfile.NamedTemporaryFile('w') as f:
|
||||
with tempfile.NamedTemporaryFile("w") as f:
|
||||
f.write(APP_SCRIPT)
|
||||
f.flush()
|
||||
network.consortium.set_js_app(
|
||||
remote_node=primary, app_script_path=f.name
|
||||
)
|
||||
network.consortium.set_js_app(remote_node=primary, app_script_path=f.name)
|
||||
|
||||
with primary.client("user0") as c:
|
||||
r = c.post(
|
||||
"/app/test_module", {}
|
||||
)
|
||||
r = c.post("/app/test_module", {})
|
||||
assert r.status_code == 200, r.status_code
|
||||
assert r.body == MODULE_RETURN
|
||||
|
||||
return network
|
||||
|
||||
|
||||
def run(args):
|
||||
hosts = ["localhost"] * (3 if args.consensus == "pbft" else 2)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче