From d5c18b68c806acc08af628e822a7e910ca703045 Mon Sep 17 00:00:00 2001 From: Sam Kleinman Date: Tue, 30 Nov 2021 12:34:16 -0500 Subject: [PATCH] e2e: more clear height test (#7347) This is a more clear version of the stable parts of the apphash tests. --- test/e2e/tests/app_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/e2e/tests/app_test.go b/test/e2e/tests/app_test.go index ab6f9739e..50989bebe 100644 --- a/test/e2e/tests/app_test.go +++ b/test/e2e/tests/app_test.go @@ -46,6 +46,7 @@ func TestApp_Hash(t *testing.T) { status, err := client.Status(ctx) require.NoError(t, err) + require.NotZero(t, status.SyncInfo.LatestBlockHeight) block, err := client.Block(ctx, &info.Response.LastBlockHeight) require.NoError(t, err) @@ -60,6 +61,29 @@ func TestApp_Hash(t *testing.T) { }) } +// Tests that the app and blockstore have and report the same height. +func TestApp_Height(t *testing.T) { + testNode(t, func(t *testing.T, node e2e.Node) { + client, err := node.Client() + require.NoError(t, err) + info, err := client.ABCIInfo(ctx) + require.NoError(t, err) + require.NotZero(t, info.Response.LastBlockHeight) + + status, err := client.Status(ctx) + require.NoError(t, err) + require.NotZero(t, status.SyncInfo.LatestBlockHeight) + + block, err := client.Block(ctx, &info.Response.LastBlockHeight) + require.NoError(t, err) + + require.Equal(t, info.Response.LastBlockHeight, block.Block.Height) + + require.True(t, status.SyncInfo.LatestBlockHeight >= info.Response.LastBlockHeight, + "status out of sync with application") + }) +} + // Tests that we can set a value and retrieve it. func TestApp_Tx(t *testing.T) { type broadcastFunc func(context.Context, types.Tx) error