test_: Added testing for filterRoutesV2

This commit is contained in:
Samuel Hawksby-Robinson 2024-05-17 14:27:14 +01:00
parent a91ce6067d
commit 4f2cd8ff7a
1 changed files with 30 additions and 0 deletions

View File

@ -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: &params.Network{ChainID: 1}, AmountIn: (*hexutil.Big)(big.NewInt(100))},
{From: &params.Network{ChainID: 2}, AmountIn: (*hexutil.Big)(big.NewInt(200))},
},
{
{From: &params.Network{ChainID: 3}, AmountIn: (*hexutil.Big)(big.NewInt(100))},
{From: &params.Network{ChainID: 4}, AmountIn: (*hexutil.Big)(big.NewInt(50))},
},
}
amountIn := big.NewInt(120)
expectedRoutes := [][]*PathV2{
{
{From: &params.Network{ChainID: 1}, AmountIn: (*hexutil.Big)(big.NewInt(50)), AmountInLocked: true},
{From: &params.Network{ChainID: 2}, AmountIn: (*hexutil.Big)(big.NewInt(200))},
},
}
filteredRoutes := filterRoutesV2(routes, amountIn, fromLockedAmount)
assert.Equal(t, expectedRoutes, filteredRoutes)
}