Skip to content

Commit

Permalink
coins parsing fix
Browse files Browse the repository at this point in the history
  • Loading branch information
george-aj committed Oct 24, 2023
1 parent 663cff0 commit 90a23bc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cosmpy/aerial/coins.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def parse_coins(value: str) -> List[Coin]:
if part == "":
continue

match = re.match(r"(\d+)(\w+)", part)
match = re.match(r"^(\d+)(.+)$", part)
if match is None:
raise RuntimeError(f"Unable to parse value {part}")

Expand Down
23 changes: 18 additions & 5 deletions tests/unit/test_aerial/coins_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,24 @@
(" ", []),
("50000atestfet", [Coin(amount="50000", denom="atestfet")]),
(
"50000atestfet, 200foobar",
[
Coin(amount="50000", denom="atestfet"),
Coin(amount="200", denom="foobar"),
],
"50000atestfet, 200foobar",
[
Coin(amount="50000", denom="atestfet"),
Coin(amount="200", denom="foobar"),
],
),
(
"500ibc/0471F1C4E7AFD3F07702BEF6DC365268D64570F7C1FDC98EA6098DD6DE59817B",
[
Coin(amount="500", denom="ibc/0471F1C4E7AFD3F07702BEF6DC365268D64570F7C1FDC98EA6098DD6DE59817B")
]
),
(
"500ibc/0471F1C4E7AFD3F07702BEF6DC365268D64570F7C1FDC98EA6098DD6DE59817B, 50000atestfet",
[
Coin(amount="500", denom="ibc/0471F1C4E7AFD3F07702BEF6DC365268D64570F7C1FDC98EA6098DD6DE59817B"),
Coin(amount="50000", denom="atestfet"),
]
),
],
)
Expand Down

0 comments on commit 90a23bc

Please sign in to comment.