@@ -61,7 +61,7 @@ func TestIntegrationUpdateSingleOperatorPath(t *testing.T) {
61
61
}
62
62
operatorAddr := crypto .PubkeyToAddress (operatorEcdsaPrivKey .PublicKey )
63
63
operatorBlsPrivKey := "0x1"
64
- avsSync := NewTestAvsSync (anvilHttpEndpoint , contractAddresses , []common.Address {operatorAddr })
64
+ avsSync := NewTestAvsSync (anvilHttpEndpoint , contractAddresses , []common.Address {operatorAddr }, 30 * time . Second )
65
65
66
66
// first register operator into avs. at this point, the operator will have whatever stake it had registered in eigenlayer in the avs
67
67
registerOperatorWithAvs (anvilHttpEndpoint , contractAddresses , operatorEcdsaPrivKeyHex , operatorBlsPrivKey )
@@ -117,7 +117,7 @@ func TestIntegrationFullOperatorSet(t *testing.T) {
117
117
}
118
118
operatorAddr := crypto .PubkeyToAddress (operatorEcdsaPrivKey .PublicKey )
119
119
operatorBlsPrivKey := "0x1"
120
- avsSync := NewTestAvsSync (anvilHttpEndpoint , contractAddresses , []common.Address {})
120
+ avsSync := NewTestAvsSync (anvilHttpEndpoint , contractAddresses , []common.Address {}, 30 * time . Second )
121
121
122
122
// first register operator into avs. at this point, the operator will have whatever stake it had registered in eigenlayer in the avs
123
123
registerOperatorWithAvs (anvilHttpEndpoint , contractAddresses , operatorEcdsaPrivKeyHex , operatorBlsPrivKey )
@@ -179,7 +179,7 @@ func TestIntegrationFullOperatorSetWithRetry(t *testing.T) {
179
179
180
180
// we create avs sync and replace its avsWriter with a mock that will fail the first 2 times we call UpdateStakesOfEntireOperatorSetForQuorums
181
181
// and succeed on the third time
182
- avsSync := NewTestAvsSync (anvilHttpEndpoint , contractAddresses , []common.Address {})
182
+ avsSync := NewTestAvsSync (anvilHttpEndpoint , contractAddresses , []common.Address {}, 30 * time . Second )
183
183
mockCtrl := gomock .NewController (t )
184
184
mockAvsRegistryWriter := chainiomocks .NewMockAvsRegistryWriter (mockCtrl )
185
185
// this is the test. we just make sure this is called 3 times
@@ -194,7 +194,59 @@ func TestIntegrationFullOperatorSetWithRetry(t *testing.T) {
194
194
195
195
}
196
196
197
- func NewTestAvsSync (anvilHttpEndpoint string , contractAddresses ContractAddresses , operators []common.Address ) * AvsSync {
197
+ func TestSingleRun (t * testing.T ) {
198
+ /* Start the anvil chain */
199
+ anvilC := startAnvilTestContainer ()
200
+ // Not sure why but deferring anvilC.Terminate() causes a panic when the test finishes...
201
+ // so letting it terminate silently for now
202
+ anvilHttpEndpoint , err := anvilC .Endpoint (context .Background (), "http" )
203
+ if err != nil {
204
+ t .Fatal (err )
205
+ }
206
+
207
+ contractAddresses := getContractAddressesFromContractRegistry (anvilHttpEndpoint )
208
+ operatorEcdsaPrivKeyHex := "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
209
+ operatorEcdsaPrivKey , err := crypto .HexToECDSA (operatorEcdsaPrivKeyHex )
210
+ if err != nil {
211
+ t .Fatal (err )
212
+ }
213
+ operatorAddr := crypto .PubkeyToAddress (operatorEcdsaPrivKey .PublicKey )
214
+ operatorBlsPrivKey := "0x1"
215
+ // set sync interval to 0 so that we only run once
216
+ avsSync := NewTestAvsSync (anvilHttpEndpoint , contractAddresses , []common.Address {}, 0 )
217
+
218
+ // first register operator into avs. at this point, the operator will have whatever stake it had registered in eigenlayer in the avs
219
+ registerOperatorWithAvs (anvilHttpEndpoint , contractAddresses , operatorEcdsaPrivKeyHex , operatorBlsPrivKey )
220
+
221
+ // get stake of operator before sync
222
+ operatorsPerQuorumBeforeSync , err := avsSync .avsReader .GetOperatorsStakeInQuorumsAtCurrentBlock (& bind.CallOpts {}, []byte {0 })
223
+ if err != nil {
224
+ t .Fatal (err )
225
+ }
226
+ // TODO: should be checking all operators, not just the first one
227
+ operatorStakeBeforeSync := operatorsPerQuorumBeforeSync [0 ][0 ].Stake
228
+
229
+ // deposit into strategy to create a diff between eigenlayer and avs stakes
230
+ depositAmount := big .NewInt (100 )
231
+ depositErc20IntoStrategyForOperator (anvilHttpEndpoint , contractAddresses .DelegationManager , contractAddresses .Erc20MockStrategy , operatorEcdsaPrivKeyHex , operatorAddr .Hex (), depositAmount )
232
+
233
+ avsSync .Start ()
234
+
235
+ // get stake of operator after sync
236
+ operatorsPerQuorumAfterSync , err := avsSync .avsReader .GetOperatorsStakeInQuorumsAtCurrentBlock (& bind.CallOpts {}, []byte {0 })
237
+ if err != nil {
238
+ t .Fatal (err )
239
+ }
240
+ operatorStakeAfterSync := operatorsPerQuorumAfterSync [0 ][0 ].Stake
241
+ operatorStakeDiff := new (big.Int ).Sub (operatorStakeAfterSync , operatorStakeBeforeSync )
242
+
243
+ // we just check that the diff is equal to the deposited amount
244
+ if operatorStakeDiff .Cmp (depositAmount ) != 0 {
245
+ t .Errorf ("expected operator stake diff to be equal to deposit amount, got %v" , operatorStakeDiff )
246
+ }
247
+ }
248
+
249
+ func NewTestAvsSync (anvilHttpEndpoint string , contractAddresses ContractAddresses , operators []common.Address , syncInterval time.Duration ) * AvsSync {
198
250
logger , err := logging .NewZapLogger (logging .Development )
199
251
if err != nil {
200
252
panic (err )
@@ -252,7 +304,7 @@ func NewTestAvsSync(anvilHttpEndpoint string, contractAddresses ContractAddresse
252
304
avsReader ,
253
305
avsWriter ,
254
306
0 * time .Second ,
255
- 30 * time . Second ,
307
+ syncInterval ,
256
308
operators ,
257
309
// we only test with one quorum
258
310
[]byte {0 },
0 commit comments