-
Notifications
You must be signed in to change notification settings - Fork 69
/
validation_test.go
74 lines (65 loc) · 2.79 KB
/
validation_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package validation
import (
"testing"
. "github.com/ethereum-optimism/superchain-registry/superchain"
)
func TestValidation(t *testing.T) {
// Entry point for validation checks which run
// on each OP chain.
for _, chain := range OPChains {
chain := chain
t.Run(perChainTestName(chain), func(t *testing.T) {
t.Parallel()
testValidation(t, chain)
})
}
}
func testValidation(t *testing.T, chain *ChainConfig) {
testUniversal(t, chain)
if chain.SuperchainLevel == Standard ||
(chain.SuperchainLevel == Frontier && chain.StandardChainCandidate) {
testStandardCandidate(t, chain)
}
if chain.SuperchainLevel == Standard {
testStandard(t, chain)
}
}
// testUniversal should be applied to each chain in the registry
// regardless of superchain_level. There should be no
// exceptions, since the test is e.g.
// designed to protect downstream software or
// sanity checking basic consistency conditions.
func testUniversal(t *testing.T, chain *ChainConfig) {
t.Run("Genesis Hash Check", func(t *testing.T) { testGenesisHash(t, chain.ChainID) })
t.Run("Genesis RPC Check", func(t *testing.T) { testGenesisHashAgainstRPC(t, chain) })
t.Run("Uniqueness Check", func(t *testing.T) { testIsGloballyUnique(t, chain) })
t.Run("ChainID RPC Check", func(t *testing.T) { testChainIDFromRPC(t, chain) })
}
// testStandardCandidate applies to Standard and Standard Candidate Chains.
func testStandardCandidate(t *testing.T, chain *ChainConfig) {
// Standard Config Params
t.Run("Rollup Config", func(t *testing.T) { testRollupConfig(t, chain) })
t.Run("Gas Token", (func(t *testing.T) { testGasToken(t, chain) }))
t.Run("Resource Config", func(t *testing.T) { testResourceConfig(t, chain) })
t.Run("Gas Limit", func(t *testing.T) { testGasLimit(t, chain) })
t.Run("GPO Params", func(t *testing.T) { testGasPriceOracleParams(t, chain) })
t.Run("Start Block RPC Check", func(t *testing.T) { testStartBlock(t, chain) })
t.Run("Superchain Config", func(t *testing.T) { testSuperchainConfig(t, chain) })
// Standard Config Roles
t.Run("L1 Security Config", func(t *testing.T) { testL1SecurityConfig(t, chain.ChainID) })
t.Run("L2 Security Config", func(t *testing.T) { testL2SecurityConfig(t, chain) })
// Other
t.Run("Data Availability Type", func(t *testing.T) { testDataAvailabilityType(t, chain) })
}
// testStandard should be applied only to a fully Standard Chain,
// i.e. not to a Standard Candidate Chain.
func testStandard(t *testing.T, chain *ChainConfig) {
// Standard Contract Versions
t.Run("Standard Contract Versions", func(t *testing.T) {
testContractsMatchATag(t, chain)
})
// Standard Config Params
t.Run("Optimism Portal 2 Params", func(t *testing.T) { testOptimismPortal2Params(t, chain) })
// Standard Config Roles
t.Run("Key Handover Check", func(t *testing.T) { testKeyHandover(t, chain.ChainID) })
}