Skip to content

Commit

Permalink
test: Fix kvstore test
Browse files Browse the repository at this point in the history
  • Loading branch information
dudong2 committed Jan 11, 2025
1 parent 05fd5f9 commit 7d9de48
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
12 changes: 12 additions & 0 deletions abci/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,18 @@ func (r *ReqRes) SetInvoked() {
r.mtx.Unlock()
}

// GetCallback returns the configured callback of the ReqRes object which may be
// nil. Note, it is not safe to concurrently call this in cases where it is
// marked done and SetCallback is called before calling GetCallback as that
// will invoke the callback twice and create a potential race condition.
//
// ref: https://github.com/tendermint/tendermint/issues/5439
func (r *ReqRes) GetCallback() func(*types.Response) {
r.mtx.Lock()
defer r.mtx.Unlock()
return r.cb
}

func waitGroup1() (wg *sync.WaitGroup) {
wg = &sync.WaitGroup{}
wg.Add(1)
Expand Down
19 changes: 9 additions & 10 deletions abci/example/kvstore/kvstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,15 @@ func TestKVStoreKV(t *testing.T) {
}

func testKVStore(ctx context.Context, t *testing.T, app types.Application, tx []byte, key, value string) {
// var (
// checkTxResp *types.ResponseCheckTx
// err error
// )
// if client, ok := app.(abcicli.Client); ok {
// checkTxResp, err = client.CheckTxSync(ctx, &types.RequestCheckTx{Tx: tx})
// } else {
// checkTxResp, err = app.CheckTxSyncForApp(ctx, &types.RequestCheckTx{Tx: tx})
// }
checkTxResp, err := app.CheckTxSyncForApp(ctx, &types.RequestCheckTx{Tx: tx})
var (
checkTxResp *types.ResponseCheckTx
err error
)
if client, ok := app.(abcicli.Client); ok {
checkTxResp, err = client.CheckTxSync(ctx, &types.RequestCheckTx{Tx: tx})
} else {
checkTxResp, err = app.CheckTxSyncForApp(ctx, &types.RequestCheckTx{Tx: tx})
}
require.NoError(t, err)
require.Equal(t, uint32(0), checkTxResp.Code)

Expand Down

0 comments on commit 7d9de48

Please sign in to comment.