Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add nodes manager test #78

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
}
}
Loading