test(router_validation)_: Resolved invalid recursive type aliasing

Additionally I've resolved a panic when AmountIn and/or AmountOut is nil
This commit is contained in:
Samuel Hawksby-Robinson 2024-07-02 15:59:11 +01:00
parent 59853fdbe2
commit 3c1326be48
1 changed files with 4 additions and 4 deletions

View File

@ -141,7 +141,7 @@ type ErrorResponseWithUUID struct {
ErrorResponse error
}
type GraphV2 = []*NodeV2
type GraphV2 []*NodeV2
type NodeV2 struct {
Path *PathV2
@ -380,14 +380,14 @@ func validateInputData(input *RouteInputParams) error {
return ErrSwapTokenIDMustBeDifferent
}
// we can do this check, cause AmountIn is required in `RouteInputParams`
if input.AmountIn.ToInt().Cmp(pathprocessor.ZeroBigIntValue) > 0 &&
if input.AmountIn != nil &&
input.AmountOut != nil &&
input.AmountIn.ToInt().Cmp(pathprocessor.ZeroBigIntValue) > 0 &&
input.AmountOut.ToInt().Cmp(pathprocessor.ZeroBigIntValue) > 0 {
return ErrSwapAmountInAmountOutMustBeExclusive
}
if input.AmountIn.ToInt().Sign() < 0 {
if input.AmountIn != nil && input.AmountIn.ToInt().Sign() < 0 {
return ErrSwapAmountInMustBePositive
}