From 4890d83acb92fbf69115f7c4c37f2c78687db2c2 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 27 Jan 2021 16:12:08 -0800 Subject: [PATCH] test: assert that pre-migrations are actually run --- chain/stmgr/forks_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/chain/stmgr/forks_test.go b/chain/stmgr/forks_test.go index 17b6542b8..95e7ef699 100644 --- a/chain/stmgr/forks_test.go +++ b/chain/stmgr/forks_test.go @@ -357,6 +357,8 @@ func TestForkPreMigration(t *testing.T) { require.False(t, found) } + counter := make(chan struct{}, 10) + sm, err := NewStateManagerWithUpgradeSchedule( cg.ChainStore(), UpgradeSchedule{{ Network: 1, @@ -374,6 +376,8 @@ func TestForkPreMigration(t *testing.T) { // the cache should be setup correctly. checkCache(t, cache) + counter <- struct{}{} + return root, nil }, PreMigrations: []PreMigration{{ @@ -386,6 +390,8 @@ func TestForkPreMigration(t *testing.T) { err := cache.Write("foo", fooCid) require.NoError(t, err) + counter <- struct{}{} + return nil }, }, { @@ -398,6 +404,8 @@ func TestForkPreMigration(t *testing.T) { err := cache.Write("bar", barCid) require.NoError(t, err) + counter <- struct{}{} + return nil }, }, { @@ -410,6 +418,8 @@ func TestForkPreMigration(t *testing.T) { err := cache.Write("fail", failCid) require.NoError(t, err) + counter <- struct{}{} + // Fail this migration. The cached entry should not be persisted. return fmt.Errorf("failed") }, @@ -422,6 +432,8 @@ func TestForkPreMigration(t *testing.T) { <-ctx.Done() close(wasCanceled) + counter <- struct{}{} + return nil }, }, { @@ -431,6 +443,8 @@ func TestForkPreMigration(t *testing.T) { checkCache(t, cache) + counter <- struct{}{} + return nil }, }}}, @@ -463,4 +477,7 @@ func TestForkPreMigration(t *testing.T) { t.Fatal(err) } } + // We have 5 pre-migration steps, and the migration. They should all have written something + // to this channel. + require.Equal(t, 6, len(counter)) }