Skip to content

Commit

Permalink
catch panic during parsing of a universal asset id (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkouv authored Dec 20, 2021
1 parent 6876599 commit d75f753
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion asset/id.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func FindCoinID(words []string) (uint, error) {

func FindTokenID(words []string) string {
for _, w := range words {
if w[0] == tokenPrefix {
if len(w) > 0 && w[0] == tokenPrefix {
token := removeFirstChar(w)
if len(token) > 0 {
return token
Expand Down
7 changes: 7 additions & 0 deletions asset/id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ func TestParseID(t *testing.T) {
Coin,
nil,
},
{
givenID: "c60_",
wantedCoin: 60,
wantedToken: "",
wantedType: Coin,
wantedError: nil,
},
}

for _, tt := range testStruct {
Expand Down

0 comments on commit d75f753

Please sign in to comment.