wormchain: tokenbridge: Parse chain id as an unsigned integer
A chain id cannot be negative so parse it using `strconv.ParseUint` to avoid issues with negative values.
This commit is contained in:
parent
62edb5b5b1
commit
a66b3ac28c
|
@ -111,7 +111,7 @@ func GetWrappedCoinMeta(identifier string) (tokenChain uint16, tokenAddress [32]
|
||||||
return 0, [32]byte{}, false
|
return 0, [32]byte{}, false
|
||||||
}
|
}
|
||||||
|
|
||||||
tokenChain64, err := strconv.ParseInt(parts[1], 10, 16)
|
tokenChain64, err := strconv.ParseUint(parts[1], 10, 16)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, [32]byte{}, false
|
return 0, [32]byte{}, false
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,13 @@ func TestGetWrappedCoinMeta(t *testing.T) {
|
||||||
tokenAddress: [32]byte{},
|
tokenAddress: [32]byte{},
|
||||||
wrapped: false,
|
wrapped: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "negative chain id",
|
||||||
|
identifier: "wh/-0222/165809739240a0ac03b98440fe8985548e3aa683cd0d4d9df5b5659669faa300",
|
||||||
|
tokenChain: 0,
|
||||||
|
tokenAddress: [32]byte{},
|
||||||
|
wrapped: false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue