fix: real errors test

This commit is contained in:
Coline
2022-07-22 11:59:45 +02:00
parent 1dbe04c8ca
commit 8da09ec892
7 changed files with 47 additions and 38 deletions

View File

@@ -1,5 +1,7 @@
from time import sleep
import pytest
import ethereum_client
from ethereum_client.utils import compare_screenshot, compare_screenshot, parse_sign_response, save_screenshot, PATH_IMG
from ethereum_client.transaction import PersonalTransaction
@@ -56,7 +58,7 @@ def test_personal_sign_reject(cmd):
msg="This is an reject sign"
)
try:
with pytest.raises(ethereum_client.exception.errors.DenyError) as error:
with cmd.personal_sign_tx(bip32_path=bip32_path, transaction=transaction, result=result) as ex:
sleep(0.5)
@@ -95,8 +97,6 @@ def test_personal_sign_reject(cmd):
# Cancel signature
compare_screenshot(cmd, f"screenshots/eip191/{PATH_IMG[cmd.model]}/personal_sign_reject/00003.png")
cmd.client.press_and_release('both')
except ethereum_client.exception.errors.DenyError as error:
assert error.args[0] == '0x6985'
def test_personal_sign_non_ascii(cmd):

View File

@@ -1,5 +1,7 @@
from time import sleep
import pytest
from ethereum_client.utils import compare_screenshot, save_screenshot, PATH_IMG, parse_sign_response
from ethereum_client.transaction import EIP712
import ethereum_client
@@ -81,7 +83,7 @@ def test_sign_eip_712_hashed_msg_reject(cmd):
msg_hash="9d96be8a7cca396e711a3ba356bd9878df02a726d753ddb6cda3c507d888bc77"
)
try:
with pytest.raises(ethereum_client.exception.errors.DenyError) as error:
with cmd.sign_eip712(bip32_path=bip32_path, transaction=transaction, result=result) as ex:
sleep(0.5)
@@ -142,8 +144,6 @@ def test_sign_eip_712_hashed_msg_reject(cmd):
# Cancel signature
compare_screenshot(cmd, f"screenshots/eip712/{PATH_IMG[cmd.model]}/sign_eip_712_hashed_msg_reject/00006.png")
cmd.client.press_and_release('both')
except ethereum_client.exception.errors.DenyError as error:
assert error.args[0] == '0x6985'
def test_sign_eip_712_bad_domain(cmd):
@@ -155,11 +155,11 @@ def test_sign_eip_712_bad_domain(cmd):
msg_hash="9d96be8a7cca396e711a3ba356bd9878df02a726d753ddb6cda3c507d888bc77"
)
try:
with pytest.raises(ethereum_client.exception.errors.UnknownDeviceError) as error:
with cmd.sign_eip712(bip32_path=bip32_path, transaction=transaction, result=result) as ex:
pass
except ethereum_client.exception.errors.UnknownDeviceError as error:
assert error.args[0] == '0x6a80'
def test_sign_eip_712_bad_msg(cmd):
@@ -171,9 +171,9 @@ def test_sign_eip_712_bad_msg(cmd):
msg_hash="deadbeef"
)
try:
with pytest.raises(ethereum_client.exception.errors.UnknownDeviceError) as error:
with cmd.sign_eip712(bip32_path=bip32_path, transaction=transaction, result=result) as ex:
pass
except ethereum_client.exception.errors.UnknownDeviceError as error:
assert error.args[0] == '0x6a80'

View File

@@ -1,5 +1,7 @@
from time import sleep
import pytest
import ethereum_client
from ethereum_client.utils import compare_screenshot, save_screenshot, PATH_IMG, parse_sign_response
from ethereum_client.plugin import Plugin
@@ -92,7 +94,8 @@ def test_transfer_erc1155_without_nft_provide_info(cmd):
result: list = []
if cmd.model == "nanox" or cmd.model == "nanosp":
try:
with pytest.raises(ethereum_client.exception.errors.UnknownDeviceError) as error:
cmd.set_plugin(plugin=PLUGIN)
@@ -100,24 +103,23 @@ def test_transfer_erc1155_without_nft_provide_info(cmd):
with cmd.send_apdu_context(SIGN_MORE, result) as ex:
pass
except ethereum_client.exception.errors.UnknownDeviceError as error:
assert error.args[0] == '0x6a80'
assert error.args[0] == '0x6a80'
def test_transfer_erc1155_without_set_plugin(cmd):
result: list = []
if cmd.model == "nanox" or cmd.model == "nanosp":
try:
with pytest.raises(ethereum_client.exception.errors.DenyError) as error:
cmd.provide_nft_information(plugin=PROVIDE_NFT_INFORMATION)
cmd.send_apdu(SIGN_FIRST)
with cmd.send_apdu_context(SIGN_MORE, result) as ex:
pass
except ethereum_client.exception.errors.DenyError as error:
assert error.args[0] == '0x6985'

View File

@@ -1,3 +1,4 @@
import pytest
from ethereum_client.plugin import ERC20Information
import ethereum_client
@@ -25,7 +26,6 @@ def test_provide_erc20_token_error(cmd):
sign="deadbeef"
)
try:
with pytest.raises(ethereum_client.exception.errors.UnknownDeviceError) as error:
cmd.provide_erc20_token_information(info=erc20_info)
except ethereum_client.exception.errors.UnknownDeviceError as error:
assert error.args[0] == '0x6a80'
assert error.args[0] == '0x6a80'

View File

@@ -1,5 +1,7 @@
from time import sleep
import pytest
import ethereum_client
from ethereum_client.utils import compare_screenshot, save_screenshot, PATH_IMG, parse_sign_response
from ethereum_client.plugin import Plugin
@@ -85,14 +87,15 @@ def test_transfer_erc721_without_nft_provide_info(cmd):
result: list = []
if cmd.model == "nanox" or cmd.model == "nanosp":
try:
with pytest.raises(ethereum_client.exception.errors.UnknownDeviceError) as error:
cmd.set_plugin(plugin=PLUGIN)
cmd.send_apdu(SIGN_FIRST)
with cmd.send_apdu_context(SIGN_MORE, result) as ex:
pass
except ethereum_client.exception.errors.UnknownDeviceError as error:
assert error.args[0] == '0x6a80'
@@ -101,7 +104,7 @@ def test_transfer_erc721_without_set_plugin(cmd):
result: list = []
if cmd.model == "nanox" or cmd.model == "nanosp":
try:
with pytest.raises(ethereum_client.exception.errors.DenyError) as error:
cmd.provide_nft_information(plugin=PROVIDE_NFT_INFORMATION)
cmd.send_apdu(SIGN_FIRST)
@@ -109,5 +112,4 @@ def test_transfer_erc721_without_set_plugin(cmd):
with cmd.send_apdu_context(SIGN_MORE, result) as ex:
pass
except ethereum_client.exception.errors.DenyError as error:
assert error.args[0] == '0x6985'

View File

@@ -1,5 +1,7 @@
from time import sleep
import pytest
import ethereum_client
from ethereum_client.utils import compare_screenshot, save_screenshot, PATH_IMG
@@ -66,9 +68,11 @@ def test_get_public_key(cmd):
def test_reject_get_public_key(cmd):
try:
# DAI COIN with display
result: list = []
# DAI COIN with display
result: list = []
with pytest.raises(ethereum_client.exception.errors.DenyError) as error:
with cmd.get_public_key(bip32_path="44'/700'/1'/0/0", display=True, result=result) as exchange:
sleep(0.5)
@@ -110,5 +114,4 @@ def test_reject_get_public_key(cmd):
compare_screenshot(cmd, f"screenshots/pubkey/{PATH_IMG[cmd.model]}/reject_get_public_key/00003.png")
cmd.client.press_and_release('both')
except ethereum_client.exception.errors.DenyError as error:
assert error.args[0] == '0x6985'

View File

@@ -1,5 +1,7 @@
from time import sleep
import pytest
import ethereum_client
from ethereum_client.utils import compare_screenshot, compare_screenshot, save_screenshot, PATH_IMG
from ethereum_client.transaction import Transaction
@@ -183,7 +185,8 @@ def test_sign_reject(cmd):
chainID=1,
)
try:
with pytest.raises(ethereum_client.exception.errors.DenyError) as error:
with cmd.simple_sign_tx(bip32_path=bip32_path, transaction=transaction, result=result) as ex:
sleep(0.5)
@@ -245,7 +248,6 @@ def test_sign_reject(cmd):
compare_screenshot(cmd, f"screenshots/sign/{PATH_IMG[cmd.model]}/reject/00005.png")
cmd.client.press_and_release('both')
except ethereum_client.exception.errors.DenyError as error:
assert error.args[0] == '0x6985'
@@ -343,19 +345,18 @@ def test_sign_error_transaction_type(cmd):
chainID=1,
)
try:
with pytest.raises(ethereum_client.exception.errors.UnknownDeviceError) as error:
with cmd.simple_sign_tx(bip32_path=bip32_path, transaction=transaction, result=result) as ex:
pass
except ethereum_client.exception.errors.UnknownDeviceError as error:
# Throw error of transaction type not supported
assert error.args[0] == '0x6501'
transaction.txType = 0x7F
try:
with pytest.raises(ethereum_client.exception.errors.UnknownDeviceError) as error:
with cmd.simple_sign_tx(bip32_path=bip32_path, transaction=transaction, result=result) as ex:
pass
except ethereum_client.exception.errors.UnknownDeviceError as error:
# Throw error of transaction type not supported
assert error.args[0] == '0x6501'
@@ -579,7 +580,8 @@ def test_sign_blind_error_disabled(cmd):
data="ok",
)
try:
with pytest.raises(ethereum_client.exception.errors.UnknownDeviceError) as error:
with cmd.simple_sign_tx(bip32_path=bip32_path, transaction=transaction, result=result) as ex:
sleep(0.5)
@@ -587,7 +589,7 @@ def test_sign_blind_error_disabled(cmd):
pass
if cmd.model == "nanox" or cmd.model == "nanosp":
pass
except ethereum_client.exception.errors.UnknownDeviceError as error:
assert error.args[0] == '0x6a80'