From 2da7e04be6fd3e451f8a7b593a1f18a73a58de6e Mon Sep 17 00:00:00 2001 From: Sergey Date: Sat, 22 Jun 2024 23:46:09 +0300 Subject: [PATCH] chore: add delegations generator test --- pkg/generators/delegators_test.go | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 pkg/generators/delegators_test.go diff --git a/pkg/generators/delegators_test.go b/pkg/generators/delegators_test.go new file mode 100644 index 0000000..7862306 --- /dev/null +++ b/pkg/generators/delegators_test.go @@ -0,0 +1,36 @@ +package generators + +import ( + "main/pkg/constants" + "main/pkg/fetchers" + statePkg "main/pkg/state" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestDelegationsGeneratorNoState(t *testing.T) { + t.Parallel() + + state := statePkg.NewState() + generator := NewDelegationsGenerator() + results := generator.Generate(state) + assert.Empty(t, results) +} + +func TestDelegationsGeneratorNotEmptyState(t *testing.T) { + t.Parallel() + + state := statePkg.NewState() + state.Set(constants.FetcherNameDelegations, fetchers.DelegationsData{ + Delegations: map[string]map[string]uint64{ + "chain": { + "validator": 100, + }, + }, + }) + + generator := NewDelegationsGenerator() + results := generator.Generate(state) + assert.NotEmpty(t, results) +}