0g-chain/x/incentive/keeper/diff_test.go
Denali Marsh eb856b5a1f
Fix: delete incentive reward factors on full withdraw/repay (#885)
* delete incentive reward index on repay/withdraw

* call hook on borrow in all cases

* additional types functionality

* extend tests to cover fix

* update naming convention in tests

* update test comment

* feat: add set difference unit tests

* clarify test names

Co-authored-by: karzak <kjydavis3@gmail.com>
2021-03-23 17:28:03 -06:00

30 lines
940 B
Go

package keeper
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestSetDiff(t *testing.T) {
tests := []struct {
name string
setA []string
setB []string
expected []string
}{
{"empty", []string{}, []string{}, []string(nil)},
{"diff equal sets", []string{"busd", "usdx"}, []string{"busd", "usdx"}, []string(nil)},
{"diff set empty", []string{"bnb", "ukava", "usdx"}, []string{}, []string{"bnb", "ukava", "usdx"}},
{"input set empty", []string{}, []string{"bnb", "ukava", "usdx"}, []string(nil)},
{"diff set with common elements", []string{"bnb", "btcb", "usdx", "xrpb"}, []string{"bnb", "usdx"}, []string{"btcb", "xrpb"}},
{"diff set with all common elements", []string{"bnb", "usdx"}, []string{"bnb", "btcb", "usdx", "xrpb"}, []string(nil)},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
require.Equal(t, tt.expected, setDifference(tt.setA, tt.setB))
})
}
}