@@ -21,6 +21,7 @@ import (
2121 "github.com/scroll-tech/go-ethereum/log"
2222 "github.com/scroll-tech/go-ethereum/rpc"
2323 "github.com/stretchr/testify/assert"
24+ "github.com/stretchr/testify/require"
2425 "gorm.io/gorm"
2526
2627 "scroll-tech/database/migrate"
4849
4950func setupDB (t * testing.T ) * gorm.DB {
5051 dsn , err := testApps .GetDBEndPoint ()
51- assert .NoError (t , err )
52+ require .NoError (t , err )
5253
5354 cfg := & database.Config {
5455 DSN : dsn ,
@@ -57,10 +58,10 @@ func setupDB(t *testing.T) *gorm.DB {
5758 MaxIdleNum : 20 ,
5859 }
5960 db , err := database .InitDB (cfg )
60- assert .NoError (t , err )
61+ require .NoError (t , err )
6162 sqlDB , err := db .DB ()
62- assert .NoError (t , err )
63- assert .NoError (t , migrate .ResetDB (sqlDB ))
63+ require .NoError (t , err )
64+ require .NoError (t , migrate .ResetDB (sqlDB ))
6465 return db
6566}
6667
@@ -88,38 +89,38 @@ func setupEnv(t *testing.T) {
8889 )
8990
9091 testApps = tc .NewTestcontainerApps ()
91- assert .NoError (t , testApps .StartPostgresContainer ())
92- assert .NoError (t , testApps .StartL2GethContainer ())
93- assert .NoError (t , testApps .StartPoSL1Container ())
92+ require .NoError (t , testApps .StartPostgresContainer ())
93+ require .NoError (t , testApps .StartL2GethContainer ())
94+ require .NoError (t , testApps .StartPoSL1Container ())
9495 rollupApp = bcmd .NewRollupApp (testApps , "../conf/config.json" )
9596
9697 l1RawClient , err = testApps .GetPoSL1Client ()
97- assert .NoError (t , err )
98+ require .NoError (t , err )
9899 l1Client = ethclient .NewClient (l1RawClient )
99100 l2Client , err = testApps .GetL2GethClient ()
100- assert .NoError (t , err )
101+ require .NoError (t , err )
101102 l1GethChainID , err = l1Client .ChainID (context .Background ())
102- assert .NoError (t , err )
103+ require .NoError (t , err )
103104 l2GethChainID , err = l2Client .ChainID (context .Background ())
104- assert .NoError (t , err )
105+ require .NoError (t , err )
105106
106107 l1Cfg , l2Cfg := rollupApp .Config .L1Config , rollupApp .Config .L2Config
107108 l1Cfg .RelayerConfig .SenderConfig .Confirmations = 0
108109 l2Cfg .Confirmations = 0
109110 l2Cfg .RelayerConfig .SenderConfig .Confirmations = 0
110111
111112 pKey , err := crypto .ToECDSA (common .FromHex (l2Cfg .RelayerConfig .CommitSenderSignerConfig .PrivateKeySignerConfig .PrivateKey ))
112- assert .NoError (t , err )
113+ require .NoError (t , err )
113114 l1Auth , err = bind .NewKeyedTransactorWithChainID (pKey , l1GethChainID )
114- assert .NoError (t , err )
115+ require .NoError (t , err )
115116
116117 pKey , err = crypto .ToECDSA (common .FromHex (l2Cfg .RelayerConfig .GasOracleSenderSignerConfig .PrivateKeySignerConfig .PrivateKey ))
117- assert .NoError (t , err )
118+ require .NoError (t , err )
118119 l2Auth , err = bind .NewKeyedTransactorWithChainID (pKey , l2GethChainID )
119- assert .NoError (t , err )
120+ require .NoError (t , err )
120121
121122 port , err := rand .Int (rand .Reader , big .NewInt (10000 ))
122- assert .NoError (t , err )
123+ require .NoError (t , err )
123124 svrPort := strconv .FormatInt (port .Int64 ()+ 40000 , 10 )
124125 l2Cfg .RelayerConfig .ChainMonitor .BaseURL = "http://localhost:" + svrPort
125126}
@@ -144,50 +145,50 @@ func mockChainMonitorServer(baseURL string) (*http.Server, error) {
144145func prepareContracts (t * testing.T ) {
145146 // L1 ScrolChain contract
146147 nonce , err := l1Client .PendingNonceAt (context .Background (), l1Auth .From )
147- assert .NoError (t , err )
148+ require .NoError (t , err )
148149 mockL1ContractAddress := crypto .CreateAddress (l1Auth .From , nonce )
149150 tx := types .NewContractCreation (nonce , big .NewInt (0 ), 10000000 , big .NewInt (1000000000 ), common .FromHex (mock_bridge .MockBridgeMetaData .Bin ))
150151 signedTx , err := l1Auth .Signer (l1Auth .From , tx )
151- assert .NoError (t , err )
152+ require .NoError (t , err )
152153 err = l1Client .SendTransaction (context .Background (), signedTx )
153- assert .NoError (t , err )
154+ require .NoError (t , err )
154155
155- assert .Eventually (t , func () bool {
156+ require .Eventually (t , func () bool {
156157 _ , isPending , getErr := l1Client .TransactionByHash (context .Background (), signedTx .Hash ())
157158 return getErr == nil && ! isPending
158159 }, 30 * time .Second , time .Second )
159160
160- assert .Eventually (t , func () bool {
161+ require .Eventually (t , func () bool {
161162 receipt , getErr := l1Client .TransactionReceipt (context .Background (), signedTx .Hash ())
162163 return getErr == nil && receipt .Status == gethTypes .ReceiptStatusSuccessful
163164 }, 30 * time .Second , time .Second )
164165
165- assert .Eventually (t , func () bool {
166+ require .Eventually (t , func () bool {
166167 code , getErr := l1Client .CodeAt (context .Background (), mockL1ContractAddress , nil )
167168 return getErr == nil && len (code ) > 0
168169 }, 30 * time .Second , time .Second )
169170
170171 // L2 ScrolChain contract
171172 nonce , err = l2Client .PendingNonceAt (context .Background (), l2Auth .From )
172- assert .NoError (t , err )
173+ require .NoError (t , err )
173174 mockL2ContractAddress := crypto .CreateAddress (l2Auth .From , nonce )
174175 tx = types .NewContractCreation (nonce , big .NewInt (0 ), 2000000 , big .NewInt (1000000000 ), common .FromHex (mock_bridge .MockBridgeMetaData .Bin ))
175176 signedTx , err = l2Auth .Signer (l2Auth .From , tx )
176- assert .NoError (t , err )
177+ require .NoError (t , err )
177178 err = l2Client .SendTransaction (context .Background (), signedTx )
178- assert .NoError (t , err )
179+ require .NoError (t , err )
179180
180- assert .Eventually (t , func () bool {
181+ require .Eventually (t , func () bool {
181182 _ , isPending , err := l2Client .TransactionByHash (context .Background (), signedTx .Hash ())
182183 return err == nil && ! isPending
183184 }, 30 * time .Second , time .Second )
184185
185- assert .Eventually (t , func () bool {
186+ require .Eventually (t , func () bool {
186187 receipt , err := l2Client .TransactionReceipt (context .Background (), signedTx .Hash ())
187188 return err == nil && receipt .Status == gethTypes .ReceiptStatusSuccessful
188189 }, 30 * time .Second , time .Second )
189190
190- assert .Eventually (t , func () bool {
191+ require .Eventually (t , func () bool {
191192 code , err := l2Client .CodeAt (context .Background (), mockL2ContractAddress , nil )
192193 return err == nil && len (code ) > 0
193194 }, 30 * time .Second , time .Second )
0 commit comments