Skip to content

Commit 473f813

Browse files
authored
Improve test legibility (#388)
* use gotestsum test runner for validation checks color coded output with summary at the end * flatten out test nesting * use CHAIN_ID in justfile * use gotestsum everywhere in justfile * install gotestsum globally in CI
1 parent 9702f3c commit 473f813

File tree

3 files changed

+29
-34
lines changed

3 files changed

+29
-34
lines changed

.circleci/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ jobs:
5555
steps:
5656
- checkout
5757
- install-just
58+
- run:
59+
name: Install gotestsum
60+
command: go install gotest.tools/gotestsum@latest
5861
- run:
5962
# need foundry to execute 'cast call' within add-chain script
6063
name: Install foundry

justfile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@ test-all: test-add-chain test-superchain test-validation
2929
test-add-chain:
3030
# We separate the first test from the rest because it generates artifacts
3131
# Which need to exist before the remaining tests run.
32-
go test ./add-chain/... -run TestAddChain_Main -v
33-
go test ./add-chain/... -run '[^TestAddChain_Main]' -v
32+
TEST_DIRECTORY=./add-chain go run gotest.tools/gotestsum@latest --format testname -- -run TestAddChain_Main
33+
TEST_DIRECTORY=./add-chain go run gotest.tools/gotestsum@latest --format testname -- -run '[^TestAddChain_Main]'
3434

3535
# Test all Go code in the superchain module
3636
test-superchain:
37-
go test ./superchain/... -v
37+
TEST_DIRECTORY=./superchain go run gotest.tools/gotestsum@latest --format testname
3838

3939
# Test all Go code in the validation module
40-
test-validation:
41-
go test ./validation/... -v
40+
test-validation: clean-add-chain
41+
TEST_DIRECTORY=./validation go run gotest.tools/gotestsum@latest --format testname
4242

4343
# Run validation checks for chains with a name or chain ID matching the supplied regex, example: just validate 10
44-
validate CHAIN:
45-
go test ./validation/... -v -run=TestValidation/{{CHAIN}}
44+
validate CHAIN_ID:
45+
TEST_DIRECTORY=./validation go run gotest.tools/gotestsum@latest --format testname -- -run=TestValidation/{{CHAIN_ID}}
4646

4747
# Clean test files generated by the add-chain tooling
4848
clean-add-chain:

validation/validation_test.go

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,16 @@ func TestValidation(t *testing.T) {
1919
}
2020

2121
func testValidation(t *testing.T, chain *ChainConfig) {
22-
t.Run("Universal Checks", func(t *testing.T) {
23-
testUniversal(t, chain)
24-
})
25-
26-
t.Run("Standard Chain", func(t *testing.T) {
27-
if chain.SuperchainLevel != Standard {
28-
t.Skip("Chain excluded from this check (NOT a Standard Chain)")
29-
}
30-
testStandard(t, chain)
31-
})
22+
testUniversal(t, chain)
3223

33-
t.Run("Standard or Standard Candidate Chain", func(t *testing.T) {
34-
if !chain.StandardChainCandidate && chain.SuperchainLevel != Standard {
35-
t.Skip("Chain excluded from this check (NOT a Standard or a Standard Candidate Chain)")
36-
}
24+
if chain.SuperchainLevel == Standard ||
25+
(chain.SuperchainLevel == Frontier && chain.StandardChainCandidate) {
3726
testStandardCandidate(t, chain)
38-
})
27+
}
28+
29+
if chain.SuperchainLevel == Standard {
30+
testStandard(t, chain)
31+
}
3932
}
4033

4134
// testUniversal should be applied to each chain in the registry
@@ -60,18 +53,17 @@ func testUniversal(t *testing.T, chain *ChainConfig) {
6053

6154
// testStandardCandidate applies to Standard and Standard Candidate Chains.
6255
func testStandardCandidate(t *testing.T, chain *ChainConfig) {
63-
t.Run("Standard Config Params", func(t *testing.T) {
64-
t.Run("Data Availability", func(t *testing.T) { testDataAvailability(t, chain) })
65-
t.Run("Resource Config", func(t *testing.T) { testResourceConfig(t, chain) })
66-
t.Run("L2OO Params", func(t *testing.T) { testL2OOParams(t, chain) })
67-
t.Run("Gas Limit", func(t *testing.T) { testGasLimit(t, chain) })
68-
t.Run("GPO Params", func(t *testing.T) { testGasPriceOracleParams(t, chain) })
69-
t.Run("Superchain Config", func(t *testing.T) { testSuperchainConfig(t, chain) })
70-
})
71-
t.Run("Standard Config Roles", func(t *testing.T) {
72-
t.Run("L1 Security Config", func(t *testing.T) { testL1SecurityConfig(t, chain.ChainID) })
73-
t.Run("L2 Security Config", func(t *testing.T) { testL2SecurityConfig(t, chain) })
74-
})
56+
// Standard Config Params
57+
t.Run("Data Availability", func(t *testing.T) { testDataAvailability(t, chain) })
58+
t.Run("Resource Config", func(t *testing.T) { testResourceConfig(t, chain) })
59+
t.Run("L2OO Params", func(t *testing.T) { testL2OOParams(t, chain) })
60+
t.Run("Gas Limit", func(t *testing.T) { testGasLimit(t, chain) })
61+
t.Run("GPO Params", func(t *testing.T) { testGasPriceOracleParams(t, chain) })
62+
t.Run("Superchain Config", func(t *testing.T) { testSuperchainConfig(t, chain) })
63+
// Standard Config Roles
64+
t.Run("L1 Security Config", func(t *testing.T) { testL1SecurityConfig(t, chain.ChainID) })
65+
t.Run("L2 Security Config", func(t *testing.T) { testL2SecurityConfig(t, chain) })
66+
// Standard Contract Versions
7567
t.Run("Standard Contract Versions", func(t *testing.T) {
7668
testContractsMatchATag(t, chain)
7769
})

0 commit comments

Comments
 (0)