fix: correctly handle hexbytes convertion

There was a bug if the value was already a HexBytes that would lead to some tiny changes on the HexBytes, leading to our test being too permissive.
This commit is contained in:
zizou
2024-09-06 17:27:31 +02:00
parent d0d81fc671
commit c90b190936
2 changed files with 19 additions and 17 deletions

View File

@@ -30,7 +30,9 @@ class ProtocolComponentExpectation(BaseModel):
@validator("static_attributes", pre=True, always=True)
def convert_static_attributes_to_hexbytes(cls, v):
return {k: HexBytes(v[k].lower()) for k in v} if v else {}
if v:
return {k: v[k] if isinstance(v[k], HexBytes) else HexBytes(v[k].lower()) for k in v}
return {}
@validator("creation_tx", pre=True, always=True)
def convert_creation_tx_to_hexbytes(cls, v):