From 65724cd2087eca565e9eb22aa78fcdb7d5cdeb90 Mon Sep 17 00:00:00 2001 From: jnicoulaud-ledger <102984500+jnicoulaud-ledger@users.noreply.github.com> Date: Wed, 23 Oct 2024 17:55:48 +0200 Subject: [PATCH] test: update tests asserts (#116) * test: update tests by reference * test: update EIP-712 roundtrip tests --- .../eip712/test_convert_eip712_round_trip.py | 21 ++++--- .../data/format_address_name_input.json | 30 ---------- .../data/format_address_name_resolved.json | 57 ------------------- ...at_address_name_using_constants_input.json | 37 +----------- ...address_name_using_constants_resolved.json | 57 ------------------- 5 files changed, 16 insertions(+), 186 deletions(-) diff --git a/tests/convert/ledger/eip712/test_convert_eip712_round_trip.py b/tests/convert/ledger/eip712/test_convert_eip712_round_trip.py index 5f17ee7..a5b0958 100644 --- a/tests/convert/ledger/eip712/test_convert_eip712_round_trip.py +++ b/tests/convert/ledger/eip712/test_convert_eip712_round_trip.py @@ -104,13 +104,20 @@ def _cleanup_formats(formats: dict[str, Any]) -> Any: del_by_path(message, "screens") if "fields" in message: for field in message["fields"]: - # Other formats are always converted to RAW - if "format" in field and field["format"] not in ( - FieldFormat.AMOUNT, - FieldFormat.TOKEN_AMOUNT, - FieldFormat.DATE, - ): - field["format"] = "raw" + if "format" in field: + format = field["format"] + + # Address name format parameters cannot be preserved + if format == "addressName": + del_by_path(field, "params") + + # Other formats are always converted to RAW + if format not in ( + FieldFormat.AMOUNT, + FieldFormat.TOKEN_AMOUNT, + FieldFormat.DATE, + ): + field["format"] = "raw" return formats diff --git a/tests/convert/resolved/data/format_address_name_input.json b/tests/convert/resolved/data/format_address_name_input.json index 7643ad6..f63f4f6 100644 --- a/tests/convert/resolved/data/format_address_name_input.json +++ b/tests/convert/resolved/data/format_address_name_input.json @@ -42,36 +42,6 @@ "formats": { "TestPrimaryType": { "fields": [ - { - "path": "param1", - "label": "Minimal parameters set", - "format": "addressName" - }, - { - "path": "param1", - "label": "types specified", - "format": "addressName", - "params": { - "types": [ - "wallet", - "eoa", - "token", - "contract", - "collection" - ] - } - }, - { - "path": "param1", - "label": "sources specified", - "format": "addressName", - "params": { - "sources": [ - "local", - "ens" - ] - } - }, { "path": "param1", "label": "All parameters specified", diff --git a/tests/convert/resolved/data/format_address_name_resolved.json b/tests/convert/resolved/data/format_address_name_resolved.json index dfbb070..61776c0 100644 --- a/tests/convert/resolved/data/format_address_name_resolved.json +++ b/tests/convert/resolved/data/format_address_name_resolved.json @@ -43,63 +43,6 @@ "formats": { "TestPrimaryType": { "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Minimal parameters set", - "format": "addressName" - }, - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "types specified", - "format": "addressName", - "params": { - "types": [ - "wallet", - "eoa", - "token", - "contract", - "collection" - ] - } - }, - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "sources specified", - "format": "addressName", - "params": { - "sources": [ - "local", - "ens" - ] - } - }, { "path": { "type": "data", diff --git a/tests/convert/resolved/data/format_address_name_using_constants_input.json b/tests/convert/resolved/data/format_address_name_using_constants_input.json index 4a79d80..f25f479 100644 --- a/tests/convert/resolved/data/format_address_name_using_constants_input.json +++ b/tests/convert/resolved/data/format_address_name_using_constants_input.json @@ -40,10 +40,7 @@ "metadata": { "constants": { "path": "#.param1", - "label1": "Minimal parameters set", - "label2": "types specified", - "label3": "sources specified", - "label4": "All parameters specified" + "label": "All parameters specified" } }, "display": { @@ -52,37 +49,7 @@ "fields": [ { "path": "$.metadata.constants.path", - "label": "$.metadata.constants.label1", - "format": "addressName" - }, - { - "path": "$.metadata.constants.path", - "label": "$.metadata.constants.label2", - "format": "addressName", - "params": { - "types": [ - "wallet", - "eoa", - "token", - "contract", - "collection" - ] - } - }, - { - "path": "$.metadata.constants.path", - "label": "$.metadata.constants.label3", - "format": "addressName", - "params": { - "sources": [ - "local", - "ens" - ] - } - }, - { - "path": "$.metadata.constants.path", - "label": "$.metadata.constants.label4", + "label": "$.metadata.constants.label", "format": "addressName", "params": { "types": [ diff --git a/tests/convert/resolved/data/format_address_name_using_constants_resolved.json b/tests/convert/resolved/data/format_address_name_using_constants_resolved.json index dfbb070..61776c0 100644 --- a/tests/convert/resolved/data/format_address_name_using_constants_resolved.json +++ b/tests/convert/resolved/data/format_address_name_using_constants_resolved.json @@ -43,63 +43,6 @@ "formats": { "TestPrimaryType": { "fields": [ - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "Minimal parameters set", - "format": "addressName" - }, - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "types specified", - "format": "addressName", - "params": { - "types": [ - "wallet", - "eoa", - "token", - "contract", - "collection" - ] - } - }, - { - "path": { - "type": "data", - "absolute": true, - "elements": [ - { - "type": "field", - "identifier": "param1" - } - ] - }, - "label": "sources specified", - "format": "addressName", - "params": { - "sources": [ - "local", - "ens" - ] - } - }, { "path": { "type": "data",