Test CryptMessage plugin using testAction function

This commit is contained in:
shortcutme 2019-08-02 16:14:17 +02:00
parent fbafd23177
commit fa970fa102
No known key found for this signature in database
GPG key ID: 5B63BAE6CB9613AE

View file

@ -47,26 +47,25 @@ class TestCrypt:
assert pub1 != pub2 assert pub1 != pub2
def testEcies(self, ui_websocket): def testEcies(self, ui_websocket):
ui_websocket.actionUserPublickey(0, 0) pub = ui_websocket.testAction("UserPublickey")
pub = ui_websocket.ws.getResult()
ui_websocket.actionEciesEncrypt(0, "hello", pub) encrypted = ui_websocket.testAction("EciesEncrypt", "hello", pub)
encrypted = ui_websocket.ws.getResult()
assert len(encrypted) == 180 assert len(encrypted) == 180
# Don't allow decrypt using other privatekey index # Don't allow decrypt using other privatekey index
ui_websocket.actionEciesDecrypt(0, encrypted, 123) decrypted = ui_websocket.testAction("EciesDecrypt", encrypted, 123)
decrypted = ui_websocket.ws.getResult()
assert decrypted != "hello" assert decrypted != "hello"
# Decrypt using correct privatekey # Decrypt using correct privatekey
ui_websocket.actionEciesDecrypt(0, encrypted) decrypted = ui_websocket.testAction("EciesDecrypt", encrypted)
decrypted = ui_websocket.ws.getResult()
assert decrypted == "hello" assert decrypted == "hello"
# Decrypt incorrect text
decrypted = ui_websocket.testAction("EciesDecrypt", "baad")
assert decrypted == None
# Decrypt batch # Decrypt batch
ui_websocket.actionEciesDecrypt(0, [encrypted, "baad", encrypted]) decrypted = ui_websocket.testAction("EciesDecrypt", [encrypted, "baad", encrypted])
decrypted = ui_websocket.ws.getResult()
assert decrypted == ["hello", None, "hello"] assert decrypted == ["hello", None, "hello"]
def testEciesUtf8(self, ui_websocket): def testEciesUtf8(self, ui_websocket):