diff --git a/services/wallet/router/filter_test.go b/services/wallet/router/filter_test.go index 699aa28bd..15db47a71 100644 --- a/services/wallet/router/filter_test.go +++ b/services/wallet/router/filter_test.go @@ -259,3 +259,33 @@ func TestFilterCapacityValidationV2(t *testing.T) { filteredRoutes := filterCapacityValidationV2(routes, amountIn, fromLockedAmount) assert.Equal(t, expectedRoutes, filteredRoutes) } + +func TestFilterRoutesV2(t *testing.T) { + fromLockedAmount := map[uint64]*hexutil.Big{ + 1: (*hexutil.Big)(big.NewInt(50)), + 2: (*hexutil.Big)(big.NewInt(100)), + } + + routes := [][]*PathV2{ + { + {From: ¶ms.Network{ChainID: 1}, AmountIn: (*hexutil.Big)(big.NewInt(100))}, + {From: ¶ms.Network{ChainID: 2}, AmountIn: (*hexutil.Big)(big.NewInt(200))}, + }, + { + {From: ¶ms.Network{ChainID: 3}, AmountIn: (*hexutil.Big)(big.NewInt(100))}, + {From: ¶ms.Network{ChainID: 4}, AmountIn: (*hexutil.Big)(big.NewInt(50))}, + }, + } + + amountIn := big.NewInt(120) + + expectedRoutes := [][]*PathV2{ + { + {From: ¶ms.Network{ChainID: 1}, AmountIn: (*hexutil.Big)(big.NewInt(50)), AmountInLocked: true}, + {From: ¶ms.Network{ChainID: 2}, AmountIn: (*hexutil.Big)(big.NewInt(200))}, + }, + } + + filteredRoutes := filterRoutesV2(routes, amountIn, fromLockedAmount) + assert.Equal(t, expectedRoutes, filteredRoutes) +}