diff --git a/integration_tests/test_e2ee.py b/integration_tests/test_e2ee.py index ebe6a3dcae..ca560e56ac 100644 --- a/integration_tests/test_e2ee.py +++ b/integration_tests/test_e2ee.py @@ -1,12 +1,31 @@ -from .utils import prepare_cipherfile - - def test_encrypt_decrypt(cronos): - cli = cronos.cosmos_cli() + cli0 = cronos.cosmos_cli() cli1 = cronos.cosmos_cli(1) + + # gen two keys for two accounts name0 = "key0" name1 = "key1" + pubkey0 = cli0.keygen(keyring_name=name0) + pubkey1 = cli1.keygen(keyring_name=name1) + sender = "validator" + cli0.register_e2ee_key(pubkey0, _from=sender) + cli1.register_e2ee_key(pubkey1, _from=sender) + # query in batch + assert cli0.query_e2ee_keys(cli0.address(sender), cli1.address(sender)) == [ + pubkey0, + pubkey1, + ] + # prepare data file to encrypt content = "Hello World!" - cipherfile = prepare_cipherfile(cli, cli1, name0, name1, content) - assert cli.decrypt(cipherfile, identity=name0) == content - assert cli1.decrypt(cipherfile, identity=name1) == content + plainfile = cli0.data_dir / "plaintext" + plainfile.write_text(content) + cipherfile = cli0.data_dir / "ciphertext" + cli0.encrypt( + plainfile, + cli0.address(sender), + cli1.address(sender), + output=cipherfile, + ) + + assert cli0.decrypt(cipherfile, identity="key0") == content + assert cli1.decrypt(cipherfile, identity="key1") == content diff --git a/integration_tests/test_gov_update_params.py b/integration_tests/test_gov_update_params.py index 69f3f41d41..dcc56d4121 100644 --- a/integration_tests/test_gov_update_params.py +++ b/integration_tests/test_gov_update_params.py @@ -9,7 +9,6 @@ approve_proposal, deploy_contract, eth_to_bech32, - prepare_cipherfile, wait_for_new_blocks, wait_for_port, ) @@ -96,18 +95,31 @@ def test_gov_update_params(cronos, tmp_path): print("params", rsp) assert rsp == params - # gen two keys for two accounts + # gen identity key for one account name = "e2ee-identity" - cli1 = cronos.cosmos_cli(1) addr = cli.address("user") content = json.dumps({"addresses": [addr]}) - cipherfile = prepare_cipherfile(cli, cli1, name, name, content) - cronos.supervisorctl("stop", "all") - cronos.supervisorctl("start", "cronos_777-1-node0", "cronos_777-1-node1") + pubkey0 = cli.keygen(keyring_name=name) + sender = "validator" + cli.register_e2ee_key(pubkey0, _from=sender) + assert cli.query_e2ee_key(cli.address(sender)) == pubkey0 + # prepare data file to encrypt + plainfile = cli.data_dir / "plaintext" + plainfile.write_text(content) + cipherfile = cli.data_dir / "ciphertext" + cli.encrypt( + plainfile, + cli.address(sender), + output=cipherfile, + ) + cronos.supervisorctl("stop", "cronos_777-1-node0") + cronos.supervisorctl("start", "cronos_777-1-node0") wait_for_port(ports.evmrpc_port(cronos.base_port(0))) rsp = cli.store_blocklist(cipherfile, from_="validator") assert rsp["code"] == 0, rsp["raw_log"] wait_for_new_blocks(cli, 2) - rsp = cli.transfer(addr, cli.address("validator"), "1basetcro") - assert rsp["code"] != 0 - assert "signer is blocked" in rsp["raw_log"] + with pytest.raises(AssertionError): + rsp = cli.transfer(addr, cli.address("validator"), "1basetcro") + cli1 = cronos.cosmos_cli(1) + rsp = cli1.transfer(cli1.address("validator"), cli1.address("validator"), "1basetcro") + assert rsp["code"] == 0, rsp["raw_log"] \ No newline at end of file diff --git a/integration_tests/utils.py b/integration_tests/utils.py index fd9cfb933b..323207d83e 100644 --- a/integration_tests/utils.py +++ b/integration_tests/utils.py @@ -732,28 +732,3 @@ def get_send_enable(port): url = f"http://127.0.0.1:{port}/cosmos/bank/v1beta1/params" raw = requests.get(url).json() return raw["params"]["send_enabled"] - - -def prepare_cipherfile(cli0, cli1, name0, name1, content): - # gen two keys for two accounts - pubkey0 = cli0.keygen(keyring_name=name0) - pubkey1 = cli1.keygen(keyring_name=name1) - sender = "validator" - cli0.register_e2ee_key(pubkey0, _from=sender) - cli1.register_e2ee_key(pubkey1, _from=sender) - # query in batch - assert cli0.query_e2ee_keys(cli0.address(sender), cli1.address(sender)) == [ - pubkey0, - pubkey1, - ] - # prepare data file to encrypt - plainfile = cli0.data_dir / "plaintext" - plainfile.write_text(content) - cipherfile = cli0.data_dir / "ciphertext" - cli0.encrypt( - plainfile, - cli0.address(sender), - cli1.address(sender), - output=cipherfile, - ) - return cipherfile