File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed
Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -2500,6 +2500,26 @@ func TestMsgMultiHopSwapValidate(t *testing.T) {
25002500 },
25012501 types .ErrZeroExitPrice ,
25022502 },
2503+ {
2504+ "single hop" ,
2505+ types.MsgMultiHopSwap {
2506+ Creator : sample .AccAddress (),
2507+ Receiver : sample .AccAddress (),
2508+ Routes : []* types.MultiHopRoute {{Hops : []string {"TokenA" }}},
2509+ AmountIn : sdkmath .OneInt (),
2510+ },
2511+ types .ErrRouteWithoutExitToken ,
2512+ },
2513+ {
2514+ "no hops" ,
2515+ types.MsgMultiHopSwap {
2516+ Creator : sample .AccAddress (),
2517+ Receiver : sample .AccAddress (),
2518+ Routes : []* types.MultiHopRoute {{Hops : []string {}}},
2519+ AmountIn : sdkmath .OneInt (),
2520+ },
2521+ types .ErrRouteWithoutExitToken ,
2522+ },
25032523 }
25042524
25052525 for _ , tt := range tests {
Original file line number Diff line number Diff line change @@ -114,12 +114,12 @@ func validateRoutes(routes []*MultiHopRoute) error {
114114}
115115
116116func validateHops (hops []string ) error {
117+ // check that route has at least entry and exit token
118+ if len (hops ) < 2 {
119+ return ErrRouteWithoutExitToken
120+ }
117121 existingHops := make (map [string ]bool , len (hops ))
118122 for _ , hop := range hops {
119- // check that route has at least entry and exit token
120- if len (hop ) < 2 {
121- return ErrRouteWithoutExitToken
122- }
123123 // check if we find cycles in the route
124124 if existingHops [hop ] {
125125 return ErrCycleInHops
You can’t perform that action at this time.
0 commit comments