Skip to content

Commit 460cc16

Browse files
authored
cmd: run tests in parallel (#28546)
1 parent 14a1e96 commit 460cc16

18 files changed

+63
-3
lines changed

cmd/abigen/namefilter_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
)
99

1010
func TestNameFilter(t *testing.T) {
11+
t.Parallel()
1112
_, err := newNameFilter("Foo")
1213
require.Error(t, err)
1314
_, err = newNameFilter("too/many:colons:Foo")

cmd/clef/consolecmd_test.go

+10-3
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,13 @@ import (
2626

2727
// TestImportRaw tests clef --importraw
2828
func TestImportRaw(t *testing.T) {
29+
t.Parallel()
2930
keyPath := filepath.Join(os.TempDir(), fmt.Sprintf("%v-tempkey.test", t.Name()))
3031
os.WriteFile(keyPath, []byte("0102030405060708090a0102030405060708090a0102030405060708090a0102"), 0777)
3132
t.Cleanup(func() { os.Remove(keyPath) })
3233

33-
t.Parallel()
3434
t.Run("happy-path", func(t *testing.T) {
35+
t.Parallel()
3536
// Run clef importraw
3637
clef := runClef(t, "--suppress-bootwarn", "--lightkdf", "importraw", keyPath)
3738
clef.input("myverylongpassword").input("myverylongpassword")
@@ -43,6 +44,7 @@ func TestImportRaw(t *testing.T) {
4344
})
4445
// tests clef --importraw with mismatched passwords.
4546
t.Run("pw-mismatch", func(t *testing.T) {
47+
t.Parallel()
4648
// Run clef importraw
4749
clef := runClef(t, "--suppress-bootwarn", "--lightkdf", "importraw", keyPath)
4850
clef.input("myverylongpassword1").input("myverylongpassword2").WaitExit()
@@ -52,6 +54,7 @@ func TestImportRaw(t *testing.T) {
5254
})
5355
// tests clef --importraw with a too short password.
5456
t.Run("short-pw", func(t *testing.T) {
57+
t.Parallel()
5558
// Run clef importraw
5659
clef := runClef(t, "--suppress-bootwarn", "--lightkdf", "importraw", keyPath)
5760
clef.input("shorty").input("shorty").WaitExit()
@@ -64,19 +67,21 @@ func TestImportRaw(t *testing.T) {
6467

6568
// TestListAccounts tests clef --list-accounts
6669
func TestListAccounts(t *testing.T) {
70+
t.Parallel()
6771
keyPath := filepath.Join(os.TempDir(), fmt.Sprintf("%v-tempkey.test", t.Name()))
6872
os.WriteFile(keyPath, []byte("0102030405060708090a0102030405060708090a0102030405060708090a0102"), 0777)
6973
t.Cleanup(func() { os.Remove(keyPath) })
7074

71-
t.Parallel()
7275
t.Run("no-accounts", func(t *testing.T) {
76+
t.Parallel()
7377
clef := runClef(t, "--suppress-bootwarn", "--lightkdf", "list-accounts")
7478
if out := string(clef.Output()); !strings.Contains(out, "The keystore is empty.") {
7579
t.Logf("Output\n%v", out)
7680
t.Error("Failure")
7781
}
7882
})
7983
t.Run("one-account", func(t *testing.T) {
84+
t.Parallel()
8085
// First, we need to import
8186
clef := runClef(t, "--suppress-bootwarn", "--lightkdf", "importraw", keyPath)
8287
clef.input("myverylongpassword").input("myverylongpassword").WaitExit()
@@ -91,19 +96,21 @@ func TestListAccounts(t *testing.T) {
9196

9297
// TestListWallets tests clef --list-wallets
9398
func TestListWallets(t *testing.T) {
99+
t.Parallel()
94100
keyPath := filepath.Join(os.TempDir(), fmt.Sprintf("%v-tempkey.test", t.Name()))
95101
os.WriteFile(keyPath, []byte("0102030405060708090a0102030405060708090a0102030405060708090a0102"), 0777)
96102
t.Cleanup(func() { os.Remove(keyPath) })
97103

98-
t.Parallel()
99104
t.Run("no-accounts", func(t *testing.T) {
105+
t.Parallel()
100106
clef := runClef(t, "--suppress-bootwarn", "--lightkdf", "list-wallets")
101107
if out := string(clef.Output()); !strings.Contains(out, "There are no wallets.") {
102108
t.Logf("Output\n%v", out)
103109
t.Error("Failure")
104110
}
105111
})
106112
t.Run("one-account", func(t *testing.T) {
113+
t.Parallel()
107114
// First, we need to import
108115
clef := runClef(t, "--suppress-bootwarn", "--lightkdf", "importraw", keyPath)
109116
clef.input("myverylongpassword").input("myverylongpassword").WaitExit()

cmd/devp2p/dns_route53_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
// This test checks that computeChanges/splitChanges create DNS changes in
2727
// leaf-added -> root-changed -> leaf-deleted order.
2828
func TestRoute53ChangeSort(t *testing.T) {
29+
t.Parallel()
2930
testTree0 := map[string]recordSet{
3031
"2kfjogvxdqtxxugbh7gs7naaai.n": {ttl: 3333, values: []string{
3132
`"enr:-HW4QO1ml1DdXLeZLsUxewnthhUy8eROqkDyoMTyavfks9JlYQIlMFEUoM78PovJDPQrAkrb3LRJ-""vtrymDguKCOIAWAgmlkgnY0iXNlY3AyNTZrMaEDffaGfJzgGhUif1JqFruZlYmA31HzathLSWxfbq_QoQ4"`,
@@ -164,6 +165,7 @@ func TestRoute53ChangeSort(t *testing.T) {
164165

165166
// This test checks that computeChanges compares the quoted value of the records correctly.
166167
func TestRoute53NoChange(t *testing.T) {
168+
t.Parallel()
167169
// Existing record set.
168170
testTree0 := map[string]recordSet{
169171
"n": {ttl: rootTTL, values: []string{

cmd/devp2p/internal/ethtest/chain_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
// TestEthProtocolNegotiation tests whether the test suite
3131
// can negotiate the highest eth protocol in a status message exchange
3232
func TestEthProtocolNegotiation(t *testing.T) {
33+
t.Parallel()
3334
var tests = []struct {
3435
conn *Conn
3536
caps []p2p.Cap
@@ -125,6 +126,7 @@ func TestEthProtocolNegotiation(t *testing.T) {
125126
// TestChain_GetHeaders tests whether the test suite can correctly
126127
// respond to a GetBlockHeaders request from a node.
127128
func TestChain_GetHeaders(t *testing.T) {
129+
t.Parallel()
128130
chainFile, err := filepath.Abs("./testdata/chain.rlp")
129131
if err != nil {
130132
t.Fatal(err)

cmd/devp2p/internal/ethtest/suite_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ var (
3535
)
3636

3737
func TestEthSuite(t *testing.T) {
38+
t.Parallel()
3839
geth, err := runGeth()
3940
if err != nil {
4041
t.Fatalf("could not run geth: %v", err)
@@ -56,6 +57,7 @@ func TestEthSuite(t *testing.T) {
5657
}
5758

5859
func TestSnapSuite(t *testing.T) {
60+
t.Parallel()
5961
geth, err := runGeth()
6062
if err != nil {
6163
t.Fatalf("could not run geth: %v", err)

cmd/ethkey/message_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
)
2323

2424
func TestMessageSignVerify(t *testing.T) {
25+
t.Parallel()
2526
tmpdir := t.TempDir()
2627

2728
keyfile := filepath.Join(tmpdir, "the-keyfile")

cmd/evm/t8n_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ func (args *t8nOutput) get() (out []string) {
106106
}
107107

108108
func TestT8n(t *testing.T) {
109+
t.Parallel()
109110
tt := new(testT8n)
110111
tt.TestCmd = cmdtest.NewTestCmd(t, tt)
111112
for i, tc := range []struct {
@@ -338,6 +339,7 @@ func (args *t9nInput) get(base string) []string {
338339
}
339340

340341
func TestT9n(t *testing.T) {
342+
t.Parallel()
341343
tt := new(testT8n)
342344
tt.TestCmd = cmdtest.NewTestCmd(t, tt)
343345
for i, tc := range []struct {
@@ -473,6 +475,7 @@ func (args *b11rInput) get(base string) []string {
473475
}
474476

475477
func TestB11r(t *testing.T) {
478+
t.Parallel()
476479
tt := new(testT8n)
477480
tt.TestCmd = cmdtest.NewTestCmd(t, tt)
478481
for i, tc := range []struct {

cmd/faucet/faucet_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
)
2424

2525
func TestFacebook(t *testing.T) {
26+
t.Parallel()
2627
// TODO: Remove facebook auth or implement facebook api, which seems to require an API key
2728
t.Skipf("The facebook access is flaky, needs to be reimplemented or removed")
2829
for _, tt := range []struct {

cmd/geth/accountcmd_test.go

+16
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@ func tmpDatadirWithKeystore(t *testing.T) string {
4343
}
4444

4545
func TestAccountListEmpty(t *testing.T) {
46+
t.Parallel()
4647
geth := runGeth(t, "account", "list")
4748
geth.ExpectExit()
4849
}
4950

5051
func TestAccountList(t *testing.T) {
52+
t.Parallel()
5153
datadir := tmpDatadirWithKeystore(t)
5254
var want = `
5355
Account #0: {7ef5a6135f1fd6a02593eedc869c6d41d934aef8} keystore://{{.Datadir}}/keystore/UTC--2016-03-22T12-57-55.920751759Z--7ef5a6135f1fd6a02593eedc869c6d41d934aef8
@@ -74,6 +76,7 @@ Account #2: {289d485d9771714cce91d3393d764e1311907acc} keystore://{{.Datadir}}\k
7476
}
7577

7678
func TestAccountNew(t *testing.T) {
79+
t.Parallel()
7780
geth := runGeth(t, "account", "new", "--lightkdf")
7881
defer geth.ExpectExit()
7982
geth.Expect(`
@@ -96,6 +99,7 @@ Path of the secret key file: .*UTC--.+--[0-9a-f]{40}
9699
}
97100

98101
func TestAccountImport(t *testing.T) {
102+
t.Parallel()
99103
tests := []struct{ name, key, output string }{
100104
{
101105
name: "correct account",
@@ -118,6 +122,7 @@ func TestAccountImport(t *testing.T) {
118122
}
119123

120124
func TestAccountHelp(t *testing.T) {
125+
t.Parallel()
121126
geth := runGeth(t, "account", "-h")
122127
geth.WaitExit()
123128
if have, want := geth.ExitStatus(), 0; have != want {
@@ -147,6 +152,7 @@ func importAccountWithExpect(t *testing.T, key string, expected string) {
147152
}
148153

149154
func TestAccountNewBadRepeat(t *testing.T) {
155+
t.Parallel()
150156
geth := runGeth(t, "account", "new", "--lightkdf")
151157
defer geth.ExpectExit()
152158
geth.Expect(`
@@ -159,6 +165,7 @@ Fatal: Passwords do not match
159165
}
160166

161167
func TestAccountUpdate(t *testing.T) {
168+
t.Parallel()
162169
datadir := tmpDatadirWithKeystore(t)
163170
geth := runGeth(t, "account", "update",
164171
"--datadir", datadir, "--lightkdf",
@@ -175,6 +182,7 @@ Repeat password: {{.InputLine "foobar2"}}
175182
}
176183

177184
func TestWalletImport(t *testing.T) {
185+
t.Parallel()
178186
geth := runGeth(t, "wallet", "import", "--lightkdf", "testdata/guswallet.json")
179187
defer geth.ExpectExit()
180188
geth.Expect(`
@@ -190,6 +198,7 @@ Address: {d4584b5f6229b7be90727b0fc8c6b91bb427821f}
190198
}
191199

192200
func TestWalletImportBadPassword(t *testing.T) {
201+
t.Parallel()
193202
geth := runGeth(t, "wallet", "import", "--lightkdf", "testdata/guswallet.json")
194203
defer geth.ExpectExit()
195204
geth.Expect(`
@@ -200,6 +209,7 @@ Fatal: could not decrypt key with given password
200209
}
201210

202211
func TestUnlockFlag(t *testing.T) {
212+
t.Parallel()
203213
geth := runMinimalGeth(t, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t),
204214
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "console", "--exec", "loadScript('testdata/empty.js')")
205215
geth.Expect(`
@@ -222,6 +232,7 @@ undefined
222232
}
223233

224234
func TestUnlockFlagWrongPassword(t *testing.T) {
235+
t.Parallel()
225236
geth := runMinimalGeth(t, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t),
226237
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "console", "--exec", "loadScript('testdata/empty.js')")
227238

@@ -240,6 +251,7 @@ Fatal: Failed to unlock account f466859ead1932d743d622cb74fc058882e8648a (could
240251

241252
// https://github.com/ethereum/go-ethereum/issues/1785
242253
func TestUnlockFlagMultiIndex(t *testing.T) {
254+
t.Parallel()
243255
geth := runMinimalGeth(t, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t),
244256
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "--unlock", "0,2", "console", "--exec", "loadScript('testdata/empty.js')")
245257

@@ -266,6 +278,7 @@ undefined
266278
}
267279

268280
func TestUnlockFlagPasswordFile(t *testing.T) {
281+
t.Parallel()
269282
geth := runMinimalGeth(t, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t),
270283
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "--password", "testdata/passwords.txt", "--unlock", "0,2", "console", "--exec", "loadScript('testdata/empty.js')")
271284

@@ -287,6 +300,7 @@ undefined
287300
}
288301

289302
func TestUnlockFlagPasswordFileWrongPassword(t *testing.T) {
303+
t.Parallel()
290304
geth := runMinimalGeth(t, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t),
291305
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "--password",
292306
"testdata/wrong-passwords.txt", "--unlock", "0,2")
@@ -297,6 +311,7 @@ Fatal: Failed to unlock account 0 (could not decrypt key with given password)
297311
}
298312

299313
func TestUnlockFlagAmbiguous(t *testing.T) {
314+
t.Parallel()
300315
store := filepath.Join("..", "..", "accounts", "keystore", "testdata", "dupes")
301316
geth := runMinimalGeth(t, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t),
302317
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "--keystore",
@@ -336,6 +351,7 @@ undefined
336351
}
337352

338353
func TestUnlockFlagAmbiguousWrongPassword(t *testing.T) {
354+
t.Parallel()
339355
store := filepath.Join("..", "..", "accounts", "keystore", "testdata", "dupes")
340356
geth := runMinimalGeth(t, "--port", "0", "--ipcdisable", "--datadir", tmpDatadirWithKeystore(t),
341357
"--unlock", "f466859ead1932d743d622cb74fc058882e8648a", "--keystore",

cmd/geth/consolecmd_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ func runMinimalGeth(t *testing.T, args ...string) *testgeth {
5050
// Tests that a node embedded within a console can be started up properly and
5151
// then terminated by closing the input stream.
5252
func TestConsoleWelcome(t *testing.T) {
53+
t.Parallel()
5354
coinbase := "0x8605cdbbdb6d264aa742e77020dcbc58fcdce182"
5455

5556
// Start a geth console, make sure it's cleaned up and terminate the console

cmd/geth/exportcmd_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727

2828
// TestExport does a basic test of "geth export", exporting the test-genesis.
2929
func TestExport(t *testing.T) {
30+
t.Parallel()
3031
outfile := fmt.Sprintf("%v/testExport.out", os.TempDir())
3132
defer os.Remove(outfile)
3233
geth := runGeth(t, "--datadir", initGeth(t), "export", outfile)

cmd/geth/les_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ func startClient(t *testing.T, name string) *gethrpc {
156156
}
157157

158158
func TestPriorityClient(t *testing.T) {
159+
t.Parallel()
159160
lightServer := startLightServer(t)
160161
defer lightServer.killAndWait()
161162

cmd/geth/logging_test.go

+4
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func censor(input string, start, end int) string {
5858
}
5959

6060
func TestLogging(t *testing.T) {
61+
t.Parallel()
6162
testConsoleLogging(t, "terminal", 6, 24)
6263
testConsoleLogging(t, "logfmt", 2, 26)
6364
}
@@ -98,6 +99,7 @@ func testConsoleLogging(t *testing.T, format string, tStart, tEnd int) {
9899
}
99100

100101
func TestVmodule(t *testing.T) {
102+
t.Parallel()
101103
checkOutput := func(level int, want, wantNot string) {
102104
t.Helper()
103105
output, err := runSelf("--log.format", "terminal", "--verbosity=0", "--log.vmodule", fmt.Sprintf("logtestcmd_active.go=%d", level), "logtest")
@@ -145,6 +147,7 @@ func nicediff(have, want []byte) string {
145147
}
146148

147149
func TestFileOut(t *testing.T) {
150+
t.Parallel()
148151
var (
149152
have, want []byte
150153
err error
@@ -165,6 +168,7 @@ func TestFileOut(t *testing.T) {
165168
}
166169

167170
func TestRotatingFileOut(t *testing.T) {
171+
t.Parallel()
168172
var (
169173
have, want []byte
170174
err error

0 commit comments

Comments
 (0)