From 385fb7a054c4f366721b868a0e52c5436d05e1d9 Mon Sep 17 00:00:00 2001 From: Phi-rjan Date: Fri, 5 Apr 2024 10:37:58 +0200 Subject: [PATCH] fix: test: TestForkPreMigration hanging when env-var is set (#11838) * Unset env-var for TestForkPreMigration Unset LOTUS_DISABLE_PRE_MIGRATIONS env-var for TestForkPreMigration test, so it does not hang * Err-check to make lint happy Err-check to make lint happy --- chain/stmgr/forks_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/chain/stmgr/forks_test.go b/chain/stmgr/forks_test.go index bf8793488..8c0227553 100644 --- a/chain/stmgr/forks_test.go +++ b/chain/stmgr/forks_test.go @@ -375,6 +375,20 @@ func testForkRefuseCall(t *testing.T, nullsBefore, nullsAfter int) { } func TestForkPreMigration(t *testing.T) { + // Backup the original value of the DISABLE_PRE_MIGRATIONS environment variable + originalValue, _ := os.LookupEnv("LOTUS_DISABLE_PRE_MIGRATIONS") + + // Unset the DISABLE_PRE_MIGRATIONS environment variable for the test + if err := os.Unsetenv("LOTUS_DISABLE_PRE_MIGRATIONS"); err != nil { + t.Fatalf("failed to unset LOTUS_DISABLE_PRE_MIGRATIONS: %v", err) + } + + // Restore the original DISABLE_PRE_MIGRATIONS environment variable at the end of the test + defer func() { + if err := os.Setenv("LOTUS_DISABLE_PRE_MIGRATIONS", originalValue); err != nil { + t.Fatalf("failed to restore LOTUS_DISABLE_PRE_MIGRATIONS: %v", err) + } + }() //stm: @CHAIN_GEN_NEXT_TIPSET_001, //stm: @CHAIN_STATE_RESOLVE_TO_KEY_ADDR_001, @CHAIN_STATE_SET_VM_CONSTRUCTOR_001 logging.SetAllLoggers(logging.LevelInfo)