7
7
"fmt"
8
8
"log/slog"
9
9
"math/big"
10
+ "os"
10
11
"strings"
11
12
"testing"
12
13
@@ -52,6 +53,72 @@ func (d *deployerKey) String() string {
52
53
return "deployer-key"
53
54
}
54
55
56
+ func TestLiveChain (t * testing.T ) {
57
+ op_e2e .InitParallel (t )
58
+
59
+ for _ , network := range []string {"mainnet" , "sepolia" } {
60
+ t .Run (network , func (t * testing.T ) {
61
+ testLiveChainNetwork (t , network )
62
+ })
63
+ }
64
+ }
65
+
66
+ func testLiveChainNetwork (t * testing.T , network string ) {
67
+ op_e2e .InitParallel (t )
68
+ lgr := testlog .Logger (t , slog .LevelInfo )
69
+ rpcURL := os .Getenv (fmt .Sprintf ("%s_RPC_URL" , strings .ToUpper (network )))
70
+ require .NotEmpty (t , rpcURL )
71
+
72
+ forkedL1 , cleanup , err := devnet .NewForked (lgr , rpcURL )
73
+ require .NoError (t , err )
74
+ t .Cleanup (func () {
75
+ require .NoError (t , cleanup ())
76
+ })
77
+
78
+ l1Client , err := ethclient .Dial (forkedL1 .RPCUrl ())
79
+ require .NoError (t , err )
80
+
81
+ ctx , cancel := context .WithCancel (context .Background ())
82
+ defer cancel ()
83
+
84
+ l1ChainID , err := l1Client .ChainID (ctx )
85
+ require .NoError (t , err )
86
+
87
+ pk , err := crypto .HexToECDSA ("ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" )
88
+ require .NoError (t , err )
89
+ dk , err := devkeys .NewMnemonicDevKeys (devkeys .TestMnemonic )
90
+ require .NoError (t , err )
91
+
92
+ testCacheDir := testutils .IsolatedTestDirWithAutoCleanup (t )
93
+
94
+ intent , st := newIntent (
95
+ t ,
96
+ l1ChainID ,
97
+ dk ,
98
+ uint256 .NewInt (9999 ),
99
+ artifacts .DefaultL1ContractsLocator ,
100
+ artifacts .DefaultL2ContractsLocator ,
101
+ )
102
+ cg := ethClientCodeGetter (ctx , l1Client )
103
+
104
+ require .NoError (t , deployer .ApplyPipeline (
105
+ ctx ,
106
+ deployer.ApplyPipelineOpts {
107
+ DeploymentTarget : deployer .DeploymentTargetLive ,
108
+ L1RPCUrl : forkedL1 .RPCUrl (),
109
+ DeployerPrivateKey : pk ,
110
+ Intent : intent ,
111
+ State : st ,
112
+ Logger : lgr ,
113
+ StateWriter : pipeline .NoopStateWriter (),
114
+ CacheDir : testCacheDir ,
115
+ },
116
+ ))
117
+
118
+ validateSuperchainDeployment (t , st , cg , false )
119
+ validateOPChainDeployment (t , cg , st , intent , false )
120
+ }
121
+
55
122
func TestEndToEndApply (t * testing.T ) {
56
123
op_e2e .InitParallel (t )
57
124
@@ -120,7 +187,7 @@ func TestEndToEndApply(t *testing.T) {
120
187
},
121
188
))
122
189
123
- validateSuperchainDeployment (t , st , cg )
190
+ validateSuperchainDeployment (t , st , cg , true )
124
191
validateOPChainDeployment (t , cg , st , intent , false )
125
192
})
126
193
@@ -144,7 +211,7 @@ func TestEndToEndApply(t *testing.T) {
144
211
},
145
212
))
146
213
147
- validateSuperchainDeployment (t , st , cg )
214
+ validateSuperchainDeployment (t , st , cg , true )
148
215
validateOPChainDeployment (t , cg , st , intent , false )
149
216
})
150
217
@@ -228,7 +295,7 @@ func TestApplyGenesisStrategy(t *testing.T) {
228
295
require .NoError (t , deployer .ApplyPipeline (ctx , opts ))
229
296
230
297
cg := stateDumpCodeGetter (st )
231
- validateSuperchainDeployment (t , st , cg )
298
+ validateSuperchainDeployment (t , st , cg , true )
232
299
233
300
for i := range intent .Chains {
234
301
t .Run (fmt .Sprintf ("chain-%d" , i ), func (t * testing.T ) {
@@ -650,20 +717,25 @@ func stateDumpCodeGetter(st *state.State) codeGetter {
650
717
}
651
718
}
652
719
653
- func validateSuperchainDeployment (t * testing.T , st * state.State , cg codeGetter ) {
654
- addrs := [] struct {
720
+ func validateSuperchainDeployment (t * testing.T , st * state.State , cg codeGetter , includeSuperchainImpls bool ) {
721
+ type addrTuple struct {
655
722
name string
656
723
addr common.Address
657
- }{
724
+ }
725
+ addrs := []addrTuple {
658
726
{"SuperchainProxyAdmin" , st .SuperchainDeployment .ProxyAdminAddress },
659
727
{"SuperchainConfigProxy" , st .SuperchainDeployment .SuperchainConfigProxyAddress },
660
- {"SuperchainConfigImpl" , st .SuperchainDeployment .SuperchainConfigImplAddress },
661
728
{"ProtocolVersionsProxy" , st .SuperchainDeployment .ProtocolVersionsProxyAddress },
662
- {"ProtocolVersionsImpl" , st .SuperchainDeployment .ProtocolVersionsImplAddress },
663
729
{"Opcm" , st .ImplementationsDeployment .OpcmAddress },
664
730
{"PreimageOracleSingleton" , st .ImplementationsDeployment .PreimageOracleSingletonAddress },
665
731
{"MipsSingleton" , st .ImplementationsDeployment .MipsSingletonAddress },
666
732
}
733
+
734
+ if includeSuperchainImpls {
735
+ addrs = append (addrs , addrTuple {"SuperchainConfigImpl" , st .SuperchainDeployment .SuperchainConfigImplAddress })
736
+ addrs = append (addrs , addrTuple {"ProtocolVersionsImpl" , st .SuperchainDeployment .ProtocolVersionsImplAddress })
737
+ }
738
+
667
739
for _ , addr := range addrs {
668
740
t .Run (addr .name , func (t * testing.T ) {
669
741
code := cg (t , addr .addr )
0 commit comments