Skip to content

Commit

Permalink
chore: fix consensus test
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanchriswhite committed Jun 12, 2023
1 parent a9ffa56 commit 0d92a09
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
16 changes: 16 additions & 0 deletions consensus/e2e_tests/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import (

"github.com/benbjohnson/clock"
"github.com/golang/mock/gomock"

"github.com/pokt-network/pocket/consensus"
typesCons "github.com/pokt-network/pocket/consensus/types"
"github.com/pokt-network/pocket/internal/testutil"
persistenceMocks "github.com/pokt-network/pocket/persistence/types/mocks"
"github.com/pokt-network/pocket/runtime"
"github.com/pokt-network/pocket/runtime/configs"
Expand Down Expand Up @@ -432,6 +434,20 @@ func basePersistenceMock(t *testing.T, _ modules.EventsChannel, bus modules.Bus)
Return(bus.GetRuntimeMgr().GetGenesis().Validators, nil).
AnyTimes()

persistenceReadContextMock.
EXPECT().
GetAllStakedActors(gomock.Any()).
DoAndReturn(func(height int64) ([]*coreTypes.Actor, error) {
genesisState := bus.GetRuntimeMgr().GetGenesis()
return testutil.Concatenate[*coreTypes.Actor](
genesisState.Validators,
genesisState.Servicers,
genesisState.Fishermen,
genesisState.Applications,
), nil
}).
AnyTimes()

persistenceReadContextMock.
EXPECT().
GetBlockHash(gomock.Any()).
Expand Down
12 changes: 12 additions & 0 deletions internal/testutil/slice.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package testutil

// Concatenate appends the contents of multiple slices of any type (T) into a
// single slice of type T.
func Concatenate[T any](tt ...[]T) []T {
var result []T
for _, t := range tt {
result = append(result, t...)
}

return result
}

0 comments on commit 0d92a09

Please sign in to comment.