Skip to content

Commit

Permalink
model config for json correctness
Browse files Browse the repository at this point in the history
  • Loading branch information
dzmitry-lahoda committed Apr 16, 2024
1 parent 5ebf738 commit 03d2de5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions mantis/simulation/routers/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ class Input(
this is what user asks for
"""

model_config = ConfigDict(coerce_numbers_to_str=True)

# natural set key is ordered pair (`in_asset_id``, `out_asset_id`)
in_asset_id: TId = Field(example="158456325028528675187087900673")
out_asset_id: TId = Field(example="158456325028528675187087900674")
Expand Down
7 changes: 6 additions & 1 deletion mantis/simulation/routers/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ def test_big_numbers_api():
"""_summary_
Ensures that amounts are strings on the wire but big integers in memory
"""
input : Input[str, str] = Input(in_asset_id="1", out_asset_id="2", in_asset_amount="100", out_asset_amount="100")
input_api_raw : Input[str, str] = Input(in_asset_id="1", out_asset_id="2", in_asset_amount="100", out_asset_amount="100")
input_memory : Input[str, int] = Input(in_asset_id="1", out_asset_id="2", in_asset_amount=100, out_asset_amount=100)
input_api_converted : Input[str, str] = Input[str, str](**input_memory.model_dump())
assert input_api_converted.model_dump_json() == input_api_raw.model_dump_json()
# assert input_api_raw == input_api_converted
# input_memory : Input[str, int] = Input[str, int].model_validate(input_api)

def test_token_price_in_usd():
pica_usd = new_pair(
Expand Down

0 comments on commit 03d2de5

Please sign in to comment.