Skip to content

Commit

Permalink
clean up and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sontrinh16 committed Nov 21, 2024
1 parent 2b94d76 commit 400e3e1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
24 changes: 4 additions & 20 deletions tests/integration/v2/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,25 +122,17 @@ func DefaultStartUpConfig(t *testing.T) StartupConfig {

// RunMsgConfig defines the run message configuration.
type RunMsgConfig struct {
DeliverBlock bool
Commit bool
Commit bool
}

// Option is a function that can be used to configure the integration app.
type Option func(*RunMsgConfig)

// WithAutomaticDeliverBlock calls deliver block after each msg.
func WithAutomaticDeliverBlock() Option {
return func(cfg *RunMsgConfig) {
cfg.Commit = true
}
}

// WithAutomaticCommit enables automatic commit.
// This means that the integration app will automatically commit the state after each msg.
func WithAutomaticCommit() Option {
return func(cfg *RunMsgConfig) {
cfg.DeliverBlock = true
cfg.Commit = true
}
}

Expand Down Expand Up @@ -171,9 +163,7 @@ func NewApp(

// set default branch and msg router service
if routerServiceFactory == nil {
routerServiceFactory = func(key []byte) router.Service {
return stf.NewMsgRouterService(key)
}
routerServiceFactory = stf.NewMsgRouterService
}

if branchService == nil {
Expand Down Expand Up @@ -454,15 +444,9 @@ func (app *App) RunMsg(t *testing.T, ctx context.Context, handler handler, optio
resp, err = handler(ctx)

if cfg.Commit {
_, err := app.Commit(integrationCtx.state)
require.NoError(t, err)
}

if cfg.DeliverBlock {
app.lastHeight++
latestVersion, err := app.Store.GetLatestVersion()
_, err := app.Commit(integrationCtx.state)
require.NoError(t, err)
require.Equal(t, latestVersion, app.lastHeight)
}

return resp, err
Expand Down
1 change: 0 additions & 1 deletion tests/integration/v2/auth/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ func TestAsyncExec(t *testing.T) {
return resp, e
},
integration.WithAutomaticCommit(),
integration.WithAutomaticDeliverBlock(),
)
if tc.expectErr {
assert.ErrorContains(t, err, tc.expErrMsg)
Expand Down

0 comments on commit 400e3e1

Please sign in to comment.