Skip to content

Commit 9aeab0b

Browse files
committed
Fix tests
1 parent 55037b4 commit 9aeab0b

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

app/services/data_decoder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22
from functools import cache
3-
from typing import Any, AsyncIterator, NotRequired, TypedDict, cast
3+
from typing import Any, AsyncIterator, NotRequired, TypedDict, Union, cast
44

55
from async_lru import alru_cache
66
from eth_abi import decode as decode_abi
@@ -38,7 +38,7 @@ class ParameterDecoded(TypedDict):
3838
name: str
3939
type: str
4040
value: Any
41-
value_decoded: NotRequired[list["MultisendDecoded"] | "DataDecoded" | None]
41+
value_decoded: NotRequired[Union[list["MultisendDecoded"], "DataDecoded", None]]
4242

4343

4444
class DataDecoded(TypedDict):

app/tests/db/test_model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ async def test_abi(self, session: AsyncSession):
4343
@database_session
4444
async def test_abi_get_abis_sorted_by_relevance(self, session: AsyncSession):
4545
abi_jsons = [
46-
{"name": "A Test Project with relevance 10"},
4746
{"name": "A Test Project with relevance 100"},
47+
{"name": "A Test Project with relevance 10"},
4848
]
49-
abi = Abi(abi_hash=b"A Test Abi", abi_json=abi_jsons[0], relevance=10)
49+
abi = Abi(abi_hash=b"A Test Abi", abi_json=abi_jsons[0], relevance=100)
5050
await abi.create(session)
51-
abi = Abi(abi_hash=b"A Test Abi2", abi_json=abi_jsons[1], relevance=100)
51+
abi = Abi(abi_hash=b"A Test Abi2", abi_json=abi_jsons[1], relevance=10)
5252
await abi.create(session)
5353
results = abi.get_abis_sorted_by_relevance(session)
5454
result = await anext(results)

app/tests/services/test_data_decoder.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from eth_typing import Address
44
from hexbytes import HexBytes
5+
from safe_eth.eth.constants import NULL_ADDRESS
56
from safe_eth.eth.contracts import (
67
get_erc20_contract,
78
get_multi_send_contract,
@@ -415,7 +416,9 @@ async def test_db_tx_decoder(self, session: AsyncSession):
415416
Web3()
416417
.eth.contract(abi=example_abi)
417418
.functions.buyDroid(4, 10)
418-
.build_transaction(get_empty_tx_params())["data"]
419+
.build_transaction(
420+
get_empty_tx_params() | {"to": NULL_ADDRESS, "chainId": 1}
421+
)["data"]
419422
)
420423

421424
decoder_service = DataDecoderService()
@@ -493,7 +496,9 @@ async def test_decode_fallback_calls_db_tx_decoder(self, session: AsyncSession):
493496
Web3()
494497
.eth.contract(abi=example_not_matched_abi)
495498
.functions.claimOwner()
496-
.build_transaction(get_empty_tx_params())["data"]
499+
.build_transaction(
500+
get_empty_tx_params() | {"to": NULL_ADDRESS, "chainId": 1}
501+
)["data"]
497502
)
498503

499504
fallback_abi = [

0 commit comments

Comments
 (0)