From dd9e4e787c0461cd7eeba5d65f6fa23f921636fb Mon Sep 17 00:00:00 2001 From: Samuel Hawksby-Robinson Date: Fri, 17 May 2024 13:32:36 +0100 Subject: [PATCH] test_: added testing for setupRouteValidationMapsV2 --- services/wallet/router/filter_test.go | 56 +++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 services/wallet/router/filter_test.go 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) + }) + } +}