-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RelayMiner, Testing, Off-chain] test:
relayer
pkg (#193)
* refactor: `MapFn`s receive context arg * chore: add `ForEach` map shorthand operator * chore: add `/pkg/observable/filter` * chore: add `/pkg/observable/logging` * chore: add `/pkg/relayer/protocol` * chore: add `Miner` interface * feat: add `Miner` implementation * test: `Miner` implementation * chore: fix comment * chore: add godoc comments * feat: Add Relayer struct * chore: Rename to RelayMiner * chore: Rename relay miner file * chore: Remove unused RelayerOption parameter * [Test] First step for automated E2E Relay test (#167) - Fixed helpers for localnet regenesis - Added an application & supplier to the genesis file - Initializing appMap & supplierMap in E2E tests - Add support for the app's codec (for unmarshaling responses) in E2E tests - Adding a placeholder for `e2e/tests/relay.feature` --- Co-authored-by: harry <[email protected]> * [Relayer] refactor: simplify `RelayerSessionsManager` (#169) * refactor: `MapFn`s receive context arg * feat: add `MapExpand` observable operator * refactor: `RelayerSessionsManager` to be more reactive * chore: add godoc comment * chore: review feedback improvements * trigger CI * chore: review feedback improvements Co-authored-by: Daniel Olshansky <[email protected]> * chore: review feedback improvements * chore: update start mining comment * fix: Update Miner interface * fix: import cycle & goimports * chore: review feedback improvements * chore: cleanup TODO_THIS_COMMIT comments * chore: improve var & func names for clarity and consistency * refactor: move claim/proof lifecycle concerns to `relayerSessionsManager`. * chore: review feedback improvements * chore: review feedback improvements * refactor: `miner#hash()` method * chore: tidy up * chore: simplify * wip: relayer CLI * chore: finish first pass * chore: review feedback improvements Co-authored-by: Daniel Olshansky <[email protected]> * chore: review feedback improvements Co-authored-by: Daniel Olshansky <[email protected]> * chore: review feedback improvements Co-authored-by: Daniel Olshansky <[email protected]> * chore: review feedback improvements * chore: review feedback improvements * chore: tidy up cmd creation * fix: incomplete refactor * chore: simplify * chore: add log lines * wip: react to miner, refactor, construct miner, refactor * chore: cleanup * chore: Reflect responsibility changes of session manager * feat: Use relay miner to start * [WIP] Updating relay.feature to run curl command * chore: Improve comment about startig relayer proxy * wip: debugging * Continued implementation but still failing * Getting an invalid request right now but figuring it out... * wip: debugging * Added service and switched to AppGate * wip: debugging * chore: Rename falg variables * wip: debugging * revertme: disable tilt relayer service * chore: use arg not flag * chore: rename command * Debugging checkpoint * wip: debugging - improvments * wip: debugging * wip: debugging * wip: debugging * revert-or-fixme: add error log lines * revert-or-fixme: add debug log lines * fix: set relay server handle function * revert-or-fixme: add debug log lines * chore: rename some chan vars * feat: fix all bugs, e2e relay works * chore: add some todo comments * wip: debugging * fix: use remote helm charts again * fix: put adequate proxied services endpoitns, prevent session republishing * chore: Refactor JSONRPCServer and server builder * Upate a couple small comments in the maketfile * revert: comment relayers out of tiltfile * chore: fix subcmd name `relayerminer` -> `relayminer` * chore: improve logging * chore: cleanup error messaging & logging in appgate server * refactor: rename misnamed `jsonRPCServer` receiver var * chore: remove appgate server debug log * chore: unexport `relayMiner` struct * refactor: interrupt signal handling * chore: improve comments * chore: improve comments * revert: tiltfile hot-reload dirs * refactor: re-consolidate client contexts * fix: typo * chore: remove todo * chore: add todo comment * revert: comment change * fix: error format strings * chore: remove comment * fix: error format strings * chore: add `-features-path` flag to cucumber tests * fix: set the relayminer URL in the curl cmd * chore: remove redundant `-X` curl arg (says curl) * squash: fix relayminer url: reword: s/relayminer/appgateserver/ * chore: improve error messaging * fix: curl invocation * test: implement step definition to assert agains relay response * chore: improve error name & messaging * Self review * fixup: merge upstream * chore: review feedback improvements * chore: update anvil service port in make targets * chore: review feedback improvements Co-authored-by: Daniel Olshansky <[email protected]> * refactor: relayminer depinject helpers & godoc comments on all constructors * refactor: separate tx and query client contexts 🙄 * fix: sessiontree store path check * fix: sessiontree store path check * chore: review feedback improvements Co-authored-by: Daniel Olshansky <[email protected]> * chore: review feedback improvements * chore: add long command description * fix: supplier client test * chore: cleanup flags and dependencies for appgateserver cmd * chore: move shared dependency setup logic to shared pkg * chore: update comment * Update .gitignore * Update OpenAPI spec * Updated comments for post 177+179 work for okdas * Update pkg/relayer/cmd/cmd.go * Update the names and references to queryNode/sequencerNode/fullNode etc * Update some comments and TODOs * Added a couple more comments * More tiny comment updates * chore: review feedback improvements Co-authored-by: Daniel Olshansky <[email protected]> * chore: add silent w/ error flag to curl * refactor: observable types to work around gomock * fix: `relayMiner#Stop()` * test: relayminer * chore: add godoc comments * chore: add comments * chore: review feedback improvements Co-authored-by: Daniel Olshansky <[email protected]> --------- Co-authored-by: Redouane Lakrache <[email protected]> Co-authored-by: Daniel Olshansky <[email protected]> Co-authored-by: harry <[email protected]>
- Loading branch information
1 parent
dd34341
commit dd8f35a
Showing
11 changed files
with
235 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package relayer_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
"time" | ||
|
||
"cosmossdk.io/depinject" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/pokt-network/poktroll/pkg/observable/channel" | ||
"github.com/pokt-network/poktroll/pkg/relayer" | ||
"github.com/pokt-network/poktroll/testutil/testrelayer" | ||
servicetypes "github.com/pokt-network/poktroll/x/service/types" | ||
) | ||
|
||
func TestRelayMiner_StartAndStop(t *testing.T) { | ||
srObs, _ := channel.NewObservable[*servicetypes.Relay]() | ||
servedRelaysObs := relayer.RelaysObservable(srObs) | ||
|
||
mrObs, _ := channel.NewObservable[*relayer.MinedRelay]() | ||
minedRelaysObs := relayer.MinedRelaysObservable(mrObs) | ||
|
||
ctx := context.Background() | ||
relayerProxyMock := testrelayer.NewMockOneTimeRelayerProxy( | ||
ctx, t, | ||
servedRelaysObs, | ||
) | ||
|
||
minerMock := testrelayer.NewMockOneTimeMiner( | ||
ctx, t, | ||
servedRelaysObs, | ||
minedRelaysObs, | ||
) | ||
|
||
relayerSessionsManagerMock := testrelayer.NewMockOneTimeRelayerSessionsManager( | ||
ctx, t, | ||
minedRelaysObs, | ||
) | ||
|
||
deps := depinject.Supply( | ||
relayerProxyMock, | ||
minerMock, | ||
relayerSessionsManagerMock, | ||
) | ||
|
||
relayminer, err := relayer.NewRelayMiner(ctx, deps) | ||
require.NoError(t, err) | ||
require.NotNil(t, relayminer) | ||
|
||
err = relayminer.Start(ctx) | ||
require.NoError(t, err) | ||
|
||
time.Sleep(time.Millisecond) | ||
|
||
err = relayminer.Stop(ctx) | ||
require.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package mockrelayer | ||
|
||
// This file is in place to declare the package for dynamically generated structs. | ||
// | ||
// Note that this does not follow the Cosmos SDK pattern of committing Mocks to main. | ||
// For example, they commit auto-generate code to main: https://github.com/cosmos/cosmos-sdk/blob/main/x/gov/testutil/expected_keepers_mocks.go | ||
// Documentation on how Cosmos uses mockgen can be found here: https://docs.cosmos.network/main/build/building-modules/testing#unit-tests | ||
// | ||
// IMPORTANT: We have attempted to use `.gitkeep` files instead, but it causes a circular dependency issue with protobuf and mock generation | ||
// since we are leveraging `ignite` to compile `.proto` files which runs `go mod tidy` before generating, requiring the entire dependency tree | ||
// to be valid before mock implementations have been generated. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package testrelayer | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/golang/mock/gomock" | ||
|
||
"github.com/pokt-network/poktroll/pkg/relayer" | ||
"github.com/pokt-network/poktroll/testutil/mockrelayer" | ||
) | ||
|
||
// NewMockOneTimeMiner creates a new mock Miner. This mock Miner will expect a | ||
// call to MinedRelays with the given context and expectedRelayObs args. When | ||
// that call is made, returnedMinedRelaysObs is returned. | ||
func NewMockOneTimeMiner( | ||
ctx context.Context, | ||
t *testing.T, | ||
expectedRelaysObs relayer.RelaysObservable, | ||
returnedMinedRelaysObs relayer.MinedRelaysObservable, | ||
) *mockrelayer.MockMiner { | ||
t.Helper() | ||
|
||
ctrl := gomock.NewController(t) | ||
minerMock := mockrelayer.NewMockMiner(ctrl) | ||
minerMock.EXPECT(). | ||
MinedRelays( | ||
gomock.Eq(ctx), | ||
gomock.Eq(expectedRelaysObs), | ||
). | ||
Return(returnedMinedRelaysObs). | ||
Times(1) | ||
return minerMock | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package testrelayer | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/golang/mock/gomock" | ||
|
||
"github.com/pokt-network/poktroll/pkg/relayer" | ||
"github.com/pokt-network/poktroll/testutil/mockrelayer" | ||
) | ||
|
||
// NewMockOneTimeRelayerProxy creates a new mock RelayerProxy. This mock | ||
// RelayerProxy will expect a call to ServedRelays with the given context, and | ||
// when that call is made, returnedRelaysObs is returned. It also expects a call | ||
// to Start and Stop with the given context. | ||
func NewMockOneTimeRelayerProxy( | ||
ctx context.Context, | ||
t *testing.T, | ||
returnedRelaysObs relayer.RelaysObservable, | ||
) *mockrelayer.MockRelayerProxy { | ||
t.Helper() | ||
|
||
ctrl := gomock.NewController(t) | ||
relayerProxyMock := mockrelayer.NewMockRelayerProxy(ctrl) | ||
relayerProxyMock.EXPECT(). | ||
Start(gomock.Eq(ctx)). | ||
Times(1) | ||
relayerProxyMock.EXPECT(). | ||
Stop(gomock.Eq(ctx)). | ||
Times(1) | ||
relayerProxyMock.EXPECT(). | ||
ServedRelays(). | ||
Return(returnedRelaysObs). | ||
Times(1) | ||
return relayerProxyMock | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package testrelayer | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/golang/mock/gomock" | ||
|
||
"github.com/pokt-network/poktroll/pkg/relayer" | ||
"github.com/pokt-network/poktroll/testutil/mockrelayer" | ||
) | ||
|
||
// NewMockOneTimeRelayerSessionsManager creates a new mock RelayerSessionsManager. | ||
// This mock RelayerSessionsManager will expect a call to InsertRelays with the | ||
// given context and expectedMinedRelaysObs args. When that call is made, | ||
// returnedMinedRelaysObs is returned. It also expects a call to Start with the | ||
// given context, and stop. | ||
func NewMockOneTimeRelayerSessionsManager( | ||
ctx context.Context, | ||
t *testing.T, | ||
expectedMinedRelaysObs relayer.MinedRelaysObservable, | ||
) *mockrelayer.MockRelayerSessionsManager { | ||
t.Helper() | ||
|
||
ctrl := gomock.NewController(t) | ||
relayerSessionsManagerMock := mockrelayer.NewMockRelayerSessionsManager(ctrl) | ||
relayerSessionsManagerMock.EXPECT(). | ||
InsertRelays(gomock.Eq(expectedMinedRelaysObs)). | ||
Times(1) | ||
relayerSessionsManagerMock.EXPECT(). | ||
Start(gomock.Eq(ctx)). | ||
Times(1) | ||
relayerSessionsManagerMock.EXPECT(). | ||
Stop(). | ||
Times(1) | ||
return relayerSessionsManagerMock | ||
} |