EIP-712 tests now have reference response signatures they can check against
This commit is contained in:
4
tests/ragger/eip712/input_files/00-simple_mail.ini
Normal file
4
tests/ragger/eip712/input_files/00-simple_mail.ini
Normal file
@@ -0,0 +1,4 @@
|
||||
[signature]
|
||||
v = 1b
|
||||
r = 23599abd6c4b631e42770c112b5955907fe91339f1ea1e102f7682262ca178b9
|
||||
s = 29fc94518588165114b4c4acb4d73e6d028dfb051d90e517b3b4746e04eb0f5f
|
||||
@@ -0,0 +1,4 @@
|
||||
[signature]
|
||||
v = 1c
|
||||
r = 3f084a471e6158bce792287500d62d40061acc1864180ed2da7a704bf3aced0f
|
||||
s = 3b799ced9e48cda152b4b9a4b7f45e3119dc7acdf16710a73800b4e336fa1b40
|
||||
@@ -0,0 +1,4 @@
|
||||
[signature]
|
||||
v = 1b
|
||||
r = 49dd2aa96d7494e0cd9111f19f87ac50194e4bbc61ea9f4bb86d674da0ae7721
|
||||
s = 7a12ddd9083b4caaabd2fb80df6de1d5d926c0e8a73bf371a45e231d409d79d6
|
||||
4
tests/ragger/eip712/input_files/03-long_string.ini
Normal file
4
tests/ragger/eip712/input_files/03-long_string.ini
Normal file
@@ -0,0 +1,4 @@
|
||||
[signature]
|
||||
v = 1c
|
||||
r = b23ffac2cb350fd6e7d06ec4b981fe016d33426d753c870e7e753797cc43bb1f
|
||||
s = 37948a656fa3403e21956ef10c8d3152f7ce22cc252d958c9f9249435090f426
|
||||
4
tests/ragger/eip712/input_files/04-long_bytes.ini
Normal file
4
tests/ragger/eip712/input_files/04-long_bytes.ini
Normal file
@@ -0,0 +1,4 @@
|
||||
[signature]
|
||||
v = 1b
|
||||
r = db18ea1b9757773385138d0802fb2f8107c3e45882962b8e0c6789eccdbfab05
|
||||
s = 3d66d4dee47916fb7fec39a538ad8d5e94fbc92f99327410716180ab07591218
|
||||
4
tests/ragger/eip712/input_files/05-signed_ints.ini
Normal file
4
tests/ragger/eip712/input_files/05-signed_ints.ini
Normal file
@@ -0,0 +1,4 @@
|
||||
[signature]
|
||||
v = 1c
|
||||
r = 50fb2861367daf3b5b73cac277e698b27bf7627a462fade1acb5a2ef285ba8ae
|
||||
s = 131a62515a0a5c4b35c5cb672b46f562151c45508d8efcdf78c4608bc14c5f30
|
||||
4
tests/ragger/eip712/input_files/06-boolean.ini
Normal file
4
tests/ragger/eip712/input_files/06-boolean.ini
Normal file
@@ -0,0 +1,4 @@
|
||||
[signature]
|
||||
v = 1c
|
||||
r = 929681d77ed88cd1adef57185a0cd7b3a268aca5d4122b8c0acfd2ce4c0afb18
|
||||
s = 5afe8e3004c182b6b02fe7559c26f20f4133ad9b17223658ccd9061b33b021cf
|
||||
4
tests/ragger/eip712/input_files/07-fixed_bytes.ini
Normal file
4
tests/ragger/eip712/input_files/07-fixed_bytes.ini
Normal file
@@ -0,0 +1,4 @@
|
||||
[signature]
|
||||
v = 1b
|
||||
r = e021d88afc50079b0341b01193c4687c47b85bcd6749fe69e0b87521d65a1847
|
||||
s = 5b7670d2a67c781a11164920403db0f7707161e81d88226cdbf91298390dfeda
|
||||
4
tests/ragger/eip712/input_files/08-opensea.ini
Normal file
4
tests/ragger/eip712/input_files/08-opensea.ini
Normal file
@@ -0,0 +1,4 @@
|
||||
[signature]
|
||||
v = 1b
|
||||
r = 1539547ae7cf8ebcd3eabfb57cd2b1fb7775ce757c3f4a307c7425d35b7bfff7
|
||||
s = 47248cb61e554c1f90af6331d9c9e51cbb8655667514194f509abe097a032319
|
||||
4
tests/ragger/eip712/input_files/09-rarible.ini
Normal file
4
tests/ragger/eip712/input_files/09-rarible.ini
Normal file
@@ -0,0 +1,4 @@
|
||||
[signature]
|
||||
v = 1c
|
||||
r = 341bca1c0dfd805d4befc21500084424dbe559c7aafd78d8fb461c0c76dfea1d
|
||||
s = 33ebb7b6fe0691961cd8b263faac20ecbbdcaef3febb57eb76614cad629080ea
|
||||
@@ -0,0 +1,4 @@
|
||||
[signature]
|
||||
v = 1b
|
||||
r = d11a91bdf7836288818875d046452061d565cc6dc1bf3dd6216ab27ef9a2844f
|
||||
s = 4f6bda8ac4c39721aff7ae08989897ede9d573085a192d03ab0eb7735d2ef403
|
||||
4
tests/ragger/eip712/input_files/11-complex_structs.ini
Normal file
4
tests/ragger/eip712/input_files/11-complex_structs.ini
Normal file
@@ -0,0 +1,4 @@
|
||||
[signature]
|
||||
v = 1c
|
||||
r = cce2e63aaac6a5f9a74684d8fdddcbc7f3b27aa17235bfab89226821ead933b6
|
||||
s = 3f3c93977abcc3f8cc9a3dc1ecc02dbca14aca1a6ecb2fb6ca3d7c713ace1ec4
|
||||
@@ -4,6 +4,8 @@ import fnmatch
|
||||
from typing import List
|
||||
from ethereum_client import EthereumClient
|
||||
from eip712 import InputData
|
||||
from pathlib import Path
|
||||
from configparser import ConfigParser
|
||||
|
||||
bip32 = [
|
||||
0x8000002c,
|
||||
@@ -23,7 +25,7 @@ def input_files() -> List[str]:
|
||||
|
||||
@pytest.fixture(params=input_files())
|
||||
def input_file(request) -> str:
|
||||
return request.param
|
||||
return Path(request.param)
|
||||
|
||||
@pytest.fixture(params=[True, False])
|
||||
def verbose(request) -> bool:
|
||||
@@ -42,12 +44,26 @@ def test_eip712_legacy(app_client: EthereumClient):
|
||||
assert s == bytes.fromhex("52d8ba9153de9255da220ffd36762c0b027701a3b5110f0a765f94b16a9dfb55")
|
||||
|
||||
|
||||
def test_eip712_new(app_client: EthereumClient, input_file, verbose):
|
||||
def test_eip712_new(app_client: EthereumClient, input_file: Path, verbose):
|
||||
if app_client._client.firmware.device != "nanos": # not supported
|
||||
print("=====> %s" % (input_file))
|
||||
test_path = "%s/%s" % (input_file.parent, "-".join(input_file.stem.split("-")[:-1]))
|
||||
conf_file = "%s.ini" % (test_path)
|
||||
|
||||
config = ConfigParser()
|
||||
config.read(conf_file)
|
||||
|
||||
# sanity check
|
||||
assert "signature" in config.sections()
|
||||
assert "v" in config["signature"]
|
||||
assert "r" in config["signature"]
|
||||
assert "s" in config["signature"]
|
||||
|
||||
if verbose:
|
||||
app_client.setting_toggle_verbose_eip712()
|
||||
InputData.process_file(app_client, input_file, False)
|
||||
v, r, s = app_client.eip712_sign_new(bip32)
|
||||
assert 1 == 1 # TODO: Replace by the actual v,r,s asserts
|
||||
|
||||
assert v == bytes.fromhex(config["signature"]["v"])
|
||||
assert r == bytes.fromhex(config["signature"]["r"])
|
||||
assert s == bytes.fromhex(config["signature"]["s"])
|
||||
|
||||
Reference in New Issue
Block a user