-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
49 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters