diff --git a/services/wallet/router/filter_test.go b/services/wallet/router/filter_test.go new file mode 100644 index 000000000..31d8becf5 --- /dev/null +++ b/services/wallet/router/filter_test.go @@ -0,0 +1,56 @@ +package router + +import ( + "math/big" + "testing" + + "github.com/ethereum/go-ethereum/common/hexutil" + + "github.com/stretchr/testify/assert" +) + +func TestSetupRouteValidationMapsV2(t *testing.T) { + tests := []struct { + name string + fromLockedAmount map[uint64]*hexutil.Big + expectedFromIncluded map[uint64]bool + expectedFromExcluded map[uint64]bool + }{ + { + name: "Mixed locked amounts", + fromLockedAmount: map[uint64]*hexutil.Big{ + 1: (*hexutil.Big)(big.NewInt(100)), + 2: (*hexutil.Big)(big.NewInt(0)), + 3: (*hexutil.Big)(big.NewInt(50)), + }, + expectedFromIncluded: map[uint64]bool{1: false, 3: false}, + expectedFromExcluded: map[uint64]bool{2: true}, + }, + { + name: "All amounts locked", + fromLockedAmount: map[uint64]*hexutil.Big{ + 1: (*hexutil.Big)(big.NewInt(100)), + 2: (*hexutil.Big)(big.NewInt(50)), + }, + expectedFromIncluded: map[uint64]bool{1: false, 2: false}, + expectedFromExcluded: map[uint64]bool{}, + }, + { + name: "No amounts locked", + fromLockedAmount: map[uint64]*hexutil.Big{ + 1: (*hexutil.Big)(big.NewInt(0)), + 2: (*hexutil.Big)(big.NewInt(0)), + }, + expectedFromIncluded: map[uint64]bool{}, + expectedFromExcluded: map[uint64]bool{1: true, 2: true}, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + fromIncluded, fromExcluded := setupRouteValidationMapsV2(tt.fromLockedAmount) + assert.Equal(t, tt.expectedFromIncluded, fromIncluded) + assert.Equal(t, tt.expectedFromExcluded, fromExcluded) + }) + } +}