From 1156e7ca0c055a9ee24ee96f999d59a245d0cc95 Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Sun, 21 Sep 2025 19:37:32 +0800 Subject: [PATCH] console: fix the wrong error msg of datadir testcase #29183 (#1540) --- console/console_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/console/console_test.go b/console/console_test.go index 09e955db23..b59f41cdb9 100644 --- a/console/console_test.go +++ b/console/console_test.go @@ -19,6 +19,7 @@ package console import ( "bytes" "errors" + "fmt" "os" "strings" "testing" @@ -152,6 +153,32 @@ func (env *tester) Close(t *testing.T) { os.RemoveAll(env.workspace) } +// Tests that the node lists the correct welcome message, notably that it contains +// the instance name, block number, data directory and supported console modules. +func TestWelcome(t *testing.T) { + tester := newTester(t, nil) + defer tester.Close(t) + + tester.console.Welcome() + + output := tester.output.String() + if want := "Welcome"; !strings.Contains(output, want) { + t.Fatalf("console output missing welcome message: have\n%s\nwant also %s", output, want) + } + if want := fmt.Sprintf("instance: %s", testInstance); !strings.Contains(output, want) { + t.Fatalf("console output missing instance: have\n%s\nwant also %s", output, want) + } + if want := "at block: 0"; !strings.Contains(output, want) { + t.Fatalf("console output missing sync status: have\n%s\nwant also %s", output, want) + } + if want := fmt.Sprintf("datadir: %s", tester.workspace); !strings.Contains(output, want) { + t.Fatalf("console output missing datadir: have\n%s\nwant also %s", output, want) + } + if want := "modules: "; !strings.Contains(output, want) { + t.Fatalf("console output missing modules: have\n%s\nwant also %s", output, want) + } +} + // Tests that JavaScript statement evaluation works as intended. func TestEvaluate(t *testing.T) { tester := newTester(t, nil)