Skip to content

Commit

Permalink
Try to make tests a bit more deterministic
Browse files Browse the repository at this point in the history
  • Loading branch information
samsondav committed Feb 22, 2024
1 parent dde08ae commit c6338be
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions core/services/ocr2/plugins/llo/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ func setupBlockchain(t *testing.T) (*bind.TransactOpts, *backends.SimulatedBacke
genesisData := core.GenesisAlloc{steve.From: {Balance: assets.Ether(1000).ToInt()}}
backend := cltest.NewSimulatedBackend(t, genesisData, uint32(ethconfig.Defaults.Miner.GasCeil))
backend.Commit() // ensure starting block number at least 1
stopMining := cltest.Mine(backend, 1*time.Second) // Should be greater than deltaRound since we cannot access old blocks on simulated blockchain
t.Cleanup(stopMining)

// Deploy contracts
verifierProxyAddr, _, _, err := verifier_proxy.DeployVerifierProxy(steve, backend, common.Address{}) // zero address for access controller disables access control
Expand Down Expand Up @@ -151,6 +149,15 @@ func TestIntegration_LLO(t *testing.T) {

configDigest := setConfig(t, steve, backend, verifierContract, verifierAddress, nodes, oracles)
channelDefinitions := setChannelDefinitions(t, steve, backend, configStoreContract, streams)

// Bury everything with finality depth
ch, err := nodes[0].App.GetRelayers().LegacyEVMChains().Get(testutils.SimulatedChainID.String())
require.NoError(t, err)
finalityDepth := ch.Config().EVM().FinalityDepth()
for i := 0; i < int(finalityDepth); i++ {
backend.Commit()
}

addBootstrapJob(t, bootstrapNode, chainID, verifierAddress, "job-1")
addOCRJobs(t, streams, serverPubKey, serverURL, verifierAddress, bootstrapPeerID, bootstrapNodePort, nodes, configStoreAddress, clientPubKeys, chainID, fromBlock)

Expand Down Expand Up @@ -292,14 +299,6 @@ func setConfig(t *testing.T, steve *bind.TransactOpts, backend *backends.Simulat

backend.Commit()

// Bury it with finality depth
ch, err := nodes[0].App.GetRelayers().LegacyEVMChains().Get(testutils.SimulatedChainID.String())
require.NoError(t, err)
finalityDepth := ch.Config().EVM().FinalityDepth()
for i := 0; i < int(finalityDepth); i++ {
backend.Commit()
}

accounts := make([]ocr2types.Account, len(offchainTransmitters))
for i := range offchainTransmitters {
accounts[i] = ocr2types.Account(fmt.Sprintf("%x", offchainTransmitters[i]))
Expand Down Expand Up @@ -365,5 +364,7 @@ func setChannelDefinitions(t *testing.T, steve *bind.TransactOpts, backend *back
channelDefinitions[channels[2]] = channel2Def
channelDefinitions[channels[3]] = channel3Def

backend.Commit()

return channelDefinitions
}

0 comments on commit c6338be

Please sign in to comment.