Skip to content

Commit

Permalink
chore: add nodes manager test
Browse files Browse the repository at this point in the history
  • Loading branch information
freak12techno committed Jul 26, 2024
1 parent 1958f33 commit ae05c68
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions pkg/nodes_manager/nodes_manager_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package nodes_manager

import (
configPkg "main/pkg/config"
"main/pkg/config/types"
loggerPkg "main/pkg/logger"
"main/pkg/metrics"
types2 "main/pkg/types"
"testing"

"github.com/jarcoal/httpmock"
"github.com/stretchr/testify/require"
)

//nolint:paralleltest // disabled due to httpmock usage
func TestNodesManagerReceive(t *testing.T) {
httpmock.Activate()
defer httpmock.DeactivateAndReset()

config := &configPkg.AppConfig{
Chains: types.Chains{
{Name: "chain", TendermintNodes: []string{"example"}},
},
Metrics: configPkg.MetricsConfig{Enabled: false},
}

logger := loggerPkg.GetNopLogger()
metricsManager := metrics.NewManager(logger, config.Metrics)
nodesManager := NewNodesManager(logger, config, metricsManager)

go nodesManager.Listen()
defer nodesManager.Stop()

reportable := &types2.Tx{Hash: types.Link{Value: "123"}}

nodesManager.Nodes["chain"][0].Channel <- types2.Report{
Chain: config.Chains[0],
Reportable: reportable,
}

received := <-nodesManager.Channel

require.Equal(t, "123", received.Reportable.GetHash())

nodesManager.Nodes["chain"][0].Channel <- types2.Report{
Chain: config.Chains[0],
Reportable: reportable,
}
}

0 comments on commit ae05c68

Please sign in to comment.