0g-chain/x/savings/keeper/diff_test.go
Denali Marsh eaeaf20e83
Incentive savings hooks + init/sync of savings claims (#1209)
* update savings module macc balances getter

* add savings keeper to incentive module

* add savings keeper to incentive module #2

* savings reward syncing

* claim savings reward

* update txs, queries

* update txs, queries #2

* update claim test

* add savings keeper to incentive module in app.go

* re-commit files to disk

* define and call hooks

* keeper methods for init/sync savings reward

* update other tests for easier extendibility

* init savings reward test

* add helper methods to global incentive unit tester

* sync savings test progress

* savings init fix + completed tests

* sync savings updates + tests

* nit: simplify false check

* fix: calculate set difference of incoming deposit denoms

Co-authored-by: karzak <kjydavis3@gmail.com>
2022-04-21 16:19:03 +02: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))
})
}
}