@@ -50,15 +50,15 @@ type ContractAddresses struct {
50
50
func TestIntegrationUpdateSingleOperatorPath (t * testing.T ) {
51
51
52
52
/* Start the anvil chain */
53
- anvilC := startAnvilTestContainer ()
53
+ anvilC := startAnvilTestContainer (t )
54
54
// Not sure why but deferring anvilC.Terminate() causes a panic when the test finishes...
55
55
// so letting it terminate silently for now
56
56
anvilHttpEndpoint , err := anvilC .Endpoint (context .Background (), "http" )
57
57
if err != nil {
58
58
t .Fatal (err )
59
59
}
60
60
61
- contractAddresses := getContractAddressesFromContractRegistry (anvilHttpEndpoint )
61
+ contractAddresses := getContractAddressesFromContractRegistry (t , anvilHttpEndpoint )
62
62
operatorEcdsaPrivKeyHex := "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
63
63
operatorEcdsaPrivKey , err := crypto .HexToECDSA (operatorEcdsaPrivKeyHex )
64
64
if err != nil {
@@ -70,7 +70,7 @@ func TestIntegrationUpdateSingleOperatorPath(t *testing.T) {
70
70
avsSync := c .avsSync
71
71
72
72
// first register operator into avs. at this point, the operator will have whatever stake it had registered in eigenlayer in the avs
73
- registerOperatorWithAvs (c .wallet , anvilHttpEndpoint , contractAddresses , operatorEcdsaPrivKeyHex , operatorBlsPrivKey , true )
73
+ registerOperatorWithAvs (t , c .wallet , anvilHttpEndpoint , contractAddresses , operatorEcdsaPrivKeyHex , operatorBlsPrivKey , true )
74
74
75
75
// get stake of operator before sync
76
76
operatorsPerQuorumBeforeSync , err := c .avsReader .GetOperatorsStakeInQuorumsAtCurrentBlock (& bind.CallOpts {}, []types.QuorumNum {0 })
@@ -81,7 +81,7 @@ func TestIntegrationUpdateSingleOperatorPath(t *testing.T) {
81
81
82
82
// deposit into strategy to create a diff between eigenlayer and avs stakes
83
83
depositAmount := big .NewInt (100 )
84
- depositErc20IntoStrategyForOperator (c .wallet , anvilHttpEndpoint , contractAddresses .DelegationManager , contractAddresses .Erc20MockStrategy , operatorEcdsaPrivKeyHex , operatorAddr .Hex (), depositAmount , false )
84
+ depositErc20IntoStrategyForOperator (t , c .wallet , anvilHttpEndpoint , contractAddresses .DelegationManager , contractAddresses .Erc20MockStrategy , operatorEcdsaPrivKeyHex , operatorAddr .Hex (), depositAmount , false )
85
85
86
86
// run avsSync
87
87
go avsSync .Start (context .Background ())
@@ -105,11 +105,11 @@ func TestIntegrationUpdateSingleOperatorPath(t *testing.T) {
105
105
// Simulating an operator registered between the moment we read the operator set and the moment we try to update the operator set to ensure this behaves as expected
106
106
func TestIntegrationFullOperatorSetWithRaceConditionFailsToUpdate (t * testing.T ) {
107
107
/* Start the anvil chain with no mining and FIFO transaction ordering to be able to force retries */
108
- anvilC := startAnvilTestContainer ("--order" , "fifo" , "--no-mining" )
108
+ anvilC := startAnvilTestContainer (t , "--order" , "fifo" , "--no-mining" )
109
109
anvilHttpEndpoint , err := anvilC .Endpoint (context .Background (), "http" )
110
110
require .NoError (t , err )
111
111
112
- contractAddresses := getContractAddressesFromContractRegistry (anvilHttpEndpoint )
112
+ contractAddresses := getContractAddressesFromContractRegistry (t , anvilHttpEndpoint )
113
113
114
114
ethClient , err := ethclient .Dial (anvilHttpEndpoint )
115
115
require .NoError (t , err )
@@ -127,10 +127,10 @@ func TestIntegrationFullOperatorSetWithRaceConditionFailsToUpdate(t *testing.T)
127
127
operator2Wallet := createWalletForOperator (t , operator2EcdsaPrivKeyHex , ethClient )
128
128
129
129
// Register first operator
130
- registerOperatorWithAvs (c .wallet , anvilHttpEndpoint , contractAddresses , operator1EcdsaPrivKeyHex , operator1BlsPrivKey , false )
130
+ registerOperatorWithAvs (t , c .wallet , anvilHttpEndpoint , contractAddresses , operator1EcdsaPrivKeyHex , operator1BlsPrivKey , false )
131
131
132
132
// mine block
133
- advanceChainByNBlocks (1 , anvilC )
133
+ advanceChainByNBlocks (t , 1 , anvilC )
134
134
135
135
// get state pre sync
136
136
operatorsPerQuorumBeforeSync , err := c .avsSync .AvsReader .GetOperatorsStakeInQuorumsAtCurrentBlock (& bind.CallOpts {}, []types.QuorumNum {0 })
@@ -142,22 +142,22 @@ func TestIntegrationFullOperatorSetWithRaceConditionFailsToUpdate(t *testing.T)
142
142
143
143
// deposit into strategy to create a diff between eigenlayer and avs stakes
144
144
depositAmount := big .NewInt (100 )
145
- depositErc20IntoStrategyForOperator (c .wallet , anvilHttpEndpoint , contractAddresses .DelegationManager , contractAddresses .Erc20MockStrategy , operator1EcdsaPrivKeyHex , operator1Addr .Hex (), depositAmount , false )
145
+ depositErc20IntoStrategyForOperator (t , c .wallet , anvilHttpEndpoint , contractAddresses .DelegationManager , contractAddresses .Erc20MockStrategy , operator1EcdsaPrivKeyHex , operator1Addr .Hex (), depositAmount , false )
146
146
147
147
// mine block
148
- advanceChainByNBlocks (1 , anvilC )
148
+ advanceChainByNBlocks (t , 1 , anvilC )
149
149
150
150
// Register the second operator. Recall that because we are running anvil in FIFO mode
151
151
// this transaction will be included before the call to UpdateStakesOfOperatorSubsetForAllQuorums
152
- registerOperatorWithAvs (operator2Wallet , anvilHttpEndpoint , contractAddresses , operator2EcdsaPrivKeyHex , operator2BlsPrivKey , false )
152
+ registerOperatorWithAvs (t , operator2Wallet , anvilHttpEndpoint , contractAddresses , operator2EcdsaPrivKeyHex , operator2BlsPrivKey , false )
153
153
154
154
// Start the sync
155
155
ctx , cancel := context .WithTimeout (context .Background (), 10 * time .Second )
156
156
defer cancel ()
157
157
go c .avsSync .Start (ctx )
158
158
159
159
// Mine another block to include operator2's registration
160
- advanceChainByNBlocks (1 , anvilC )
160
+ advanceChainByNBlocks (t , 1 , anvilC )
161
161
162
162
// Wait for sync process to complete
163
163
time .Sleep (2 * time .Second )
@@ -207,11 +207,11 @@ func TestIntegrationFullOperatorSetWithRaceConditionFailsToUpdate(t *testing.T)
207
207
// since the contract makes sure we are updating the full operator set
208
208
func TestIntegrationFullOperatorSetWithRetry (t * testing.T ) {
209
209
/* Start the anvil chain with no mining and FIFO transaction ordering to be able to force retries */
210
- anvilC := startAnvilTestContainer ("--order" , "fifo" , "--no-mining" )
210
+ anvilC := startAnvilTestContainer (t , "--order" , "fifo" , "--no-mining" )
211
211
anvilHttpEndpoint , err := anvilC .Endpoint (context .Background (), "http" )
212
212
require .NoError (t , err )
213
213
214
- contractAddresses := getContractAddressesFromContractRegistry (anvilHttpEndpoint )
214
+ contractAddresses := getContractAddressesFromContractRegistry (t , anvilHttpEndpoint )
215
215
216
216
ethClient , err := ethclient .Dial (anvilHttpEndpoint )
217
217
require .NoError (t , err )
@@ -229,10 +229,10 @@ func TestIntegrationFullOperatorSetWithRetry(t *testing.T) {
229
229
operator2Wallet := createWalletForOperator (t , operator2EcdsaPrivKeyHex , ethClient )
230
230
231
231
// Register first operator
232
- registerOperatorWithAvs (c .wallet , anvilHttpEndpoint , contractAddresses , operator1EcdsaPrivKeyHex , operator1BlsPrivKey , false )
232
+ registerOperatorWithAvs (t , c .wallet , anvilHttpEndpoint , contractAddresses , operator1EcdsaPrivKeyHex , operator1BlsPrivKey , false )
233
233
234
234
// mine block
235
- advanceChainByNBlocks (1 , anvilC )
235
+ advanceChainByNBlocks (t , 1 , anvilC )
236
236
237
237
// get state pre sync
238
238
operatorsPerQuorumBeforeSync , err := c .avsSync .AvsReader .GetOperatorsStakeInQuorumsAtCurrentBlock (& bind.CallOpts {}, []types.QuorumNum {0 })
@@ -244,24 +244,24 @@ func TestIntegrationFullOperatorSetWithRetry(t *testing.T) {
244
244
245
245
// deposit into strategy to create a diff between eigenlayer and avs stakes
246
246
depositAmount := big .NewInt (100 )
247
- depositErc20IntoStrategyForOperator (c .wallet , anvilHttpEndpoint , contractAddresses .DelegationManager , contractAddresses .Erc20MockStrategy , operator1EcdsaPrivKeyHex , operator1Addr .Hex (), depositAmount , false )
248
- advanceChainByNBlocks (1 , anvilC )
247
+ depositErc20IntoStrategyForOperator (t , c .wallet , anvilHttpEndpoint , contractAddresses .DelegationManager , contractAddresses .Erc20MockStrategy , operator1EcdsaPrivKeyHex , operator1Addr .Hex (), depositAmount , false )
248
+ advanceChainByNBlocks (t , 1 , anvilC )
249
249
250
250
// Register the second operator. Recall that because we are running anvil in FIFO mode
251
251
// this transaction will be included before the call to UpdateStakesOfOperatorSubsetForAllQuorums
252
- registerOperatorWithAvs (operator2Wallet , anvilHttpEndpoint , contractAddresses , operator2EcdsaPrivKeyHex , operator2BlsPrivKey , false )
252
+ registerOperatorWithAvs (t , operator2Wallet , anvilHttpEndpoint , contractAddresses , operator2EcdsaPrivKeyHex , operator2BlsPrivKey , false )
253
253
254
254
// Start the sync
255
255
ctx , cancel := context .WithTimeout (context .Background (), 10 * time .Second )
256
256
defer cancel ()
257
257
go c .avsSync .Start (ctx )
258
258
259
259
// Mine another block to include operator2's registration then wait for update
260
- advanceChainByNBlocks (1 , anvilC )
260
+ advanceChainByNBlocks (t , 1 , anvilC )
261
261
time .Sleep (1 * time .Second )
262
262
263
263
// Mine Block to include update
264
- advanceChainByNBlocks (1 , anvilC )
264
+ advanceChainByNBlocks (t , 1 , anvilC )
265
265
266
266
// Wait for sync process to complete
267
267
time .Sleep (10 * time .Second )
@@ -305,15 +305,15 @@ func TestIntegrationFullOperatorSetWithRetry(t *testing.T) {
305
305
306
306
func TestIntegrationFullOperatorSet (t * testing.T ) {
307
307
/* Start the anvil chain */
308
- anvilC := startAnvilTestContainer ()
308
+ anvilC := startAnvilTestContainer (t )
309
309
// Not sure why but deferring anvilC.Terminate() causes a panic when the test finishes...
310
310
// so letting it terminate silently for now
311
311
anvilHttpEndpoint , err := anvilC .Endpoint (context .Background (), "http" )
312
312
if err != nil {
313
313
t .Fatal (err )
314
314
}
315
315
316
- contractAddresses := getContractAddressesFromContractRegistry (anvilHttpEndpoint )
316
+ contractAddresses := getContractAddressesFromContractRegistry (t , anvilHttpEndpoint )
317
317
operatorEcdsaPrivKeyHex := "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
318
318
operatorEcdsaPrivKey , err := crypto .HexToECDSA (operatorEcdsaPrivKeyHex )
319
319
if err != nil {
@@ -326,7 +326,7 @@ func TestIntegrationFullOperatorSet(t *testing.T) {
326
326
avsSync := c .avsSync
327
327
328
328
// first register operator into avs. at this point, the operator will have whatever stake it had registered in eigenlayer in the avs
329
- registerOperatorWithAvs (c .wallet , anvilHttpEndpoint , contractAddresses , operatorEcdsaPrivKeyHex , operatorBlsPrivKey , true )
329
+ registerOperatorWithAvs (t , c .wallet , anvilHttpEndpoint , contractAddresses , operatorEcdsaPrivKeyHex , operatorBlsPrivKey , true )
330
330
331
331
// get stake of operator before sync
332
332
operatorsPerQuorumBeforeSync , err := avsSync .AvsReader .GetOperatorsStakeInQuorumsAtCurrentBlock (& bind.CallOpts {}, []types.QuorumNum {0 })
@@ -338,7 +338,7 @@ func TestIntegrationFullOperatorSet(t *testing.T) {
338
338
339
339
// deposit into strategy to create a diff between eigenlayer and avs stakes
340
340
depositAmount := big .NewInt (100 )
341
- depositErc20IntoStrategyForOperator (c .wallet , anvilHttpEndpoint , contractAddresses .DelegationManager , contractAddresses .Erc20MockStrategy , operatorEcdsaPrivKeyHex , operatorAddr .Hex (), depositAmount , true )
341
+ depositErc20IntoStrategyForOperator (t , c .wallet , anvilHttpEndpoint , contractAddresses .DelegationManager , contractAddresses .Erc20MockStrategy , operatorEcdsaPrivKeyHex , operatorAddr .Hex (), depositAmount , true )
342
342
343
343
avsSync .Start (context .Background ())
344
344
@@ -432,7 +432,7 @@ func NewAvsSyncComponents(t *testing.T, anvilHttpEndpoint string, contractAddres
432
432
}
433
433
}
434
434
435
- func startAnvilTestContainer (additionalFlags ... string ) testcontainers.Container {
435
+ func startAnvilTestContainer (t * testing. T , additionalFlags ... string ) testcontainers.Container {
436
436
integrationDir , err := os .Getwd ()
437
437
require .NoError (t , err )
438
438
@@ -469,12 +469,12 @@ func startAnvilTestContainer(additionalFlags ...string) testcontainers.Container
469
469
// see comment in start-anvil-chain-with-el-and-avs-deployed.sh
470
470
// 25 is arbitrary, but I think it's enough (not sure at which block exactly deployment happened)
471
471
// this is still needed as of the latest stable anvil
472
- advanceChainByNBlocks (25 , anvilC )
472
+ advanceChainByNBlocks (t , 25 , anvilC )
473
473
474
474
return anvilC
475
475
}
476
476
477
- func advanceChainByNBlocks (n int , anvilC testcontainers.Container ) {
477
+ func advanceChainByNBlocks (t * testing. T , n int , anvilC testcontainers.Container ) {
478
478
anvilEndpoint , err := anvilC .Endpoint (context .Background (), "" )
479
479
require .NoError (t , err )
480
480
rpcUrl := "http://" + anvilEndpoint
@@ -490,7 +490,7 @@ func advanceChainByNBlocks(n int, anvilC testcontainers.Container) {
490
490
}
491
491
492
492
// TODO(samlaf): move this function to eigensdk
493
- func registerOperatorWithAvs (wallet walletsdk.Wallet , ethHttpUrl string , contractAddresses ContractAddresses , ecdsaPrivKeyHex string , blsPrivKeyHex string , waitForMine bool ) {
493
+ func registerOperatorWithAvs (t * testing. T , wallet walletsdk.Wallet , ethHttpUrl string , contractAddresses ContractAddresses , ecdsaPrivKeyHex string , blsPrivKeyHex string , waitForMine bool ) {
494
494
ethHttpClient , err := ethclient .Dial (ethHttpUrl )
495
495
require .NoError (t , err )
496
496
blsKeyPair , err := bls .NewKeyPairFromString (blsPrivKeyHex )
@@ -531,6 +531,7 @@ func registerOperatorWithAvs(wallet walletsdk.Wallet, ethHttpUrl string, contrac
531
531
532
532
// TODO(samlaf): move this function to eigensdk
533
533
func depositErc20IntoStrategyForOperator (
534
+ t * testing.T ,
534
535
wallet walletsdk.Wallet ,
535
536
ethHttpUrl string ,
536
537
delegationManagerAddr common.Address ,
@@ -566,7 +567,7 @@ func depositErc20IntoStrategyForOperator(
566
567
567
568
}
568
569
569
- func getContractAddressesFromContractRegistry (ethHttpUrl string ) ContractAddresses {
570
+ func getContractAddressesFromContractRegistry (t * testing. T , ethHttpUrl string ) ContractAddresses {
570
571
ethHttpClient , err := ethclient .Dial (ethHttpUrl )
571
572
require .NoError (t , err )
572
573
// The ContractsRegistry contract should always be deployed at this address on anvil
0 commit comments