Skip to content

Commit

Permalink
test: update tests asserts (#116)
Browse files Browse the repository at this point in the history
* test: update tests by reference

* test: update EIP-712 roundtrip tests
  • Loading branch information
jnicoulaud-ledger authored Oct 23, 2024
1 parent 6ed3b23 commit 65724cd
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 186 deletions.
21 changes: 14 additions & 7 deletions tests/convert/ledger/eip712/test_convert_eip712_round_trip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
30 changes: 0 additions & 30 deletions tests/convert/resolved/data/format_address_name_input.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
57 changes: 0 additions & 57 deletions tests/convert/resolved/data/format_address_name_resolved.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 65724cd

Please sign in to comment.