fix up e2e tests

This commit is contained in:
Callum Waters
2022-09-30 12:30:51 +02:00
parent d1616c192b
commit a2978b4b10
4 changed files with 27 additions and 20 deletions
+1 -1
View File
@@ -469,7 +469,7 @@ func (h *Handshaker) replayBlocks(
assertAppHashEqualsOneFromBlock(appHash, block)
}
err = sm.ExecCommitBlock(proxyApp.Consensus(), block, h.logger, h.stateStore, h.genDoc.InitialHeight)
appHash, err = sm.ExecCommitBlock(proxyApp.Consensus(), block, h.logger, h.stateStore, h.genDoc.InitialHeight)
if err != nil {
return nil, err
}
+7 -7
View File
@@ -570,19 +570,19 @@ func ExecCommitBlock(
logger log.Logger,
store Store,
initialHeight int64,
) error {
_, err := execBlockOnProxyApp(logger, appConnConsensus, block, store, initialHeight)
) ([]byte, error) {
resp, err := execBlockOnProxyApp(logger, appConnConsensus, block, store, initialHeight)
if err != nil {
logger.Error("failed executing block on proxy app", "height", block.Height, "err", err)
return err
return nil, err
}
// Commit block, get hash back
res, err := appConnConsensus.Commit(context.TODO())
_, err = appConnConsensus.Commit(context.TODO())
if err != nil {
logger.Error("client error during proxyAppConn.CommitSync", "err", res)
return err
logger.Error("client error during proxyAppConn.CommitSync", "err", err)
return nil, err
}
return nil
return resp.AgreedAppData, nil
}
+5 -5
View File
@@ -74,8 +74,8 @@ func TestApplyBlock(t *testing.T) {
assert.EqualValues(t, 1, state.Version.Consensus.App, "App version wasn't updated")
}
// TestBeginBlockValidators ensures we send absent validators list.
func TestBeginBlockValidators(t *testing.T) {
// TestFinalizeBlockValidators ensures we send absent validators list.
func TestFinalizeBlockValidators(t *testing.T) {
app := &testApp{}
cc := proxy.NewLocalClientCreator(app)
proxyApp := proxy.NewAppConns(cc, proxy.NopMetrics())
@@ -121,7 +121,7 @@ func TestBeginBlockValidators(t *testing.T) {
// block for height 2
block := makeBlock(state, 2, lastCommit)
err = sm.ExecCommitBlock(proxyApp.Consensus(), block, log.TestingLogger(), stateStore, 1)
_, err = sm.ExecCommitBlock(proxyApp.Consensus(), block, log.TestingLogger(), stateStore, 1)
require.Nil(t, err, tc.desc)
// -> app receives a list of validators with a bool indicating if they signed
@@ -139,8 +139,8 @@ func TestBeginBlockValidators(t *testing.T) {
}
}
// TestBeginBlockByzantineValidators ensures we send byzantine validators list.
func TestBeginBlockByzantineValidators(t *testing.T) {
// TestFinalizeBlockByzantineValidators ensures we send byzantine validators list.
func TestFinalizeBlockByzantineValidators(t *testing.T) {
app := &testApp{}
cc := proxy.NewLocalClientCreator(app)
proxyApp := proxy.NewAppConns(cc, proxy.NopMetrics())
+14 -7
View File
@@ -42,15 +42,22 @@ func TestApp_Hash(t *testing.T) {
require.NoError(t, err)
require.NotEmpty(t, info.Response.LastBlockAppHash, "expected app to return app hash")
block, err := client.Block(ctx, nil)
require.NoError(t, err)
require.EqualValues(t, info.Response.LastBlockAppHash, block.Block.AppHash,
"app hash does not match last block's app hash")
// In next-block execution, the app hash is stored in the next block
requestedHeight := info.Response.LastBlockHeight + 1
status, err := client.Status(ctx)
require.Eventually(t, func() bool {
status, err := client.Status(ctx)
require.NoError(t, err)
require.NotZero(t, status.SyncInfo.LatestBlockHeight)
return status.SyncInfo.LatestBlockHeight >= requestedHeight
}, 5*time.Second, 500*time.Millisecond)
block, err := client.Block(ctx, &requestedHeight)
require.NoError(t, err)
require.EqualValues(t, info.Response.LastBlockAppHash, status.SyncInfo.LatestAppHash,
"app hash does not match node status")
require.Equal(t,
fmt.Sprintf("%x", info.Response.LastBlockAppHash),
fmt.Sprintf("%x", block.Block.AppHash.Bytes()),
"app hash does not match last block's app hash")
})
}