From 54334421b806f4fadc698c3149e3cf8678719591 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Thu, 12 Dec 2024 15:25:35 +0100 Subject: [PATCH 01/21] integrate new contracts for the aggoracle (wip) --- aggoracle/chaingersender/evm.go | 15 +++++----- aggoracle/e2e_test.go | 6 ++-- go.mod | 2 +- go.sum | 2 ++ lastgersync/evmdownloader.go | 6 ++-- test/helpers/e2e.go | 51 +++++++++++++++++---------------- test/helpers/simulated.go | 19 ++++++------ 7 files changed, 53 insertions(+), 48 deletions(-) diff --git a/aggoracle/chaingersender/evm.go b/aggoracle/chaingersender/evm.go index 30f12c9c..c004208d 100644 --- a/aggoracle/chaingersender/evm.go +++ b/aggoracle/chaingersender/evm.go @@ -6,7 +6,7 @@ import ( "math/big" "time" - "github.com/0xPolygon/cdk-contracts-tooling/contracts/manual/pessimisticglobalexitroot" + "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain-paris/polygonzkevmglobalexitrootv2" cfgTypes "github.com/0xPolygon/cdk/config/types" "github.com/0xPolygon/cdk/log" "github.com/0xPolygon/zkevm-ethtx-manager/ethtxmanager" @@ -41,7 +41,7 @@ type EthTxManager interface { type EVMChainGERSender struct { logger *log.Logger - gerContract *pessimisticglobalexitroot.Pessimisticglobalexitroot + gerContract *polygonzkevmglobalexitrootv2.Polygonzkevmglobalexitrootv2 gerAddr common.Address client EthClienter ethTxMan EthTxManager @@ -66,7 +66,7 @@ func NewEVMChainGERSender( gasOffset uint64, waitPeriodMonitorTx time.Duration, ) (*EVMChainGERSender, error) { - gerContract, err := pessimisticglobalexitroot.NewPessimisticglobalexitroot(l2GlobalExitRoot, l2Client) + gerContract, err := polygonzkevmglobalexitrootv2.NewPolygonzkevmglobalexitrootv2(l2GlobalExitRoot, l2Client) if err != nil { return nil, err } @@ -83,24 +83,25 @@ func NewEVMChainGERSender( } func (c *EVMChainGERSender) IsGERInjected(ger common.Hash) (bool, error) { - timestamp, err := c.gerContract.GlobalExitRootMap(&bind.CallOpts{Pending: false}, ger) + blockHashBigInt, err := c.gerContract.GlobalExitRootMap(&bind.CallOpts{Pending: false}, ger) if err != nil { return false, fmt.Errorf("error calling gerContract.GlobalExitRootMap: %w", err) } - return timestamp.Cmp(common.Big0) != 0, nil + return common.BigToHash(blockHashBigInt) != common.Hash{}, nil } func (c *EVMChainGERSender) InjectGER(ctx context.Context, ger common.Hash) error { ticker := time.NewTicker(c.waitPeriodMonitorTx) defer ticker.Stop() - gerABI, err := pessimisticglobalexitroot.PessimisticglobalexitrootMetaData.GetAbi() + gerABI, err := polygonzkevmglobalexitrootv2.Polygonzkevmglobalexitrootv2MetaData.GetAbi() if err != nil { return err } - updateGERTxInput, err := gerABI.Pack("updateGlobalExitRoot", ger) + // TODO: @Stefan-Ethernal should we invoke the PolygonZkEVMBridgeV2.updateGlobalExitRoot? + updateGERTxInput, err := gerABI.Pack("updateExitRoot", ger) if err != nil { return err } diff --git a/aggoracle/e2e_test.go b/aggoracle/e2e_test.go index 090bd57c..c5cd3c8a 100644 --- a/aggoracle/e2e_test.go +++ b/aggoracle/e2e_test.go @@ -6,7 +6,7 @@ import ( "testing" "time" - gerContractL1 "github.com/0xPolygon/cdk-contracts-tooling/contracts/manual/globalexitrootnopush0" + gerContractL1 "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain-paris/polygonzkevmglobalexitrootv2" "github.com/0xPolygon/cdk/aggoracle" "github.com/0xPolygon/cdk/test/helpers" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -22,7 +22,7 @@ func TestEVM(t *testing.T) { func runTest( t *testing.T, - gerL1Contract *gerContractL1.Globalexitrootnopush0, + gerL1Contract *gerContractL1.Polygonzkevmglobalexitrootv2, sender aggoracle.ChainSender, l1Client *simulated.Backend, authL1 *bind.TransactOpts, @@ -30,6 +30,8 @@ func runTest( t.Helper() for i := 0; i < 10; i++ { + // TODO: @Stefan-Ethernal this should be invoked either from rollup manager or bridge + // https://github.com/0xPolygonHermez/zkevm-contracts/blob/2b279bbe712e3d396dcafad4be63b663dd647476/contracts/v2/PolygonZkEVMGlobalExitRootV2.sol#L85-L95 _, err := gerL1Contract.UpdateExitRoot(authL1, common.HexToHash(strconv.Itoa(i))) require.NoError(t, err) l1Client.Commit() diff --git a/go.mod b/go.mod index 9878328a..8a72eb7b 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/0xPolygon/cdk go 1.22.4 require ( - github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20240826154954-f6182d2b17a2 + github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20241211191239-915ad3f37c3b github.com/0xPolygon/cdk-data-availability v0.0.11 github.com/0xPolygon/cdk-rpc v0.0.0-20241004114257-6c3cb6eebfb6 github.com/0xPolygon/zkevm-ethtx-manager v0.2.1 diff --git a/go.sum b/go.sum index 249a34c8..2f0103dd 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,7 @@ github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20240826154954-f6182d2b17a2 h1:N5qvWG4amhUt6d1F4Kf8AdJZs4z7/xZfE3v/Im2afNM= github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20240826154954-f6182d2b17a2/go.mod h1:mFlcEjsm2YBBsu8atHJ3zyVnwM+Z/fMXpVmIJge+WVU= +github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20241211191239-915ad3f37c3b h1:IvCbb1Pl6W0Ty7GFyq71O0KGOtSg82nqn5zi6UVGivk= +github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20241211191239-915ad3f37c3b/go.mod h1:mFlcEjsm2YBBsu8atHJ3zyVnwM+Z/fMXpVmIJge+WVU= github.com/0xPolygon/cdk-data-availability v0.0.10 h1:pVcke2I7GuPH7JeRLKokEOHffPMwEHmJd9yDXHqh9B4= github.com/0xPolygon/cdk-data-availability v0.0.10/go.mod h1:nn5RmnkzOiugAxizSbaYnA+em79YLLLoR25i0UlKc5Q= github.com/0xPolygon/cdk-data-availability v0.0.11 h1:enmlyFYCvmDmcX/2fnDjWnn3svqqm9o2Fe+Kupoykdo= diff --git a/lastgersync/evmdownloader.go b/lastgersync/evmdownloader.go index bf9a236f..7a695faa 100644 --- a/lastgersync/evmdownloader.go +++ b/lastgersync/evmdownloader.go @@ -7,7 +7,7 @@ import ( "math/big" "time" - "github.com/0xPolygon/cdk-contracts-tooling/contracts/manual/pessimisticglobalexitroot" + "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain-paris/polygonzkevmglobalexitrootv2" "github.com/0xPolygon/cdk/db" "github.com/0xPolygon/cdk/l1infotreesync" "github.com/0xPolygon/cdk/log" @@ -27,7 +27,7 @@ type EthClienter interface { type downloader struct { *sync.EVMDownloaderImplementation l2Client EthClienter - gerContract *pessimisticglobalexitroot.Pessimisticglobalexitroot + gerContract *polygonzkevmglobalexitrootv2.Polygonzkevmglobalexitrootv2 l1InfoTreesync *l1infotreesync.L1InfoTreeSync processor *processor rh *sync.RetryHandler @@ -42,7 +42,7 @@ func newDownloader( blockFinality *big.Int, waitForNewBlocksPeriod time.Duration, ) (*downloader, error) { - gerContract, err := pessimisticglobalexitroot.NewPessimisticglobalexitroot(globalExitRootL2, l2Client) + gerContract, err := polygonzkevmglobalexitrootv2.NewPolygonzkevmglobalexitrootv2(globalExitRootL2, l2Client) if err != nil { return nil, err } diff --git a/test/helpers/e2e.go b/test/helpers/e2e.go index 6b3b0c86..d77b6e26 100644 --- a/test/helpers/e2e.go +++ b/test/helpers/e2e.go @@ -6,9 +6,8 @@ import ( "testing" "time" - "github.com/0xPolygon/cdk-contracts-tooling/contracts/elderberry-paris/polygonzkevmbridgev2" - gerContractL1 "github.com/0xPolygon/cdk-contracts-tooling/contracts/manual/globalexitrootnopush0" - gerContractEVMChain "github.com/0xPolygon/cdk-contracts-tooling/contracts/manual/pessimisticglobalexitrootnopush0" + "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain-paris/polygonzkevmbridgev2" + "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain-paris/polygonzkevmglobalexitrootv2" "github.com/0xPolygon/cdk/aggoracle" "github.com/0xPolygon/cdk/aggoracle/chaingersender" "github.com/0xPolygon/cdk/bridgesync" @@ -24,7 +23,7 @@ import ( ) const ( - NetworkIDL2 = uint32(1) + rollupID = uint32(1) syncBlockChunkSize = 10 retries = 3 periodRetry = time.Millisecond * 100 @@ -34,9 +33,9 @@ type AggoracleWithEVMChainEnv struct { L1Client *simulated.Backend L2Client *simulated.Backend L1InfoTreeSync *l1infotreesync.L1InfoTreeSync - GERL1Contract *gerContractL1.Globalexitrootnopush0 + GERL1Contract *polygonzkevmglobalexitrootv2.Polygonzkevmglobalexitrootv2 GERL1Addr common.Address - GERL2Contract *gerContractEVMChain.Pessimisticglobalexitrootnopush0 + GERL2Contract *polygonzkevmglobalexitrootv2.Polygonzkevmglobalexitrootv2 GERL2Addr common.Address AuthL1 *bind.TransactOpts AuthL2 *bind.TransactOpts @@ -101,7 +100,7 @@ func NewE2EEnvWithEVML2(t *testing.T) *AggoracleWithEVMChainEnv { BridgeL2Addr: bridgeL2Addr, BridgeL2Sync: bridgeL2Sync, - NetworkIDL2: NetworkIDL2, + NetworkIDL2: rollupID, EthTxManMockL2: ethTxManMockL2, } } @@ -109,7 +108,7 @@ func NewE2EEnvWithEVML2(t *testing.T) *AggoracleWithEVMChainEnv { func CommonSetup(t *testing.T) ( *simulated.Backend, *l1infotreesync.L1InfoTreeSync, - *gerContractL1.Globalexitrootnopush0, + *polygonzkevmglobalexitrootv2.Polygonzkevmglobalexitrootv2, common.Address, *polygonzkevmbridgev2.Polygonzkevmbridgev2, common.Address, @@ -172,7 +171,7 @@ func CommonSetup(t *testing.T) ( func L2SetupEVM(t *testing.T) ( aggoracle.ChainSender, *simulated.Backend, - *gerContractEVMChain.Pessimisticglobalexitrootnopush0, + *polygonzkevmglobalexitrootv2.Polygonzkevmglobalexitrootv2, common.Address, *polygonzkevmbridgev2.Polygonzkevmbridgev2, common.Address, @@ -227,7 +226,7 @@ func newSimulatedL1(t *testing.T) ( *simulated.Backend, *bind.TransactOpts, common.Address, - *gerContractL1.Globalexitrootnopush0, + *polygonzkevmglobalexitrootv2.Polygonzkevmglobalexitrootv2, common.Address, *polygonzkevmbridgev2.Polygonzkevmbridgev2, ) { @@ -237,7 +236,8 @@ func newSimulatedL1(t *testing.T) ( precalculatedAddr := crypto.CreateAddress(setup.DeployerAuth.From, 2) //nolint:mnd - gerAddr, _, gerContract, err := gerContractL1.DeployGlobalexitrootnopush0(setup.DeployerAuth, client.Client(), + gerAddr, _, gerContract, err := polygonzkevmglobalexitrootv2.DeployPolygonzkevmglobalexitrootv2( + setup.DeployerAuth, client.Client(), setup.UserAuth.From, setup.BridgeProxyAddr) require.NoError(t, err) client.Commit() @@ -251,30 +251,31 @@ func newSimulatedEVMAggSovereignChain(t *testing.T) ( *simulated.Backend, *bind.TransactOpts, common.Address, - *gerContractEVMChain.Pessimisticglobalexitrootnopush0, + *polygonzkevmglobalexitrootv2.Polygonzkevmglobalexitrootv2, common.Address, *polygonzkevmbridgev2.Polygonzkevmbridgev2, ) { t.Helper() - client, setup := SimulatedBackend(t, nil, NetworkIDL2) + client, setup := SimulatedBackend(t, nil, rollupID) - precalculatedAddr := crypto.CreateAddress(setup.DeployerAuth.From, 2) //nolint:mnd - - gerAddr, _, gerContract, err := gerContractEVMChain.DeployPessimisticglobalexitrootnopush0( - setup.DeployerAuth, client.Client(), setup.UserAuth.From, - ) + // TODO: @Stefan-Ethernal deploy the GlobalExitRootManagerL2SovereignChain here instead? + // https://github.com/0xPolygonHermez/zkevm-contracts/blob/feature/audit-remediations/contracts/v2/sovereignChains/GlobalExitRootManagerL2SovereignChain.sol + gerAddr, _, gerContract, err := polygonzkevmglobalexitrootv2.DeployPolygonzkevmglobalexitrootv2( + setup.DeployerAuth, client.Client(), setup.UserAuth.From, setup.BridgeProxyAddr) require.NoError(t, err) client.Commit() - globalExitRootSetterRole := common.HexToHash("0x7b95520991dfda409891be0afa2635b63540f92ee996fda0bf695a166e5c5176") - _, err = gerContract.GrantRole(setup.DeployerAuth, globalExitRootSetterRole, setup.UserAuth.From) - require.NoError(t, err) - client.Commit() + // TODO: @Stefan-Ethernal Remove? + // globalExitRootSetterRole := common.HexToHash("0x7b95520991dfda409891be0afa2635b63540f92ee996fda0bf695a166e5c5176") + // _, err = gerContract.GrantRole(setup.DeployerAuth, globalExitRootSetterRole, setup.UserAuth.From) + // require.NoError(t, err) + // client.Commit() - hasRole, _ := gerContract.HasRole(&bind.CallOpts{Pending: false}, globalExitRootSetterRole, setup.UserAuth.From) - require.True(t, hasRole) - require.Equal(t, precalculatedAddr, gerAddr) + // precalculatedAddr := crypto.CreateAddress(setup.DeployerAuth.From, 2) //nolint:mnd + // hasRole, _ := gerContract.HasRole(&bind.CallOpts{Pending: false}, globalExitRootSetterRole, setup.UserAuth.From) + // require.True(t, hasRole) + // require.Equal(t, precalculatedAddr, gerAddr) return client, setup.UserAuth, gerAddr, gerContract, setup.BridgeProxyAddr, setup.BridgeProxyContract } diff --git a/test/helpers/simulated.go b/test/helpers/simulated.go index 08f01394..31d609d1 100644 --- a/test/helpers/simulated.go +++ b/test/helpers/simulated.go @@ -4,7 +4,7 @@ import ( "math/big" "testing" - "github.com/0xPolygon/cdk-contracts-tooling/contracts/elderberry-paris/polygonzkevmbridgev2" + "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain-paris/polygonzkevmbridgev2" "github.com/0xPolygon/cdk/test/contracts/transparentupgradableproxy" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" @@ -35,8 +35,6 @@ func (tc TestClient) Client() *rpc.Client { type SimulatedBackendSetup struct { UserAuth *bind.TransactOpts DeployerAuth *bind.TransactOpts - BridgeAddr common.Address - BridgeContract *polygonzkevmbridgev2.Polygonzkevmbridgev2 BridgeProxyAddr common.Address BridgeProxyContract *polygonzkevmbridgev2.Polygonzkevmbridgev2 } @@ -45,7 +43,7 @@ type SimulatedBackendSetup struct { func SimulatedBackend( t *testing.T, balances map[common.Address]types.Account, - ebZkevmBridgeNetwork uint32, + rollupID uint32, ) (*simulated.Backend, *SimulatedBackendSetup) { t.Helper() @@ -81,13 +79,16 @@ func SimulatedBackend( // MUST BE DEPLOYED FIRST // Deploy zkevm bridge contract - bridgeAddr, _, bridgeContract, err := polygonzkevmbridgev2.DeployPolygonzkevmbridgev2(deployerAuth, client.Client()) + bridgeAddr, _, _, err := polygonzkevmbridgev2.DeployPolygonzkevmbridgev2(deployerAuth, client.Client()) require.NoError(t, err) client.Commit() // Create proxy contract for the bridge - var bridgeProxyAddr common.Address - var bridgeProxyContract *polygonzkevmbridgev2.Polygonzkevmbridgev2 + var ( + bridgeProxyAddr common.Address + bridgeProxyContract *polygonzkevmbridgev2.Polygonzkevmbridgev2 + ) + { precalculatedAddr := crypto.CreateAddress(deployerAuth.From, 2) //nolint:mnd @@ -96,7 +97,7 @@ func SimulatedBackend( require.NotNil(t, bridgeABI) dataCallProxy, err := bridgeABI.Pack("initialize", - ebZkevmBridgeNetwork, + rollupID, common.Address{}, // gasTokenAddressMainnet uint32(0), // gasTokenNetworkMainnet precalculatedAddr, @@ -127,8 +128,6 @@ func SimulatedBackend( return client, &SimulatedBackendSetup{ UserAuth: userAuth, DeployerAuth: deployerAuth, - BridgeAddr: bridgeAddr, - BridgeContract: bridgeContract, BridgeProxyAddr: bridgeProxyAddr, BridgeProxyContract: bridgeProxyContract, } From 0ef8ba1aa009572923348ebff918f8098b1d57fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Tue, 17 Dec 2024 10:41:40 +0100 Subject: [PATCH 02/21] feat: integrate the GlobalExitRootManager L2 sovereign chain --- aggoracle/chaingersender/evm.go | 70 ++++++++++++++++++--------------- aggoracle/oracle.go | 8 ++-- common/common.go | 4 ++ go.mod | 2 +- go.sum | 6 +-- lastgersync/evmdownloader.go | 39 +++++++++--------- sync/evmdownloader.go | 2 +- 7 files changed, 70 insertions(+), 61 deletions(-) diff --git a/aggoracle/chaingersender/evm.go b/aggoracle/chaingersender/evm.go index c004208d..5af3e443 100644 --- a/aggoracle/chaingersender/evm.go +++ b/aggoracle/chaingersender/evm.go @@ -6,17 +6,21 @@ import ( "math/big" "time" - "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain-paris/polygonzkevmglobalexitrootv2" - cfgTypes "github.com/0xPolygon/cdk/config/types" + "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain-paris/globalexitrootmanagerl2sovereignchain" + cdkcommon "github.com/0xPolygon/cdk/common" + cfgtypes "github.com/0xPolygon/cdk/config/types" "github.com/0xPolygon/cdk/log" "github.com/0xPolygon/zkevm-ethtx-manager/ethtxmanager" ethtxtypes "github.com/0xPolygon/zkevm-ethtx-manager/types" "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" ) +const insertGERFuncName = "insertGlobalExitRoot" + type EthClienter interface { ethereum.LogFilterer ethereum.BlockNumberReader @@ -39,43 +43,51 @@ type EthTxManager interface { ) (common.Hash, error) } -type EVMChainGERSender struct { - logger *log.Logger - gerContract *polygonzkevmglobalexitrootv2.Polygonzkevmglobalexitrootv2 - gerAddr common.Address - client EthClienter - ethTxMan EthTxManager - gasOffset uint64 - waitPeriodMonitorTx time.Duration -} - type EVMConfig struct { GlobalExitRootL2Addr common.Address `mapstructure:"GlobalExitRootL2"` URLRPCL2 string `mapstructure:"URLRPCL2"` ChainIDL2 uint64 `mapstructure:"ChainIDL2"` GasOffset uint64 `mapstructure:"GasOffset"` - WaitPeriodMonitorTx cfgTypes.Duration `mapstructure:"WaitPeriodMonitorTx"` + WaitPeriodMonitorTx cfgtypes.Duration `mapstructure:"WaitPeriodMonitorTx"` EthTxManager ethtxmanager.Config `mapstructure:"EthTxManager"` } +type EVMChainGERSender struct { + logger *log.Logger + + l2GERManager *globalexitrootmanagerl2sovereignchain.Globalexitrootmanagerl2sovereignchain + l2GERManagerAddr common.Address + l2GERManagerAbi *abi.ABI + + ethTxMan EthTxManager + gasOffset uint64 + waitPeriodMonitorTx time.Duration +} + func NewEVMChainGERSender( logger *log.Logger, - l2GlobalExitRoot common.Address, + l2GERManagerAddr common.Address, l2Client EthClienter, ethTxMan EthTxManager, gasOffset uint64, waitPeriodMonitorTx time.Duration, ) (*EVMChainGERSender, error) { - gerContract, err := polygonzkevmglobalexitrootv2.NewPolygonzkevmglobalexitrootv2(l2GlobalExitRoot, l2Client) + l2GERManager, err := globalexitrootmanagerl2sovereignchain.NewGlobalexitrootmanagerl2sovereignchain( + l2GERManagerAddr, l2Client) + if err != nil { + return nil, err + } + + l2GERAbi, err := globalexitrootmanagerl2sovereignchain.Globalexitrootmanagerl2sovereignchainMetaData.GetAbi() if err != nil { return nil, err } return &EVMChainGERSender{ logger: logger, - gerContract: gerContract, - gerAddr: l2GlobalExitRoot, - client: l2Client, + l2GERManager: l2GERManager, + l2GERManagerAddr: l2GERManagerAddr, + l2GERManagerAbi: l2GERAbi, ethTxMan: ethTxMan, gasOffset: gasOffset, waitPeriodMonitorTx: waitPeriodMonitorTx, @@ -83,40 +95,36 @@ func NewEVMChainGERSender( } func (c *EVMChainGERSender) IsGERInjected(ger common.Hash) (bool, error) { - blockHashBigInt, err := c.gerContract.GlobalExitRootMap(&bind.CallOpts{Pending: false}, ger) + blockHashBigInt, err := c.l2GERManager.GlobalExitRootMap(&bind.CallOpts{Pending: false}, ger) if err != nil { - return false, fmt.Errorf("error calling gerContract.GlobalExitRootMap: %w", err) + return false, fmt.Errorf("failed to check if global exit root is injected %s: %w", ger, err) } - return common.BigToHash(blockHashBigInt) != common.Hash{}, nil + return common.BigToHash(blockHashBigInt) != cdkcommon.ZeroHash, nil } func (c *EVMChainGERSender) InjectGER(ctx context.Context, ger common.Hash) error { ticker := time.NewTicker(c.waitPeriodMonitorTx) defer ticker.Stop() - gerABI, err := polygonzkevmglobalexitrootv2.Polygonzkevmglobalexitrootv2MetaData.GetAbi() + updateGERTxInput, err := c.l2GERManagerAbi.Pack(insertGERFuncName, ger) if err != nil { return err } - // TODO: @Stefan-Ethernal should we invoke the PolygonZkEVMBridgeV2.updateGlobalExitRoot? - updateGERTxInput, err := gerABI.Pack("updateExitRoot", ger) + id, err := c.ethTxMan.Add(ctx, &c.l2GERManagerAddr, common.Big0, updateGERTxInput, c.gasOffset, nil) if err != nil { return err } - id, err := c.ethTxMan.Add(ctx, &c.gerAddr, big.NewInt(0), updateGERTxInput, c.gasOffset, nil) - if err != nil { - return err - } for { <-ticker.C c.logger.Debugf("waiting for tx %s to be mined", id.Hex()) res, err := c.ethTxMan.Result(ctx, id) if err != nil { - c.logger.Error("error calling ethTxMan.Result: ", err) + c.logger.Errorf("failed to check the transaction %s status: %s", id.Hex(), err) + continue } switch res.Status { @@ -124,13 +132,13 @@ func (c *EVMChainGERSender) InjectGER(ctx context.Context, ger common.Hash) erro ethtxtypes.MonitoredTxStatusSent: continue case ethtxtypes.MonitoredTxStatusFailed: - return fmt.Errorf("tx %s failed", res.ID) + return fmt.Errorf("tx %s failed", id.Hex()) case ethtxtypes.MonitoredTxStatusMined, ethtxtypes.MonitoredTxStatusSafe, ethtxtypes.MonitoredTxStatusFinalized: return nil default: - c.logger.Error("unexpected tx status: ", res.Status) + c.logger.Error("unexpected tx status:", res.Status) } } } diff --git a/aggoracle/oracle.go b/aggoracle/oracle.go index 82378f30..88ee56ce 100644 --- a/aggoracle/oracle.go +++ b/aggoracle/oracle.go @@ -68,6 +68,7 @@ func (a *AggOracle) Start(ctx context.Context) { if err := a.processLatestGER(ctx, &blockNumToFetch); err != nil { a.handleGERProcessingError(err, blockNumToFetch) } + case <-ctx.Done(): return } @@ -85,12 +86,13 @@ func (a *AggOracle) processLatestGER(ctx context.Context, blockNumToFetch *uint6 // Update the block number for the next iteration *blockNumToFetch = blockNum - alreadyInjected, err := a.chainSender.IsGERInjected(gerToInject) + isGERInjected, err := a.chainSender.IsGERInjected(gerToInject) if err != nil { return fmt.Errorf("error checking if GER is already injected: %w", err) } - if alreadyInjected { - a.logger.Debugf("GER %s already injected", gerToInject.Hex()) + + if isGERInjected { + a.logger.Debugf("GER %s is already injected", gerToInject.Hex()) return nil } diff --git a/common/common.go b/common/common.go index 15206902..2fe71dce 100644 --- a/common/common.go +++ b/common/common.go @@ -14,6 +14,10 @@ import ( "github.com/iden3/go-iden3-crypto/keccak256" ) +var ( + ZeroHash = common.HexToHash("0x0") +) + // Uint64ToBytes converts a uint64 to a byte slice func Uint64ToBytes(num uint64) []byte { const uint64ByteSize = 8 diff --git a/go.mod b/go.mod index 8a72eb7b..2444cba6 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/0xPolygon/cdk go 1.22.4 require ( - github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20241211191239-915ad3f37c3b + github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20241217070745-faeedeaaea77 github.com/0xPolygon/cdk-data-availability v0.0.11 github.com/0xPolygon/cdk-rpc v0.0.0-20241004114257-6c3cb6eebfb6 github.com/0xPolygon/zkevm-ethtx-manager v0.2.1 diff --git a/go.sum b/go.sum index 2f0103dd..69b3f541 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,5 @@ -github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20240826154954-f6182d2b17a2 h1:N5qvWG4amhUt6d1F4Kf8AdJZs4z7/xZfE3v/Im2afNM= -github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20240826154954-f6182d2b17a2/go.mod h1:mFlcEjsm2YBBsu8atHJ3zyVnwM+Z/fMXpVmIJge+WVU= -github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20241211191239-915ad3f37c3b h1:IvCbb1Pl6W0Ty7GFyq71O0KGOtSg82nqn5zi6UVGivk= -github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20241211191239-915ad3f37c3b/go.mod h1:mFlcEjsm2YBBsu8atHJ3zyVnwM+Z/fMXpVmIJge+WVU= +github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20241217070745-faeedeaaea77 h1:EEPwISL8b1mIh0k7l0/2b2MxzbHfakkIUdFNKiD+dwg= +github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20241217070745-faeedeaaea77/go.mod h1:mFlcEjsm2YBBsu8atHJ3zyVnwM+Z/fMXpVmIJge+WVU= github.com/0xPolygon/cdk-data-availability v0.0.10 h1:pVcke2I7GuPH7JeRLKokEOHffPMwEHmJd9yDXHqh9B4= github.com/0xPolygon/cdk-data-availability v0.0.10/go.mod h1:nn5RmnkzOiugAxizSbaYnA+em79YLLLoR25i0UlKc5Q= github.com/0xPolygon/cdk-data-availability v0.0.11 h1:enmlyFYCvmDmcX/2fnDjWnn3svqqm9o2Fe+Kupoykdo= diff --git a/lastgersync/evmdownloader.go b/lastgersync/evmdownloader.go index 7a695faa..9217dfa1 100644 --- a/lastgersync/evmdownloader.go +++ b/lastgersync/evmdownloader.go @@ -7,7 +7,8 @@ import ( "math/big" "time" - "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain-paris/polygonzkevmglobalexitrootv2" + "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain-paris/globalexitrootmanagerl2sovereignchain" + cdkcommon "github.com/0xPolygon/cdk/common" "github.com/0xPolygon/cdk/db" "github.com/0xPolygon/cdk/l1infotreesync" "github.com/0xPolygon/cdk/log" @@ -26,8 +27,7 @@ type EthClienter interface { type downloader struct { *sync.EVMDownloaderImplementation - l2Client EthClienter - gerContract *polygonzkevmglobalexitrootv2.Polygonzkevmglobalexitrootv2 + l2GERManager *globalexitrootmanagerl2sovereignchain.Globalexitrootmanagerl2sovereignchain l1InfoTreesync *l1infotreesync.L1InfoTreeSync processor *processor rh *sync.RetryHandler @@ -35,14 +35,15 @@ type downloader struct { func newDownloader( l2Client EthClienter, - globalExitRootL2 common.Address, - l1InfoTreesync *l1infotreesync.L1InfoTreeSync, + l2GERAddr common.Address, + l1InfoTreeSync *l1infotreesync.L1InfoTreeSync, processor *processor, rh *sync.RetryHandler, blockFinality *big.Int, waitForNewBlocksPeriod time.Duration, ) (*downloader, error) { - gerContract, err := polygonzkevmglobalexitrootv2.NewPolygonzkevmglobalexitrootv2(globalExitRootL2, l2Client) + gerContract, err := globalexitrootmanagerl2sovereignchain.NewGlobalexitrootmanagerl2sovereignchain( + l2GERAddr, l2Client) if err != nil { return nil, err } @@ -51,9 +52,8 @@ func newDownloader( EVMDownloaderImplementation: sync.NewEVMDownloaderImplementation( "lastgersync", l2Client, blockFinality, waitForNewBlocksPeriod, nil, nil, nil, rh, ), - l2Client: l2Client, - gerContract: gerContract, - l1InfoTreesync: l1InfoTreesync, + l2GERManager: gerContract, + l1InfoTreesync: l1InfoTreeSync, processor: processor, rh: rh, }, nil @@ -148,10 +148,11 @@ func (d *downloader) getGERsFromIndex(ctx context.Context, fromL1InfoTreeIndex u if err != nil { return nil, fmt.Errorf("error calling GetInfoByIndex: %w", err) } - gers = append(gers, Event{ - L1InfoTreeIndex: i, - GlobalExitRoot: info.GlobalExitRoot, - }) + gers = append(gers, + Event{ + L1InfoTreeIndex: i, + GlobalExitRoot: info.GlobalExitRoot, + }) } return gers, nil @@ -161,20 +162,16 @@ func (d *downloader) setGreatestGERInjectedFromList(b *sync.EVMBlock, list []Eve for _, event := range list { var attempts int for { - timestamp, err := d.gerContract.GlobalExitRootMap( - &bind.CallOpts{Pending: false}, event.GlobalExitRoot, - ) + blockHashBigInt, err := d.l2GERManager.GlobalExitRootMap(&bind.CallOpts{Pending: false}, event.GlobalExitRoot) if err != nil { attempts++ - log.Errorf( - "error calling contract function GlobalExitRootMap with ger %s: %v", - event.GlobalExitRoot.Hex(), err, - ) + log.Errorf("failed to check if global exit root %s is injected on L2: %s", event.GlobalExitRoot.Hex(), err) d.rh.Handle("GlobalExitRootMap", attempts) continue } - if timestamp.Cmp(big.NewInt(0)) == 1 { + + if common.BigToHash(blockHashBigInt) != cdkcommon.ZeroHash { b.Events = []interface{}{event} } diff --git a/sync/evmdownloader.go b/sync/evmdownloader.go index 20f48f48..b849a517 100644 --- a/sync/evmdownloader.go +++ b/sync/evmdownloader.go @@ -98,7 +98,7 @@ func (d *EVMDownloader) Download(ctx context.Context, fromBlock uint64, download lastBlock = d.WaitForNewBlocks(ctx, fromBlock-1) continue } - d.log.Debugf("getting events from blocks %d to %d", fromBlock, toBlock) + d.log.Debugf("getting events from blocks %d to %d", fromBlock, toBlock) blocks := d.GetEventsByBlockRange(ctx, fromBlock, toBlock) for _, b := range blocks { d.log.Debugf("sending block %d to the driver (with events)", b.Num) From ddad93b9cd3144ce364c042a3cbe254df63ae47c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Tue, 17 Dec 2024 10:54:37 +0100 Subject: [PATCH 03/21] fix: backport changes from fep-type1 branch --- aggoracle/chaingersender/evm.go | 4 +++- claimsponsor/evmclaimsponsor.go | 2 ++ tree/tree.go | 9 +++++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/aggoracle/chaingersender/evm.go b/aggoracle/chaingersender/evm.go index 5af3e443..ef9e1b75 100644 --- a/aggoracle/chaingersender/evm.go +++ b/aggoracle/chaingersender/evm.go @@ -132,10 +132,12 @@ func (c *EVMChainGERSender) InjectGER(ctx context.Context, ger common.Hash) erro ethtxtypes.MonitoredTxStatusSent: continue case ethtxtypes.MonitoredTxStatusFailed: - return fmt.Errorf("tx %s failed", id.Hex()) + return fmt.Errorf("inject GER tx %s failed", id.Hex()) case ethtxtypes.MonitoredTxStatusMined, ethtxtypes.MonitoredTxStatusSafe, ethtxtypes.MonitoredTxStatusFinalized: + c.logger.Debugf("inject GER tx %s was successfully mined at block %d", id.Hex(), res.MinedAtBlockNumber) + return nil default: c.logger.Error("unexpected tx status:", res.Status) diff --git a/claimsponsor/evmclaimsponsor.go b/claimsponsor/evmclaimsponsor.go index 6f315d94..10b073c3 100644 --- a/claimsponsor/evmclaimsponsor.go +++ b/claimsponsor/evmclaimsponsor.go @@ -174,6 +174,8 @@ func (c *EVMClaimSponsor) claimStatus(ctx context.Context, id string) (ClaimStat case ethtxtypes.MonitoredTxStatusMined, ethtxtypes.MonitoredTxStatusSafe, ethtxtypes.MonitoredTxStatusFinalized: + log.Infof("claim tx with id %s mined at block %d", id, res.MinedAtBlockNumber) + return SuccessClaimStatus, nil default: return "", fmt.Errorf("unexpected tx status: %v", res.Status) diff --git a/tree/tree.go b/tree/tree.go index 6abb9e3d..51f88a6e 100644 --- a/tree/tree.go +++ b/tree/tree.go @@ -124,7 +124,7 @@ func (t *Tree) getRHTNode(tx db.Querier, nodeHash common.Hash) (*types.TreeNode, node := &types.TreeNode{} err := meddler.QueryRow( tx, node, - fmt.Sprintf(`select * from %s where hash = $1`, t.rhtTable), + fmt.Sprintf(`SELECT * FROM %s WHERE hash = $1`, t.rhtTable), nodeHash.String(), ) if err != nil { @@ -215,9 +215,9 @@ func (t *Tree) GetRootByIndex(ctx context.Context, index uint32) (types.Root, er // GetRootByHash returns the root associated to the hash func (t *Tree) GetRootByHash(ctx context.Context, hash common.Hash) (*types.Root, error) { - var root *types.Root + var root types.Root if err := meddler.QueryRow( - t.db, root, + t.db, &root, fmt.Sprintf(`SELECT * FROM %s WHERE hash = $1;`, t.rootTable), hash.Hex(), ); err != nil { @@ -226,7 +226,8 @@ func (t *Tree) GetRootByHash(ctx context.Context, hash common.Hash) (*types.Root } return nil, err } - return root, nil + + return &root, nil } func (t *Tree) GetLeaf(tx db.Querier, index uint32, root common.Hash) (common.Hash, error) { From 029d73c1648495f8132c791491f67d52d43b4dcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Tue, 17 Dec 2024 10:55:23 +0100 Subject: [PATCH 04/21] chore: remove empty test/e2e.go --- test/e2e.go | 1 - 1 file changed, 1 deletion(-) delete mode 100644 test/e2e.go diff --git a/test/e2e.go b/test/e2e.go deleted file mode 100644 index df8caf70..00000000 --- a/test/e2e.go +++ /dev/null @@ -1 +0,0 @@ -package e2e From d51548b3a2cce36a28ee433058c975072b5c410e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Tue, 17 Dec 2024 13:42:44 +0100 Subject: [PATCH 05/21] test: update the aggoracle e2e test --- aggoracle/e2e_test.go | 8 +++-- bridgesync/bridgesync.go | 2 +- test/helpers/e2e.go | 63 +++++++++++++++++++++++---------------- test/helpers/simulated.go | 21 ++++++------- 4 files changed, 55 insertions(+), 39 deletions(-) diff --git a/aggoracle/e2e_test.go b/aggoracle/e2e_test.go index c5cd3c8a..eb4d466c 100644 --- a/aggoracle/e2e_test.go +++ b/aggoracle/e2e_test.go @@ -30,16 +30,18 @@ func runTest( t.Helper() for i := 0; i < 10; i++ { - // TODO: @Stefan-Ethernal this should be invoked either from rollup manager or bridge - // https://github.com/0xPolygonHermez/zkevm-contracts/blob/2b279bbe712e3d396dcafad4be63b663dd647476/contracts/v2/PolygonZkEVMGlobalExitRootV2.sol#L85-L95 _, err := gerL1Contract.UpdateExitRoot(authL1, common.HexToHash(strconv.Itoa(i))) require.NoError(t, err) l1Client.Commit() - time.Sleep(time.Millisecond * 150) + + // wait for the GER to be processed by the L1InfoTree syncer + time.Sleep(time.Millisecond * 100) expectedGER, err := gerL1Contract.GetLastGlobalExitRoot(&bind.CallOpts{Pending: false}) require.NoError(t, err) + isInjected, err := sender.IsGERInjected(expectedGER) require.NoError(t, err) + require.True(t, isInjected, fmt.Sprintf("iteration %d, GER: %s", i, common.Bytes2Hex(expectedGER[:]))) } } diff --git a/bridgesync/bridgesync.go b/bridgesync/bridgesync.go index d91477c8..ebf9115e 100644 --- a/bridgesync/bridgesync.go +++ b/bridgesync/bridgesync.go @@ -162,7 +162,7 @@ func newBridgeSync( } logger.Infof("BridgeSyncer [%s] created: dbPath: %s initialBlock: %d bridgeAddr: %s, syncFullClaims: %d,"+ " maxRetryAttemptsAfterError: %d RetryAfterErrorPeriod: %s"+ - "syncBlockChunkSize: %d, blockFinalityType: %s waitForNewBlocksPeriod: %s", + " syncBlockChunkSize: %d, blockFinalityType: %s, waitForNewBlocksPeriod: %s", l1OrL2ID, dbPath, initialBlock, bridge.String(), syncFullClaims, maxRetryAttemptsAfterError, retryAfterErrorPeriod.String(), diff --git a/test/helpers/e2e.go b/test/helpers/e2e.go index d77b6e26..a2fbcbbe 100644 --- a/test/helpers/e2e.go +++ b/test/helpers/e2e.go @@ -6,6 +6,7 @@ import ( "testing" "time" + "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain-paris/globalexitrootmanagerl2sovereignchain" "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain-paris/polygonzkevmbridgev2" "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain-paris/polygonzkevmglobalexitrootv2" "github.com/0xPolygon/cdk/aggoracle" @@ -15,6 +16,7 @@ import ( "github.com/0xPolygon/cdk/l1infotreesync" "github.com/0xPolygon/cdk/log" "github.com/0xPolygon/cdk/reorgdetector" + "github.com/0xPolygon/cdk/test/contracts/transparentupgradableproxy" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" @@ -35,7 +37,7 @@ type AggoracleWithEVMChainEnv struct { L1InfoTreeSync *l1infotreesync.L1InfoTreeSync GERL1Contract *polygonzkevmglobalexitrootv2.Polygonzkevmglobalexitrootv2 GERL1Addr common.Address - GERL2Contract *polygonzkevmglobalexitrootv2.Polygonzkevmglobalexitrootv2 + GERL2Contract *globalexitrootmanagerl2sovereignchain.Globalexitrootmanagerl2sovereignchain GERL2Addr common.Address AuthL1 *bind.TransactOpts AuthL2 *bind.TransactOpts @@ -57,8 +59,10 @@ func NewE2EEnvWithEVML2(t *testing.T) *AggoracleWithEVMChainEnv { t.Helper() ctx := context.Background() - l1Client, syncer, gerL1Contract, gerL1Addr, - bridgeL1Contract, bridgeL1Addr, authL1, rdL1, bridgeL1Sync := CommonSetup(t) + l1Client, syncer, + gerL1Contract, gerL1Addr, + bridgeL1Contract, bridgeL1Addr, + authL1, rdL1, bridgeL1Sync := CommonSetup(t) sender, l2Client, gerL2Contract, gerL2Addr, bridgeL2Contract, bridgeL2Addr, authL2, @@ -137,7 +141,8 @@ func CommonSetup(t *testing.T) ( gerL1Addr, common.Address{}, syncBlockChunkSize, etherman.LatestBlock, rdL1, l1Client.Client(), - time.Millisecond, 0, periodRetry, retries, l1infotreesync.FlagAllowWrongContractsAddrs, + time.Millisecond, 0, periodRetry, + retries, l1infotreesync.FlagAllowWrongContractsAddrs, ) require.NoError(t, err) @@ -171,7 +176,7 @@ func CommonSetup(t *testing.T) ( func L2SetupEVM(t *testing.T) ( aggoracle.ChainSender, *simulated.Backend, - *polygonzkevmglobalexitrootv2.Polygonzkevmglobalexitrootv2, + *globalexitrootmanagerl2sovereignchain.Globalexitrootmanagerl2sovereignchain, common.Address, *polygonzkevmbridgev2.Polygonzkevmbridgev2, common.Address, @@ -182,7 +187,7 @@ func L2SetupEVM(t *testing.T) ( ) { t.Helper() - l2Client, authL2, gerL2Addr, gerL2Sc, bridgeL2Addr, bridgeL2Sc := newSimulatedEVMAggSovereignChain(t) + l2Client, authL2, gerL2Addr, gerL2Contract, bridgeL2Addr, bridgeL2Sc := newSimulatedEVML2SovereignChain(t) ethTxManMock := NewEthTxManMock(t, l2Client, authL2) sender, err := chaingersender.NewEVMChainGERSender( log.GetDefaultLogger(), @@ -219,7 +224,7 @@ func L2SetupEVM(t *testing.T) ( go bridgeL2Sync.Start(ctx) - return sender, l2Client, gerL2Sc, gerL2Addr, bridgeL2Sc, bridgeL2Addr, authL2, ethTxManMock, bridgeL2Sync, rdL2 + return sender, l2Client, gerL2Contract, gerL2Addr, bridgeL2Sc, bridgeL2Addr, authL2, ethTxManMock, bridgeL2Sync, rdL2 } func newSimulatedL1(t *testing.T) ( @@ -234,7 +239,7 @@ func newSimulatedL1(t *testing.T) ( client, setup := SimulatedBackend(t, nil, 0) - precalculatedAddr := crypto.CreateAddress(setup.DeployerAuth.From, 2) //nolint:mnd + expectedGERAddr := crypto.CreateAddress(setup.DeployerAuth.From, 2) //nolint:mnd gerAddr, _, gerContract, err := polygonzkevmglobalexitrootv2.DeployPolygonzkevmglobalexitrootv2( setup.DeployerAuth, client.Client(), @@ -242,16 +247,16 @@ func newSimulatedL1(t *testing.T) ( require.NoError(t, err) client.Commit() - require.Equal(t, precalculatedAddr, gerAddr) + require.Equal(t, expectedGERAddr, gerAddr) return client, setup.UserAuth, gerAddr, gerContract, setup.BridgeProxyAddr, setup.BridgeProxyContract } -func newSimulatedEVMAggSovereignChain(t *testing.T) ( +func newSimulatedEVML2SovereignChain(t *testing.T) ( *simulated.Backend, *bind.TransactOpts, common.Address, - *polygonzkevmglobalexitrootv2.Polygonzkevmglobalexitrootv2, + *globalexitrootmanagerl2sovereignchain.Globalexitrootmanagerl2sovereignchain, common.Address, *polygonzkevmbridgev2.Polygonzkevmbridgev2, ) { @@ -259,23 +264,31 @@ func newSimulatedEVMAggSovereignChain(t *testing.T) ( client, setup := SimulatedBackend(t, nil, rollupID) - // TODO: @Stefan-Ethernal deploy the GlobalExitRootManagerL2SovereignChain here instead? - // https://github.com/0xPolygonHermez/zkevm-contracts/blob/feature/audit-remediations/contracts/v2/sovereignChains/GlobalExitRootManagerL2SovereignChain.sol - gerAddr, _, gerContract, err := polygonzkevmglobalexitrootv2.DeployPolygonzkevmglobalexitrootv2( - setup.DeployerAuth, client.Client(), setup.UserAuth.From, setup.BridgeProxyAddr) + gerL2Addr, _, _, err := globalexitrootmanagerl2sovereignchain.DeployGlobalexitrootmanagerl2sovereignchain( + setup.DeployerAuth, client.Client(), setup.BridgeProxyAddr) require.NoError(t, err) client.Commit() - // TODO: @Stefan-Ethernal Remove? - // globalExitRootSetterRole := common.HexToHash("0x7b95520991dfda409891be0afa2635b63540f92ee996fda0bf695a166e5c5176") - // _, err = gerContract.GrantRole(setup.DeployerAuth, globalExitRootSetterRole, setup.UserAuth.From) - // require.NoError(t, err) - // client.Commit() + gerL2Abi, err := globalexitrootmanagerl2sovereignchain.Globalexitrootmanagerl2sovereignchainMetaData.GetAbi() + require.NoError(t, err) + require.NotNil(t, gerL2Abi) - // precalculatedAddr := crypto.CreateAddress(setup.DeployerAuth.From, 2) //nolint:mnd - // hasRole, _ := gerContract.HasRole(&bind.CallOpts{Pending: false}, globalExitRootSetterRole, setup.UserAuth.From) - // require.True(t, hasRole) - // require.Equal(t, precalculatedAddr, gerAddr) + gerL2InitData, err := gerL2Abi.Pack("initialize", setup.UserAuth.From, setup.UserAuth.From) + require.NoError(t, err) - return client, setup.UserAuth, gerAddr, gerContract, setup.BridgeProxyAddr, setup.BridgeProxyContract + gerProxyAddr, _, _, err := transparentupgradableproxy.DeployTransparentupgradableproxy( + setup.DeployerAuth, + client.Client(), + gerL2Addr, + setup.DeployerAuth.From, + gerL2InitData, + ) + require.NoError(t, err) + client.Commit() + + gerL2Contract, err := globalexitrootmanagerl2sovereignchain.NewGlobalexitrootmanagerl2sovereignchain( + gerProxyAddr, client.Client()) + require.NoError(t, err) + + return client, setup.UserAuth, gerProxyAddr, gerL2Contract, setup.BridgeProxyAddr, setup.BridgeProxyContract } diff --git a/test/helpers/simulated.go b/test/helpers/simulated.go index 31d609d1..48bc4893 100644 --- a/test/helpers/simulated.go +++ b/test/helpers/simulated.go @@ -90,7 +90,7 @@ func SimulatedBackend( ) { - precalculatedAddr := crypto.CreateAddress(deployerAuth.From, 2) //nolint:mnd + calculatedGERAddr := crypto.CreateAddress(deployerAuth.From, 2) //nolint:mnd bridgeABI, err := polygonzkevmbridgev2.Polygonzkevmbridgev2MetaData.GetAbi() require.NoError(t, err) @@ -100,7 +100,7 @@ func SimulatedBackend( rollupID, common.Address{}, // gasTokenAddressMainnet uint32(0), // gasTokenNetworkMainnet - precalculatedAddr, + calculatedGERAddr, common.Address{}, []byte{}, // gasTokenMetadata ) @@ -120,15 +120,16 @@ func SimulatedBackend( bridgeProxyContract, err = polygonzkevmbridgev2.NewPolygonzkevmbridgev2(bridgeProxyAddr, client.Client()) require.NoError(t, err) - checkGERAddr, err := bridgeProxyContract.GlobalExitRootManager(&bind.CallOpts{}) + actualGERAddr, err := bridgeProxyContract.GlobalExitRootManager(&bind.CallOpts{}) require.NoError(t, err) - require.Equal(t, precalculatedAddr, checkGERAddr) + require.Equal(t, calculatedGERAddr, actualGERAddr) } - return client, &SimulatedBackendSetup{ - UserAuth: userAuth, - DeployerAuth: deployerAuth, - BridgeProxyAddr: bridgeProxyAddr, - BridgeProxyContract: bridgeProxyContract, - } + return client, + &SimulatedBackendSetup{ + UserAuth: userAuth, + DeployerAuth: deployerAuth, + BridgeProxyAddr: bridgeProxyAddr, + BridgeProxyContract: bridgeProxyContract, + } } From 8719da52598f8e364630ee797b31f65988bd5737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Wed, 18 Dec 2024 08:18:48 +0100 Subject: [PATCH 06/21] fix: logs --- aggoracle/oracle.go | 3 +-- bridgesync/bridgesync.go | 2 +- claimsponsor/claimsponsor.go | 2 +- sync/evmdownloader.go | 4 ++-- test/helpers/e2e.go | 15 +++++++++++---- test/helpers/ethtxmanmock_e2e.go | 25 +++++++++++-------------- 6 files changed, 27 insertions(+), 24 deletions(-) diff --git a/aggoracle/oracle.go b/aggoracle/oracle.go index 88ee56ce..2bdc469f 100644 --- a/aggoracle/oracle.go +++ b/aggoracle/oracle.go @@ -7,7 +7,6 @@ import ( "math/big" "time" - "github.com/0xPolygon/cdk/db" "github.com/0xPolygon/cdk/etherman" "github.com/0xPolygon/cdk/l1infotreesync" "github.com/0xPolygon/cdk/log" @@ -110,7 +109,7 @@ func (a *AggOracle) handleGERProcessingError(err error, blockNumToFetch uint64) switch { case errors.Is(err, l1infotreesync.ErrBlockNotProcessed): a.logger.Debugf("syncer is not ready for the block %d", blockNumToFetch) - case errors.Is(err, db.ErrNotFound): + case errors.Is(err, l1infotreesync.ErrNotFound): a.logger.Debugf("syncer has not found any GER until block %d", blockNumToFetch) default: a.logger.Error("unexpected error processing GER: ", err) diff --git a/bridgesync/bridgesync.go b/bridgesync/bridgesync.go index ebf9115e..643933cf 100644 --- a/bridgesync/bridgesync.go +++ b/bridgesync/bridgesync.go @@ -161,7 +161,7 @@ func newBridgeSync( return nil, err } logger.Infof("BridgeSyncer [%s] created: dbPath: %s initialBlock: %d bridgeAddr: %s, syncFullClaims: %d,"+ - " maxRetryAttemptsAfterError: %d RetryAfterErrorPeriod: %s"+ + " maxRetryAttemptsAfterError: %d, retryAfterErrorPeriod: %s,"+ " syncBlockChunkSize: %d, blockFinalityType: %s, waitForNewBlocksPeriod: %s", l1OrL2ID, dbPath, initialBlock, bridge.String(), syncFullClaims, diff --git a/claimsponsor/claimsponsor.go b/claimsponsor/claimsponsor.go index 32483789..5c6c8bf0 100644 --- a/claimsponsor/claimsponsor.go +++ b/claimsponsor/claimsponsor.go @@ -141,7 +141,7 @@ func (c *ClaimSponsor) claim(ctx context.Context) error { } } - c.logger.Infof("waiting for tx %s with global index %s to succeed or fail", claim.TxID, claim.GlobalIndex.String()) + c.logger.Infof("waiting for tx %s with global index %s", claim.TxID, claim.GlobalIndex.String()) status, err := c.waitTxToBeSuccessOrFail(ctx, claim.TxID) if err != nil { return fmt.Errorf("error calling waitTxToBeSuccessOrFail for tx %s: %w", claim.TxID, err) diff --git a/sync/evmdownloader.go b/sync/evmdownloader.go index b849a517..8b3ad790 100644 --- a/sync/evmdownloader.go +++ b/sync/evmdownloader.go @@ -92,13 +92,13 @@ func (d *EVMDownloader) Download(ctx context.Context, fromBlock uint64, download } if fromBlock > toBlock { d.log.Debugf( - "waiting for new blocks, last block processed %d, last block seen on L1 %d", + "waiting for new blocks, last block processed: %d, last block seen on L1: %d", fromBlock-1, lastBlock, ) lastBlock = d.WaitForNewBlocks(ctx, fromBlock-1) continue } - d.log.Debugf("getting events from blocks %d to %d", fromBlock, toBlock) + d.log.Debugf("getting events from block %d to %d", fromBlock, toBlock) blocks := d.GetEventsByBlockRange(ctx, fromBlock, toBlock) for _, b := range blocks { d.log.Debugf("sending block %d to the driver (with events)", b.Num) diff --git a/test/helpers/e2e.go b/test/helpers/e2e.go index a2fbcbbe..eb4e9b01 100644 --- a/test/helpers/e2e.go +++ b/test/helpers/e2e.go @@ -187,11 +187,15 @@ func L2SetupEVM(t *testing.T) ( ) { t.Helper() - l2Client, authL2, gerL2Addr, gerL2Contract, bridgeL2Addr, bridgeL2Sc := newSimulatedEVML2SovereignChain(t) + l2Client, authL2, gerL2Addr, gerL2Contract, + bridgeL2Addr, bridgeL2Contract := newSimulatedEVML2SovereignChain(t) + ethTxManMock := NewEthTxManMock(t, l2Client, authL2) + + const gerCheckFrequency = time.Millisecond * 50 sender, err := chaingersender.NewEVMChainGERSender( - log.GetDefaultLogger(), - gerL2Addr, l2Client.Client(), ethTxManMock, 0, time.Millisecond*50, //nolint:mnd + log.GetDefaultLogger(), gerL2Addr, l2Client.Client(), + ethTxManMock, 0, gerCheckFrequency, ) require.NoError(t, err) ctx := context.Background() @@ -224,7 +228,10 @@ func L2SetupEVM(t *testing.T) ( go bridgeL2Sync.Start(ctx) - return sender, l2Client, gerL2Contract, gerL2Addr, bridgeL2Sc, bridgeL2Addr, authL2, ethTxManMock, bridgeL2Sync, rdL2 + return sender, l2Client, + gerL2Contract, gerL2Addr, + bridgeL2Contract, bridgeL2Addr, + authL2, ethTxManMock, bridgeL2Sync, rdL2 } func newSimulatedL1(t *testing.T) ( diff --git a/test/helpers/ethtxmanmock_e2e.go b/test/helpers/ethtxmanmock_e2e.go index 0c8ee0f8..1bb0d934 100644 --- a/test/helpers/ethtxmanmock_e2e.go +++ b/test/helpers/ethtxmanmock_e2e.go @@ -2,7 +2,6 @@ package helpers import ( "context" - "math/big" "testing" "github.com/0xPolygon/cdk/log" @@ -23,9 +22,8 @@ func NewEthTxManMock( t.Helper() const ( - ArgToIndex = 1 - ArgDataIndex = 3 - ZeroValue = 0 + argReceiverIdx = 1 + argTxInputIdx = 3 ) ethTxMock := NewEthTxManagerMock(t) @@ -40,17 +38,17 @@ func NewEthTxManMock( } gas, err := client.Client().EstimateGas(ctx, ethereum.CallMsg{ From: auth.From, - To: args.Get(ArgToIndex).(*common.Address), - Value: big.NewInt(ZeroValue), - Data: args.Get(ArgDataIndex).([]byte), + To: args.Get(argReceiverIdx).(*common.Address), + Value: common.Big0, + Data: args.Get(argTxInputIdx).([]byte), }) if err != nil { log.Error(err) res, err := client.Client().CallContract(ctx, ethereum.CallMsg{ From: auth.From, - To: args.Get(ArgToIndex).(*common.Address), - Value: big.NewInt(ZeroValue), - Data: args.Get(ArgDataIndex).([]byte), + To: args.Get(argReceiverIdx).(*common.Address), + Value: common.Big0, + Data: args.Get(argTxInputIdx).([]byte), }, nil) log.Debugf("contract call: %s", res) if err != nil { @@ -63,12 +61,12 @@ func NewEthTxManMock( log.Error(err) } - to, ok := args.Get(ArgToIndex).(*common.Address) + to, ok := args.Get(argReceiverIdx).(*common.Address) if !ok { log.Error("expected *common.Address for ArgToIndex") return } - data, ok := args.Get(ArgDataIndex).([]byte) + data, ok := args.Get(argTxInputIdx).([]byte) if !ok { log.Error("expected []byte for ArgDataIndex") return @@ -76,7 +74,7 @@ func NewEthTxManMock( tx := types.NewTx(&types.LegacyTx{ To: to, Nonce: nonce, - Value: big.NewInt(ZeroValue), + Value: common.Big0, Data: data, Gas: gas, GasPrice: price, @@ -95,7 +93,6 @@ func NewEthTxManMock( client.Commit() }). Return(common.Hash{}, nil) - // res, err := c.ethTxMan.Result(ctx, id) ethTxMock.On("Result", mock.Anything, mock.Anything). Return(ethtxtypes.MonitoredTxResult{Status: ethtxtypes.MonitoredTxStatusMined}, nil) From 70a68e131f8eb09d8a3ffc9ade5a9af9a6a48dc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Wed, 18 Dec 2024 12:20:06 +0100 Subject: [PATCH 07/21] refactor: rely only on single L1 bridge syncer in the e2e, cleanup logs, handle context cancellation --- bridgesync/bridgesync.go | 42 ++++++++++++++++-------- bridgesync/downloader.go | 2 +- claimsponsor/claimsponsor.go | 31 +++++++++++------- claimsponsor/e2e_test.go | 50 ++++++++++++++--------------- claimsponsor/evmclaimsponsor.go | 49 +++++++++++++--------------- lastgersync/evmdownloader.go | 9 +++--- test/helpers/e2e.go | 1 + test/helpers/ethtxmanmock_e2e.go | 55 +++++++++++++++++--------------- 8 files changed, 129 insertions(+), 110 deletions(-) diff --git a/bridgesync/bridgesync.go b/bridgesync/bridgesync.go index 643933cf..4052ba29 100644 --- a/bridgesync/bridgesync.go +++ b/bridgesync/bridgesync.go @@ -12,8 +12,8 @@ import ( ) const ( - bridgeSyncL1 = "bridgesyncl1" - bridgeSyncL2 = "bridgesyncl2" + bridgeSyncL1 = "L1" + bridgeSyncL2 = "L2" downloadBufferSize = 1000 ) @@ -107,14 +107,14 @@ func newBridgeSync( rd ReorgDetector, ethClient EthClienter, initialBlock uint64, - l1OrL2ID string, + layerID string, waitForNewBlocksPeriod time.Duration, retryAfterErrorPeriod time.Duration, maxRetryAttemptsAfterError int, originNetwork uint32, syncFullClaims bool, ) (*BridgeSync, error) { - logger := log.WithFields("bridge-syncer", l1OrL2ID) + logger := log.WithFields("bridge-syncer", layerID) processor, err := newProcessor(dbPath, logger) if err != nil { return nil, err @@ -143,7 +143,7 @@ func newBridgeSync( return nil, err } downloader, err := sync.NewEVMDownloader( - l1OrL2ID, + layerID, ethClient, syncBlockChunkSize, blockFinalityType, @@ -156,17 +156,33 @@ func newBridgeSync( return nil, err } - driver, err := sync.NewEVMDriver(rd, processor, downloader, l1OrL2ID, downloadBufferSize, rh) + driver, err := sync.NewEVMDriver(rd, processor, downloader, layerID, downloadBufferSize, rh) if err != nil { return nil, err } - logger.Infof("BridgeSyncer [%s] created: dbPath: %s initialBlock: %d bridgeAddr: %s, syncFullClaims: %d,"+ - " maxRetryAttemptsAfterError: %d, retryAfterErrorPeriod: %s,"+ - " syncBlockChunkSize: %d, blockFinalityType: %s, waitForNewBlocksPeriod: %s", - l1OrL2ID, - dbPath, initialBlock, bridge.String(), syncFullClaims, - maxRetryAttemptsAfterError, retryAfterErrorPeriod.String(), - syncBlockChunkSize, blockFinalityType, waitForNewBlocksPeriod.String()) + + logger.Infof( + "BridgeSyncer [%s] created:\n"+ + " dbPath: %s\n"+ + " initialBlock: %d\n"+ + " bridgeAddr: %s\n"+ + " syncFullClaims: %t\n"+ + " maxRetryAttemptsAfterError: %d\n"+ + " retryAfterErrorPeriod: %s\n"+ + " syncBlockChunkSize: %d\n"+ + " blockFinalityType: %s\n"+ + " waitForNewBlocksPeriod: %s", + layerID, + dbPath, + initialBlock, + bridge.String(), + syncFullClaims, + maxRetryAttemptsAfterError, + retryAfterErrorPeriod.String(), + syncBlockChunkSize, + blockFinalityType, + waitForNewBlocksPeriod.String(), + ) return &BridgeSync{ processor: processor, diff --git a/bridgesync/downloader.go b/bridgesync/downloader.go index 782d5f1b..4b774401 100644 --- a/bridgesync/downloader.go +++ b/bridgesync/downloader.go @@ -7,7 +7,7 @@ import ( "strings" "github.com/0xPolygon/cdk-contracts-tooling/contracts/etrog/polygonzkevmbridge" - "github.com/0xPolygon/cdk-contracts-tooling/contracts/etrog/polygonzkevmbridgev2" + "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain-paris/polygonzkevmbridgev2" rpcTypes "github.com/0xPolygon/cdk-rpc/types" "github.com/0xPolygon/cdk/db" "github.com/0xPolygon/cdk/sync" diff --git a/claimsponsor/claimsponsor.go b/claimsponsor/claimsponsor.go index 5c6c8bf0..73d08eb7 100644 --- a/claimsponsor/claimsponsor.go +++ b/claimsponsor/claimsponsor.go @@ -101,17 +101,22 @@ func newClaimSponsor( } func (c *ClaimSponsor) Start(ctx context.Context) { - var ( - attempts int - ) + attempts := 0 + for { - err := c.claim(ctx) - if err != nil { - attempts++ - c.logger.Error(err) - c.rh.Handle("claimsponsor main loop", attempts) - } else { - attempts = 0 + select { + case <-ctx.Done(): + return + + default: + err := c.claim(ctx) + if err != nil { + attempts++ + c.logger.Error(err) + c.rh.Handle("claimsponsor main loop", attempts) + } else { + attempts = 0 + } } } } @@ -207,12 +212,14 @@ func (c *ClaimSponsor) updateClaimStatus(globalIndex *big.Int, status ClaimStatu } func (c *ClaimSponsor) waitTxToBeSuccessOrFail(ctx context.Context, txID string) (ClaimStatus, error) { - t := time.NewTicker(c.waitTxToBeMinedPeriod) + ticker := time.NewTicker(c.waitTxToBeMinedPeriod) + defer ticker.Stop() + for { select { case <-ctx.Done(): return "", errors.New("context cancelled") - case <-t.C: + case <-ticker.C: status, err := c.sender.claimStatus(ctx, txID) if err != nil { return "", err diff --git a/claimsponsor/e2e_test.go b/claimsponsor/e2e_test.go index c5d669f7..8299d2b5 100644 --- a/claimsponsor/e2e_test.go +++ b/claimsponsor/e2e_test.go @@ -11,7 +11,6 @@ import ( "github.com/0xPolygon/cdk/bridgesync" "github.com/0xPolygon/cdk/claimsponsor" - "github.com/0xPolygon/cdk/etherman" "github.com/0xPolygon/cdk/log" "github.com/0xPolygon/cdk/test/helpers" "github.com/ethereum/go-ethereum/accounts/abi/bind" @@ -23,11 +22,6 @@ func TestE2EL1toEVML2(t *testing.T) { // start other needed components ctx := context.Background() env := helpers.NewE2EEnvWithEVML2(t) - dbPathBridgeSyncL1 := path.Join(t.TempDir(), "claimsponsorTestE2EL1toEVML2_bs.sqlite") - testClient := helpers.TestClient{ClientRenamed: env.L1Client.Client()} - bridgeSyncL1, err := bridgesync.NewL1(ctx, dbPathBridgeSyncL1, env.BridgeL1Addr, 10, etherman.LatestBlock, env.ReorgDetectorL1, testClient, 0, time.Millisecond*10, 0, 0, 1, false) - require.NoError(t, err) - go bridgeSyncL1.Start(ctx) // start claim sponsor dbPathClaimSponsor := path.Join(t.TempDir(), "claimsponsorTestE2EL1toEVML2_cs.sqlite") @@ -46,14 +40,15 @@ func TestE2EL1toEVML2(t *testing.T) { go claimer.Start(ctx) // test - for i := 0; i < 3; i++ { + for i := uint32(0); i < 3; i++ { // Send bridges to L2, wait for GER to be injected on L2 - amount := big.NewInt(int64(i) + 1) + amount := new(big.Int).SetUint64(uint64(i) + 1) env.AuthL1.Value = amount _, err := env.BridgeL1Contract.BridgeAsset(env.AuthL1, env.NetworkIDL2, env.AuthL2.From, amount, common.Address{}, true, nil) require.NoError(t, err) env.L1Client.Commit() time.Sleep(time.Millisecond * 300) + expectedGER, err := env.GERL1Contract.GetLastGlobalExitRoot(&bind.CallOpts{Pending: false}) require.NoError(t, err) isInjected, err := env.AggOracleSender.IsGERInjected(expectedGER) @@ -61,29 +56,32 @@ func TestE2EL1toEVML2(t *testing.T) { require.True(t, isInjected, fmt.Sprintf("iteration %d, GER: %s", i, common.Bytes2Hex(expectedGER[:]))) // Build MP using bridgeSyncL1 & env.L1InfoTreeSync - info, err := env.L1InfoTreeSync.GetInfoByIndex(ctx, uint32(i)) + info, err := env.L1InfoTreeSync.GetInfoByIndex(ctx, i) require.NoError(t, err) - localProof, err := bridgeSyncL1.GetProof(ctx, uint32(i), info.MainnetExitRoot) + + localProof, err := env.BridgeL1Sync.GetProof(ctx, i, info.MainnetExitRoot) require.NoError(t, err) + rollupProof, err := env.L1InfoTreeSync.GetRollupExitTreeMerkleProof(ctx, 0, common.Hash{}) require.NoError(t, err) // Request to sponsor claim - globalIndex := bridgesync.GenerateGlobalIndex(true, 0, uint32(i)) - err = claimer.AddClaimToQueue(&claimsponsor.Claim{ - LeafType: 0, - ProofLocalExitRoot: localProof, - ProofRollupExitRoot: rollupProof, - GlobalIndex: globalIndex, - MainnetExitRoot: info.MainnetExitRoot, - RollupExitRoot: info.RollupExitRoot, - OriginNetwork: 0, - OriginTokenAddress: common.Address{}, - DestinationNetwork: env.NetworkIDL2, - DestinationAddress: env.AuthL2.From, - Amount: amount, - Metadata: nil, - }) + globalIndex := bridgesync.GenerateGlobalIndex(true, 0, i) + err = claimer.AddClaimToQueue( + &claimsponsor.Claim{ + LeafType: claimsponsor.LeafTypeAsset, + ProofLocalExitRoot: localProof, + ProofRollupExitRoot: rollupProof, + GlobalIndex: globalIndex, + MainnetExitRoot: info.MainnetExitRoot, + RollupExitRoot: info.RollupExitRoot, + OriginNetwork: 0, + OriginTokenAddress: common.Address{}, + DestinationNetwork: env.NetworkIDL2, + DestinationAddress: env.AuthL2.From, + Amount: amount, + Metadata: nil, + }) require.NoError(t, err) // Wait until success @@ -103,7 +101,7 @@ func TestE2EL1toEVML2(t *testing.T) { require.True(t, succeed) // Check on contract that is claimed - isClaimed, err := env.BridgeL2Contract.IsClaimed(&bind.CallOpts{Pending: false}, uint32(i), 0) + isClaimed, err := env.BridgeL2Contract.IsClaimed(&bind.CallOpts{Pending: false}, i, 0) require.NoError(t, err) require.True(t, isClaimed) } diff --git a/claimsponsor/evmclaimsponsor.go b/claimsponsor/evmclaimsponsor.go index 10b073c3..d8fbfb22 100644 --- a/claimsponsor/evmclaimsponsor.go +++ b/claimsponsor/evmclaimsponsor.go @@ -6,7 +6,7 @@ import ( "math/big" "time" - "github.com/0xPolygon/cdk-contracts-tooling/contracts/etrog/polygonzkevmbridgev2" + "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain-paris/polygonzkevmbridgev2" configTypes "github.com/0xPolygon/cdk/config/types" "github.com/0xPolygon/cdk/log" "github.com/0xPolygon/zkevm-ethtx-manager/ethtxmanager" @@ -22,8 +22,9 @@ const ( // LeafTypeAsset represents a bridge asset LeafTypeAsset uint8 = 0 // LeafTypeMessage represents a bridge message - LeafTypeMessage uint8 = 1 - gasTooHighErrTemplate = "Claim tx estimated to consume more gas than the maximum allowed by the service. " + + LeafTypeMessage uint8 = 1 + + gasTooHighErrTemplate = "Claim tx estimated to consume more gas than the maximum allowed by the service. " + "Estimated %d, maximum allowed: %d" ) @@ -41,15 +42,13 @@ type EthTxManager interface { } type EVMClaimSponsor struct { - *ClaimSponsor - l2Client EthClienter - bridgeABI *abi.ABI - bridgeAddr common.Address - bridgeContract *polygonzkevmbridgev2.Polygonzkevmbridgev2 - ethTxManager EthTxManager - sender common.Address - gasOffest uint64 - maxGas uint64 + l2Client EthClienter + bridgeABI *abi.ABI + bridgeAddr common.Address + ethTxManager EthTxManager + sender common.Address + gasOffest uint64 + maxGas uint64 } type EVMClaimSponsorConfig struct { @@ -83,7 +82,7 @@ func NewEVMClaimSponsor( logger *log.Logger, dbPath string, l2Client EthClienter, - bridge common.Address, + bridgeAddr common.Address, sender common.Address, maxGas, gasOffset uint64, ethTxManager EthTxManager, @@ -92,24 +91,21 @@ func NewEVMClaimSponsor( waitTxToBeMinedPeriod time.Duration, waitOnEmptyQueue time.Duration, ) (*ClaimSponsor, error) { - contract, err := polygonzkevmbridgev2.NewPolygonzkevmbridgev2(bridge, l2Client) - if err != nil { - return nil, err - } abi, err := polygonzkevmbridgev2.Polygonzkevmbridgev2MetaData.GetAbi() if err != nil { return nil, err } + evmSponsor := &EVMClaimSponsor{ - l2Client: l2Client, - bridgeABI: abi, - bridgeAddr: bridge, - bridgeContract: contract, - sender: sender, - gasOffest: gasOffset, - maxGas: maxGas, - ethTxManager: ethTxManager, + l2Client: l2Client, + bridgeABI: abi, + bridgeAddr: bridgeAddr, + sender: sender, + gasOffest: gasOffset, + maxGas: maxGas, + ethTxManager: ethTxManager, } + baseSponsor, err := newClaimSponsor( logger, dbPath, @@ -122,7 +118,6 @@ func NewEVMClaimSponsor( if err != nil { return nil, err } - evmSponsor.ClaimSponsor = baseSponsor return baseSponsor, nil } @@ -152,7 +147,7 @@ func (c *EVMClaimSponsor) sendClaim(ctx context.Context, claim *Claim) (string, if err != nil { return "", err } - id, err := c.ethTxManager.Add(ctx, &c.bridgeAddr, big.NewInt(0), data, c.gasOffest, nil) + id, err := c.ethTxManager.Add(ctx, &c.bridgeAddr, common.Big0, data, c.gasOffest, nil) if err != nil { return "", err } diff --git a/lastgersync/evmdownloader.go b/lastgersync/evmdownloader.go index 9217dfa1..819a52bd 100644 --- a/lastgersync/evmdownloader.go +++ b/lastgersync/evmdownloader.go @@ -148,11 +148,10 @@ func (d *downloader) getGERsFromIndex(ctx context.Context, fromL1InfoTreeIndex u if err != nil { return nil, fmt.Errorf("error calling GetInfoByIndex: %w", err) } - gers = append(gers, - Event{ - L1InfoTreeIndex: i, - GlobalExitRoot: info.GlobalExitRoot, - }) + gers = append(gers, Event{ + L1InfoTreeIndex: i, + GlobalExitRoot: info.GlobalExitRoot, + }) } return gers, nil diff --git a/test/helpers/e2e.go b/test/helpers/e2e.go index eb4e9b01..eb741391 100644 --- a/test/helpers/e2e.go +++ b/test/helpers/e2e.go @@ -67,6 +67,7 @@ func NewE2EEnvWithEVML2(t *testing.T) *AggoracleWithEVMChainEnv { sender, l2Client, gerL2Contract, gerL2Addr, bridgeL2Contract, bridgeL2Addr, authL2, ethTxManMockL2, bridgeL2Sync, rdL2 := L2SetupEVM(t) + oracle, err := aggoracle.New( log.GetDefaultLogger(), sender, l1Client.Client(), syncer, diff --git a/test/helpers/ethtxmanmock_e2e.go b/test/helpers/ethtxmanmock_e2e.go index 1bb0d934..92a8546c 100644 --- a/test/helpers/ethtxmanmock_e2e.go +++ b/test/helpers/ethtxmanmock_e2e.go @@ -2,6 +2,7 @@ package helpers import ( "context" + "encoding/hex" "testing" "github.com/0xPolygon/cdk/log" @@ -36,23 +37,36 @@ func NewEthTxManMock( log.Error(err) return } - gas, err := client.Client().EstimateGas(ctx, ethereum.CallMsg{ - From: auth.From, - To: args.Get(argReceiverIdx).(*common.Address), - Value: common.Big0, - Data: args.Get(argTxInputIdx).([]byte), - }) + + to, ok := args.Get(argReceiverIdx).(*common.Address) + if !ok { + log.Error("expected *common.Address for tx receiver arg") + return + } + + data, ok := args.Get(argTxInputIdx).([]byte) + if !ok { + log.Error("expected []byte for tx input data arg") + return + } + + log.Debugf("receiver %s, data: %s", to, hex.EncodeToString(data)) + + msg := ethereum.CallMsg{ + From: auth.From, + To: to, + Data: data, + } + + gas, err := client.Client().EstimateGas(ctx, msg) if err != nil { - log.Error(err) - res, err := client.Client().CallContract(ctx, ethereum.CallMsg{ - From: auth.From, - To: args.Get(argReceiverIdx).(*common.Address), - Value: common.Big0, - Data: args.Get(argTxInputIdx).([]byte), - }, nil) - log.Debugf("contract call: %s", res) + log.Errorf("eth_estimateGas invocation failed: %s", err) + + res, err := client.Client().CallContract(ctx, msg, nil) if err != nil { - log.Errorf("%+v", err) + log.Errorf("eth_call invocation failed: %s", err) + } else { + log.Debugf("contract call result: %s", hex.EncodeToString(res)) } return } @@ -61,16 +75,6 @@ func NewEthTxManMock( log.Error(err) } - to, ok := args.Get(argReceiverIdx).(*common.Address) - if !ok { - log.Error("expected *common.Address for ArgToIndex") - return - } - data, ok := args.Get(argTxInputIdx).([]byte) - if !ok { - log.Error("expected []byte for ArgDataIndex") - return - } tx := types.NewTx(&types.LegacyTx{ To: to, Nonce: nonce, @@ -79,7 +83,6 @@ func NewEthTxManMock( Gas: gas, GasPrice: price, }) - tx.Gas() signedTx, err := auth.Signer(auth.From, tx) if err != nil { log.Error(err) From 85c056687bbb8a39c2873bfa002fb7354db624ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Wed, 18 Dec 2024 16:15:39 +0100 Subject: [PATCH 08/21] refactor: simulated backend so that it correctly initializes bridge contract --- aggoracle/e2e_test.go | 22 +-- bridgesync/e2e_test.go | 4 +- claimsponsor/e2e_test.go | 29 ++-- .../datacommittee/datacommittee_test.go | 12 +- l1infotreesync/e2e_test.go | 10 +- test/helpers/e2e.go | 26 +++- test/helpers/ethtxmanmock_e2e.go | 4 +- test/helpers/simulated.go | 132 ++++++++++-------- 8 files changed, 127 insertions(+), 112 deletions(-) diff --git a/aggoracle/e2e_test.go b/aggoracle/e2e_test.go index eb4d466c..c39bf60b 100644 --- a/aggoracle/e2e_test.go +++ b/aggoracle/e2e_test.go @@ -6,40 +6,26 @@ import ( "testing" "time" - gerContractL1 "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain-paris/polygonzkevmglobalexitrootv2" - "github.com/0xPolygon/cdk/aggoracle" "github.com/0xPolygon/cdk/test/helpers" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/ethclient/simulated" "github.com/stretchr/testify/require" ) func TestEVM(t *testing.T) { env := helpers.NewE2EEnvWithEVML2(t) - runTest(t, env.GERL1Contract, env.AggOracleSender, env.L1Client, env.AuthL1) -} - -func runTest( - t *testing.T, - gerL1Contract *gerContractL1.Polygonzkevmglobalexitrootv2, - sender aggoracle.ChainSender, - l1Client *simulated.Backend, - authL1 *bind.TransactOpts, -) { - t.Helper() for i := 0; i < 10; i++ { - _, err := gerL1Contract.UpdateExitRoot(authL1, common.HexToHash(strconv.Itoa(i))) + _, err := env.GERL1Contract.UpdateExitRoot(env.AuthL1, common.HexToHash(strconv.Itoa(i))) require.NoError(t, err) - l1Client.Commit() + env.L1Client.Commit() // wait for the GER to be processed by the L1InfoTree syncer time.Sleep(time.Millisecond * 100) - expectedGER, err := gerL1Contract.GetLastGlobalExitRoot(&bind.CallOpts{Pending: false}) + expectedGER, err := env.GERL1Contract.GetLastGlobalExitRoot(&bind.CallOpts{Pending: false}) require.NoError(t, err) - isInjected, err := sender.IsGERInjected(expectedGER) + isInjected, err := env.AggOracleSender.IsGERInjected(expectedGER) require.NoError(t, err) require.True(t, isInjected, fmt.Sprintf("iteration %d, GER: %s", i, common.Bytes2Hex(expectedGER[:]))) diff --git a/bridgesync/e2e_test.go b/bridgesync/e2e_test.go index 3c1e166e..be63c980 100644 --- a/bridgesync/e2e_test.go +++ b/bridgesync/e2e_test.go @@ -24,7 +24,6 @@ func TestBridgeEventE2E(t *testing.T) { ) env := helpers.NewE2EEnvWithEVML2(t) ctx := context.Background() - // Send bridge txs bridgesSent := 0 reorgs := 0 @@ -35,7 +34,7 @@ func TestBridgeEventE2E(t *testing.T) { bridge := bridgesync.Bridge{ Amount: big.NewInt(0), DepositCount: lastDepositCount, - DestinationNetwork: uint32(i), + DestinationNetwork: uint32(i + 1), DestinationAddress: common.HexToAddress("f00"), Metadata: []byte{}, } @@ -48,6 +47,7 @@ func TestBridgeEventE2E(t *testing.T) { bridge.OriginAddress, true, nil, ) + t.Logf("BridgeAsset err: %+v", err) require.NoError(t, err) helpers.CommitBlocks(t, env.L1Client, 1, blockTime) bn, err := env.L1Client.Client().BlockNumber(ctx) diff --git a/claimsponsor/e2e_test.go b/claimsponsor/e2e_test.go index 8299d2b5..c06223b9 100644 --- a/claimsponsor/e2e_test.go +++ b/claimsponsor/e2e_test.go @@ -67,21 +67,20 @@ func TestE2EL1toEVML2(t *testing.T) { // Request to sponsor claim globalIndex := bridgesync.GenerateGlobalIndex(true, 0, i) - err = claimer.AddClaimToQueue( - &claimsponsor.Claim{ - LeafType: claimsponsor.LeafTypeAsset, - ProofLocalExitRoot: localProof, - ProofRollupExitRoot: rollupProof, - GlobalIndex: globalIndex, - MainnetExitRoot: info.MainnetExitRoot, - RollupExitRoot: info.RollupExitRoot, - OriginNetwork: 0, - OriginTokenAddress: common.Address{}, - DestinationNetwork: env.NetworkIDL2, - DestinationAddress: env.AuthL2.From, - Amount: amount, - Metadata: nil, - }) + err = claimer.AddClaimToQueue(&claimsponsor.Claim{ + LeafType: claimsponsor.LeafTypeAsset, + ProofLocalExitRoot: localProof, + ProofRollupExitRoot: rollupProof, + GlobalIndex: globalIndex, + MainnetExitRoot: info.MainnetExitRoot, + RollupExitRoot: info.RollupExitRoot, + OriginNetwork: 0, + OriginTokenAddress: common.Address{}, + DestinationNetwork: env.NetworkIDL2, + DestinationAddress: env.AuthL2.From, + Amount: amount, + Metadata: nil, + }) require.NoError(t, err) // Wait until success diff --git a/dataavailability/datacommittee/datacommittee_test.go b/dataavailability/datacommittee/datacommittee_test.go index 7e2a8d3e..2cc009ad 100644 --- a/dataavailability/datacommittee/datacommittee_test.go +++ b/dataavailability/datacommittee/datacommittee_test.go @@ -5,10 +5,10 @@ import ( "math/big" "testing" - smcparis "github.com/0xPolygon/cdk-contracts-tooling/contracts/banana-paris/polygondatacommittee" + scparis "github.com/0xPolygon/cdk-contracts-tooling/contracts/banana-paris/polygondatacommittee" "github.com/0xPolygon/cdk-contracts-tooling/contracts/banana/polygondatacommittee" "github.com/0xPolygon/cdk/log" - erc1967proxy "github.com/0xPolygon/cdk/test/contracts/erc1967proxy" + "github.com/0xPolygon/cdk/test/contracts/erc1967proxy" "github.com/0xPolygon/cdk/test/helpers" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" @@ -20,7 +20,7 @@ import ( func TestUpdateDataCommitteeEvent(t *testing.T) { // Set up testing environment - dac, ethBackend, da, auth := newSimulatedDacman(t) + dac, ethBackend, da, auth := newSimulatedDACBackend(t) // Update the committee requiredAmountOfSignatures := big.NewInt(2) @@ -65,7 +65,7 @@ func init() { // NewSimulatedEtherman creates an etherman that uses a simulated blockchain. It's important to notice that the ChainID of the auth // must be 1337. The address that holds the auth will have an initial balance of 10 ETH -func newSimulatedDacman(t *testing.T) ( +func newSimulatedDACBackend(t *testing.T) ( *Backend, *simulated.Backend, *polygondatacommittee.Polygondatacommittee, @@ -73,10 +73,10 @@ func newSimulatedDacman(t *testing.T) ( ) { t.Helper() - ethBackend, setup := helpers.SimulatedBackend(t, nil, 0) + ethBackend, setup := helpers.NewSimulatedBackend(t, nil) // DAC Setup - addr, _, _, err := smcparis.DeployPolygondatacommittee(setup.UserAuth, ethBackend.Client()) + addr, _, _, err := scparis.DeployPolygondatacommittee(setup.UserAuth, ethBackend.Client()) require.NoError(t, err) ethBackend.Commit() diff --git a/l1infotreesync/e2e_test.go b/l1infotreesync/e2e_test.go index 885d2bff..9084bf85 100644 --- a/l1infotreesync/e2e_test.go +++ b/l1infotreesync/e2e_test.go @@ -35,21 +35,23 @@ func newSimulatedClient(t *testing.T) ( ) { t.Helper() ctx := context.Background() - client, setup := helpers.SimulatedBackend(t, nil, 0) + client, setup := helpers.NewSimulatedBackend(t, nil) nonce, err := client.Client().PendingNonceAt(ctx, setup.UserAuth.From) require.NoError(t, err) - precalculatedAddr := crypto.CreateAddress(setup.UserAuth.From, nonce+1) - verifyAddr, _, verifyContract, err := verifybatchesmock.DeployVerifybatchesmock(setup.UserAuth, client.Client(), precalculatedAddr) + precalculatedGERAddr := crypto.CreateAddress(setup.UserAuth.From, nonce+1) + verifyAddr, _, verifyContract, err := verifybatchesmock.DeployVerifybatchesmock(setup.UserAuth, client.Client(), precalculatedGERAddr) require.NoError(t, err) client.Commit() gerAddr, _, gerContract, err := polygonzkevmglobalexitrootv2.DeployPolygonzkevmglobalexitrootv2(setup.UserAuth, client.Client(), verifyAddr, setup.UserAuth.From) require.NoError(t, err) + require.Equal(t, precalculatedGERAddr, gerAddr) client.Commit() - require.Equal(t, precalculatedAddr, gerAddr) + err = setup.DeployBridge(client, gerAddr, 0) + require.NoError(t, err) return client, setup.UserAuth, gerAddr, verifyAddr, gerContract, verifyContract } diff --git a/test/helpers/e2e.go b/test/helpers/e2e.go index eb741391..963d7268 100644 --- a/test/helpers/e2e.go +++ b/test/helpers/e2e.go @@ -59,11 +59,13 @@ func NewE2EEnvWithEVML2(t *testing.T) *AggoracleWithEVMChainEnv { t.Helper() ctx := context.Background() + // Setup L1 l1Client, syncer, gerL1Contract, gerL1Addr, bridgeL1Contract, bridgeL1Addr, authL1, rdL1, bridgeL1Sync := CommonSetup(t) + // Setup L2 EVM sender, l2Client, gerL2Contract, gerL2Addr, bridgeL2Contract, bridgeL2Addr, authL2, ethTxManMockL2, bridgeL2Sync, rdL2 := L2SetupEVM(t) @@ -123,7 +125,6 @@ func CommonSetup(t *testing.T) ( ) { t.Helper() - // Config and spin up ctx := context.Background() // Simulated L1 @@ -245,9 +246,17 @@ func newSimulatedL1(t *testing.T) ( ) { t.Helper() - client, setup := SimulatedBackend(t, nil, 0) + client, setup := NewSimulatedBackend(t, nil) - expectedGERAddr := crypto.CreateAddress(setup.DeployerAuth.From, 2) //nolint:mnd + ctx := context.Background() + nonce, err := client.Client().PendingNonceAt(ctx, setup.DeployerAuth.From) + require.NoError(t, err) + + // DeployBridge function sends two transactions (bridge and proxy contract deployment) + calculatedGERAddr := crypto.CreateAddress(setup.DeployerAuth.From, nonce+2) //nolint:mnd + + err = setup.DeployBridge(client, calculatedGERAddr, 0) + require.NoError(t, err) gerAddr, _, gerContract, err := polygonzkevmglobalexitrootv2.DeployPolygonzkevmglobalexitrootv2( setup.DeployerAuth, client.Client(), @@ -255,7 +264,7 @@ func newSimulatedL1(t *testing.T) ( require.NoError(t, err) client.Commit() - require.Equal(t, expectedGERAddr, gerAddr) + require.Equal(t, calculatedGERAddr, gerAddr) return client, setup.UserAuth, gerAddr, gerContract, setup.BridgeProxyAddr, setup.BridgeProxyContract } @@ -270,7 +279,7 @@ func newSimulatedEVML2SovereignChain(t *testing.T) ( ) { t.Helper() - client, setup := SimulatedBackend(t, nil, rollupID) + client, setup := NewSimulatedBackend(t, nil) gerL2Addr, _, _, err := globalexitrootmanagerl2sovereignchain.DeployGlobalexitrootmanagerl2sovereignchain( setup.DeployerAuth, client.Client(), setup.BridgeProxyAddr) @@ -298,5 +307,12 @@ func newSimulatedEVML2SovereignChain(t *testing.T) ( gerProxyAddr, client.Client()) require.NoError(t, err) + err = setup.DeployBridge(client, gerProxyAddr, rollupID) + require.NoError(t, err) + + actualGERAddr, err := setup.BridgeProxyContract.GlobalExitRootManager(nil) + require.NoError(t, err) + require.Equal(t, gerProxyAddr, actualGERAddr) + return client, setup.UserAuth, gerProxyAddr, gerL2Contract, setup.BridgeProxyAddr, setup.BridgeProxyContract } diff --git a/test/helpers/ethtxmanmock_e2e.go b/test/helpers/ethtxmanmock_e2e.go index 92a8546c..5a07fa19 100644 --- a/test/helpers/ethtxmanmock_e2e.go +++ b/test/helpers/ethtxmanmock_e2e.go @@ -60,11 +60,11 @@ func NewEthTxManMock( gas, err := client.Client().EstimateGas(ctx, msg) if err != nil { - log.Errorf("eth_estimateGas invocation failed: %s", err) + log.Errorf("eth_estimateGas invocation failed: %+v", err) res, err := client.Client().CallContract(ctx, msg, nil) if err != nil { - log.Errorf("eth_call invocation failed: %s", err) + log.Errorf("eth_call invocation failed: %+v", err) } else { log.Debugf("contract call result: %s", hex.EncodeToString(res)) } diff --git a/test/helpers/simulated.go b/test/helpers/simulated.go index 48bc4893..3ee86462 100644 --- a/test/helpers/simulated.go +++ b/test/helpers/simulated.go @@ -1,6 +1,7 @@ package helpers import ( + "fmt" "math/big" "testing" @@ -39,11 +40,71 @@ type SimulatedBackendSetup struct { BridgeProxyContract *polygonzkevmbridgev2.Polygonzkevmbridgev2 } -// SimulatedBackend creates a simulated backend with two accounts: user and deployer. -func SimulatedBackend( - t *testing.T, - balances map[common.Address]types.Account, - rollupID uint32, +// DeployBridge deploys the bridge contract +func (s *SimulatedBackendSetup) DeployBridge(client *simulated.Backend, + gerAddr common.Address, networkID uint32) error { + // Deploy zkevm bridge contract + bridgeAddr, _, _, err := polygonzkevmbridgev2.DeployPolygonzkevmbridgev2(s.DeployerAuth, client.Client()) + if err != nil { + return err + } + client.Commit() + + // Create proxy contract for the bridge + var ( + bridgeProxyAddr common.Address + bridgeProxyContract *polygonzkevmbridgev2.Polygonzkevmbridgev2 + ) + + bridgeABI, err := polygonzkevmbridgev2.Polygonzkevmbridgev2MetaData.GetAbi() + if err != nil { + return err + } + + // TODO: @Stefan-Ethernal parameterize gasTokenAddress and gasTokenNetwork if necessary + dataCallProxy, err := bridgeABI.Pack("initialize", + networkID, + common.Address{}, // gasTokenAddressMainnet + uint32(0), // gasTokenNetworkMainnet + gerAddr, // global exit root manager + common.Address{}, // rollup manager + []byte{}, // gasTokenMetadata + ) + if err != nil { + return err + } + + bridgeProxyAddr, _, _, err = transparentupgradableproxy.DeployTransparentupgradableproxy( + s.DeployerAuth, + client.Client(), + bridgeAddr, + s.DeployerAuth.From, + dataCallProxy, + ) + if err != nil { + return err + } + client.Commit() + + bridgeProxyContract, err = polygonzkevmbridgev2.NewPolygonzkevmbridgev2(bridgeProxyAddr, client.Client()) + if err != nil { + return err + } + + actualGERAddr, err := bridgeProxyContract.GlobalExitRootManager(&bind.CallOpts{}) + if gerAddr != actualGERAddr { + return fmt.Errorf("mismatch between expected %s and actual %s GER addresses on bridge contract (%s)", + gerAddr, actualGERAddr, bridgeProxyAddr) + } + + s.BridgeProxyAddr = bridgeProxyAddr + s.BridgeProxyContract = bridgeProxyContract + + return err +} + +// NewSimulatedBackend creates a simulated backend with two accounts: user and deployer. +func NewSimulatedBackend(t *testing.T, balances map[common.Address]types.Account, ) (*simulated.Backend, *SimulatedBackendSetup) { t.Helper() @@ -51,13 +112,13 @@ func SimulatedBackend( balance, ok := new(big.Int).SetString(defaultBalance, 10) //nolint:mnd require.Truef(t, ok, "failed to set balance") - // Create user + // Create user account userPK, err := crypto.GenerateKey() require.NoError(t, err) userAuth, err := bind.NewKeyedTransactorWithChainID(userPK, big.NewInt(chainID)) require.NoError(t, err) - // Create deployer + // Create deployer account deployerPK, err := crypto.GenerateKey() require.NoError(t, err) deployerAuth, err := bind.NewKeyedTransactorWithChainID(deployerPK, big.NewInt(chainID)) @@ -77,59 +138,10 @@ func SimulatedBackend( // Mine the first block client.Commit() - // MUST BE DEPLOYED FIRST - // Deploy zkevm bridge contract - bridgeAddr, _, _, err := polygonzkevmbridgev2.DeployPolygonzkevmbridgev2(deployerAuth, client.Client()) - require.NoError(t, err) - client.Commit() - - // Create proxy contract for the bridge - var ( - bridgeProxyAddr common.Address - bridgeProxyContract *polygonzkevmbridgev2.Polygonzkevmbridgev2 - ) - - { - calculatedGERAddr := crypto.CreateAddress(deployerAuth.From, 2) //nolint:mnd - - bridgeABI, err := polygonzkevmbridgev2.Polygonzkevmbridgev2MetaData.GetAbi() - require.NoError(t, err) - require.NotNil(t, bridgeABI) - - dataCallProxy, err := bridgeABI.Pack("initialize", - rollupID, - common.Address{}, // gasTokenAddressMainnet - uint32(0), // gasTokenNetworkMainnet - calculatedGERAddr, - common.Address{}, - []byte{}, // gasTokenMetadata - ) - require.NoError(t, err) - - bridgeProxyAddr, _, _, err = transparentupgradableproxy.DeployTransparentupgradableproxy( - deployerAuth, - client.Client(), - bridgeAddr, - deployerAuth.From, - dataCallProxy, - ) - require.NoError(t, err) - require.Equal(t, precalculatedBridgeAddr, bridgeProxyAddr) - client.Commit() - - bridgeProxyContract, err = polygonzkevmbridgev2.NewPolygonzkevmbridgev2(bridgeProxyAddr, client.Client()) - require.NoError(t, err) - - actualGERAddr, err := bridgeProxyContract.GlobalExitRootManager(&bind.CallOpts{}) - require.NoError(t, err) - require.Equal(t, calculatedGERAddr, actualGERAddr) + setup := &SimulatedBackendSetup{ + UserAuth: userAuth, + DeployerAuth: deployerAuth, } - return client, - &SimulatedBackendSetup{ - UserAuth: userAuth, - DeployerAuth: deployerAuth, - BridgeProxyAddr: bridgeProxyAddr, - BridgeProxyContract: bridgeProxyContract, - } + return client, setup } From cb1eee98c52dbeb93c137cd3d8526d6cff7c95e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Wed, 18 Dec 2024 19:07:10 +0100 Subject: [PATCH 09/21] fix: tests --- .../datacommittee/datacommittee_test.go | 5 +- l1infotreesync/e2e_test.go | 7 +- test/helpers/e2e.go | 28 ++++- test/helpers/ethtxmanmock_e2e.go | 102 +++++++++++++----- test/helpers/simulated.go | 37 +++++-- 5 files changed, 138 insertions(+), 41 deletions(-) diff --git a/dataavailability/datacommittee/datacommittee_test.go b/dataavailability/datacommittee/datacommittee_test.go index 2cc009ad..63d04c57 100644 --- a/dataavailability/datacommittee/datacommittee_test.go +++ b/dataavailability/datacommittee/datacommittee_test.go @@ -73,7 +73,10 @@ func newSimulatedDACBackend(t *testing.T) ( ) { t.Helper() - ethBackend, setup := helpers.NewSimulatedBackend(t, nil) + deployerAuth, err := helpers.CreateAccount(big.NewInt(1337)) + require.NoError(t, err) + + ethBackend, setup := helpers.NewSimulatedBackend(t, nil, deployerAuth) // DAC Setup addr, _, _, err := scparis.DeployPolygondatacommittee(setup.UserAuth, ethBackend.Client()) diff --git a/l1infotreesync/e2e_test.go b/l1infotreesync/e2e_test.go index 9084bf85..7d78a5d0 100644 --- a/l1infotreesync/e2e_test.go +++ b/l1infotreesync/e2e_test.go @@ -3,6 +3,7 @@ package l1infotreesync_test import ( "context" "fmt" + "math/big" "path" "strconv" "testing" @@ -35,7 +36,11 @@ func newSimulatedClient(t *testing.T) ( ) { t.Helper() ctx := context.Background() - client, setup := helpers.NewSimulatedBackend(t, nil) + + deployerAuth, err := helpers.CreateAccount(big.NewInt(1337)) + require.NoError(t, err) + + client, setup := helpers.NewSimulatedBackend(t, nil, deployerAuth) nonce, err := client.Client().PendingNonceAt(ctx, setup.UserAuth.From) require.NoError(t, err) diff --git a/test/helpers/e2e.go b/test/helpers/e2e.go index 963d7268..2f2af506 100644 --- a/test/helpers/e2e.go +++ b/test/helpers/e2e.go @@ -2,6 +2,7 @@ package helpers import ( "context" + "math/big" "path" "testing" "time" @@ -19,6 +20,7 @@ import ( "github.com/0xPolygon/cdk/test/contracts/transparentupgradableproxy" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethclient/simulated" "github.com/stretchr/testify/require" @@ -246,7 +248,10 @@ func newSimulatedL1(t *testing.T) ( ) { t.Helper() - client, setup := NewSimulatedBackend(t, nil) + deployerAuth, err := CreateAccount(big.NewInt(chainID)) + require.NoError(t, err) + + client, setup := NewSimulatedBackend(t, nil, deployerAuth) ctx := context.Background() nonce, err := client.Client().PendingNonceAt(ctx, setup.DeployerAuth.From) @@ -279,13 +284,25 @@ func newSimulatedEVML2SovereignChain(t *testing.T) ( ) { t.Helper() - client, setup := NewSimulatedBackend(t, nil) + deployerAuth, err := CreateAccount(big.NewInt(chainID)) + require.NoError(t, err) + + premineBalance, ok := new(big.Int).SetString(defaultBalance, base10) + require.True(t, ok) + + const deployedContractsCount = 3 + l2BridgeAddr := crypto.CreateAddress(deployerAuth.From, deployedContractsCount) + + genesisAllocMap := map[common.Address]types.Account{l2BridgeAddr: {Balance: premineBalance}} + client, setup := NewSimulatedBackend(t, genesisAllocMap, deployerAuth) + // Deploy L2 GER manager contract gerL2Addr, _, _, err := globalexitrootmanagerl2sovereignchain.DeployGlobalexitrootmanagerl2sovereignchain( setup.DeployerAuth, client.Client(), setup.BridgeProxyAddr) require.NoError(t, err) client.Commit() + // Prepare initialize data that are going to be called by the L2 GER proxy contract gerL2Abi, err := globalexitrootmanagerl2sovereignchain.Globalexitrootmanagerl2sovereignchainMetaData.GetAbi() require.NoError(t, err) require.NotNil(t, gerL2Abi) @@ -293,6 +310,7 @@ func newSimulatedEVML2SovereignChain(t *testing.T) ( gerL2InitData, err := gerL2Abi.Pack("initialize", setup.UserAuth.From, setup.UserAuth.From) require.NoError(t, err) + // Deploy L2 GER manager proxy contract gerProxyAddr, _, _, err := transparentupgradableproxy.DeployTransparentupgradableproxy( setup.DeployerAuth, client.Client(), @@ -303,16 +321,18 @@ func newSimulatedEVML2SovereignChain(t *testing.T) ( require.NoError(t, err) client.Commit() + // Create L2 GER manager contract binding gerL2Contract, err := globalexitrootmanagerl2sovereignchain.NewGlobalexitrootmanagerl2sovereignchain( gerProxyAddr, client.Client()) require.NoError(t, err) err = setup.DeployBridge(client, gerProxyAddr, rollupID) require.NoError(t, err) + require.Equal(t, l2BridgeAddr, setup.BridgeProxyAddr) - actualGERAddr, err := setup.BridgeProxyContract.GlobalExitRootManager(nil) + bridgeGERAddr, err := setup.BridgeProxyContract.GlobalExitRootManager(nil) require.NoError(t, err) - require.Equal(t, gerProxyAddr, actualGERAddr) + require.Equal(t, gerProxyAddr, bridgeGERAddr) return client, setup.UserAuth, gerProxyAddr, gerL2Contract, setup.BridgeProxyAddr, setup.BridgeProxyContract } diff --git a/test/helpers/ethtxmanmock_e2e.go b/test/helpers/ethtxmanmock_e2e.go index 5a07fa19..8952e72d 100644 --- a/test/helpers/ethtxmanmock_e2e.go +++ b/test/helpers/ethtxmanmock_e2e.go @@ -3,6 +3,8 @@ package helpers import ( "context" "encoding/hex" + "fmt" + big "math/big" "testing" "github.com/0xPolygon/cdk/log" @@ -32,12 +34,6 @@ func NewEthTxManMock( "Add", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything). Run(func(args mock.Arguments) { ctx := context.Background() - nonce, err := client.Client().PendingNonceAt(ctx, auth.From) - if err != nil { - log.Error(err) - return - } - to, ok := args.Get(argReceiverIdx).(*common.Address) if !ok { log.Error("expected *common.Address for tx receiver arg") @@ -58,7 +54,7 @@ func NewEthTxManMock( Data: data, } - gas, err := client.Client().EstimateGas(ctx, msg) + _, err := client.Client().EstimateGas(ctx, msg) if err != nil { log.Errorf("eth_estimateGas invocation failed: %+v", err) @@ -70,29 +66,13 @@ func NewEthTxManMock( } return } - price, err := client.Client().SuggestGasPrice(ctx) - if err != nil { - log.Error(err) - } - tx := types.NewTx(&types.LegacyTx{ - To: to, - Nonce: nonce, - Value: common.Big0, - Data: data, - Gas: gas, - GasPrice: price, - }) - signedTx, err := auth.Signer(auth.From, tx) + err = SendTx(ctx, client, auth, to, data, common.Big0) if err != nil { - log.Error(err) - return - } - err = client.Client().SendTransaction(ctx, signedTx) - if err != nil { - log.Error(err) + log.Errorf("failed to send transaction: %s", err) return } + client.Commit() }). Return(common.Hash{}, nil) @@ -101,3 +81,73 @@ func NewEthTxManMock( return ethTxMock } + +// SendTx is a helper function that creates the legacy transaction, sings it and sends against simulated environment +func SendTx(ctx context.Context, client *simulated.Backend, auth *bind.TransactOpts, + to *common.Address, data []byte, value *big.Int) error { + nonce, err := client.Client().PendingNonceAt(ctx, auth.From) + if err != nil { + return err + } + + gas := uint64(21000) //nolint:mnd + + if len(data) > 0 { + msg := ethereum.CallMsg{ + From: auth.From, + To: to, + Data: data, + Value: value, + } + + gas, err = client.Client().EstimateGas(ctx, msg) + if err != nil { + return err + } + } + + price, err := client.Client().SuggestGasPrice(ctx) + if err != nil { + return err + } + + senderBalance, err := client.Client().BalanceAt(ctx, auth.From, nil) + if err != nil { + return err + } + + required := new(big.Int).Add(value, new(big.Int).Mul(big.NewInt(int64(gas)), price)) + if senderBalance.Cmp(required) < 0 { + return fmt.Errorf("insufficient balance: have %s, need %s", senderBalance, required) + } + + tx := types.NewTx(&types.LegacyTx{ + Nonce: nonce, + GasPrice: price, + Gas: gas, + To: to, + Value: value, + Data: data, + }) + + signedTx, err := auth.Signer(auth.From, tx) + if err != nil { + return err + } + + err = client.Client().SendTransaction(ctx, signedTx) + if err != nil { + return err + } + + client.Commit() + + receipt, err := client.Client().TransactionReceipt(ctx, signedTx.Hash()) + if err != nil { + return fmt.Errorf("transaction failed: %w", err) + } + + fmt.Printf("Transaction status: %d\n", receipt.Status) + + return nil +} diff --git a/test/helpers/simulated.go b/test/helpers/simulated.go index 3ee86462..b021d776 100644 --- a/test/helpers/simulated.go +++ b/test/helpers/simulated.go @@ -1,6 +1,7 @@ package helpers import ( + "context" "fmt" "math/big" "testing" @@ -18,8 +19,10 @@ import ( const ( defaultBlockGasLimit = uint64(999999999999999999) - defaultBalance = "10000000000000000000000000" + defaultBalance = "100000000000000000000000000" chainID = 1337 + + base10 = 10 ) type ClientRenamed simulated.Client @@ -61,7 +64,6 @@ func (s *SimulatedBackendSetup) DeployBridge(client *simulated.Backend, return err } - // TODO: @Stefan-Ethernal parameterize gasTokenAddress and gasTokenNetwork if necessary dataCallProxy, err := bridgeABI.Pack("initialize", networkID, common.Address{}, // gasTokenAddressMainnet @@ -92,6 +94,10 @@ func (s *SimulatedBackendSetup) DeployBridge(client *simulated.Backend, } actualGERAddr, err := bridgeProxyContract.GlobalExitRootManager(&bind.CallOpts{}) + if err != nil { + return err + } + if gerAddr != actualGERAddr { return fmt.Errorf("mismatch between expected %s and actual %s GER addresses on bridge contract (%s)", gerAddr, actualGERAddr, bridgeProxyAddr) @@ -100,12 +106,20 @@ func (s *SimulatedBackendSetup) DeployBridge(client *simulated.Backend, s.BridgeProxyAddr = bridgeProxyAddr s.BridgeProxyContract = bridgeProxyContract - return err + bridgeBalance, err := client.Client().BalanceAt(context.Background(), bridgeProxyAddr, nil) + if err != nil { + return err + } + + fmt.Printf("Bridge balance (%s)=%d\n", bridgeProxyAddr, bridgeBalance) + + return nil } // NewSimulatedBackend creates a simulated backend with two accounts: user and deployer. -func NewSimulatedBackend(t *testing.T, balances map[common.Address]types.Account, -) (*simulated.Backend, *SimulatedBackendSetup) { +func NewSimulatedBackend(t *testing.T, + balances map[common.Address]types.Account, + deployerAuth *bind.TransactOpts) (*simulated.Backend, *SimulatedBackendSetup) { t.Helper() // Define default balance @@ -119,10 +133,6 @@ func NewSimulatedBackend(t *testing.T, balances map[common.Address]types.Account require.NoError(t, err) // Create deployer account - deployerPK, err := crypto.GenerateKey() - require.NoError(t, err) - deployerAuth, err := bind.NewKeyedTransactorWithChainID(deployerPK, big.NewInt(chainID)) - require.NoError(t, err) precalculatedBridgeAddr := crypto.CreateAddress(deployerAuth.From, 1) // Define balances map @@ -145,3 +155,12 @@ func NewSimulatedBackend(t *testing.T, balances map[common.Address]types.Account return client, setup } + +func CreateAccount(chainID *big.Int) (*bind.TransactOpts, error) { + privateKey, err := crypto.GenerateKey() + if err != nil { + return nil, err + } + + return bind.NewKeyedTransactorWithChainID(privateKey, chainID) +} From 3eb029e76bad5bdf9a5bfde38545d92053a0b28d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Wed, 18 Dec 2024 19:12:58 +0100 Subject: [PATCH 10/21] fix: bridge balance logs --- l1infotreesync/e2e_test.go | 3 --- test/helpers/simulated.go | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/l1infotreesync/e2e_test.go b/l1infotreesync/e2e_test.go index 7d78a5d0..7b5c7be8 100644 --- a/l1infotreesync/e2e_test.go +++ b/l1infotreesync/e2e_test.go @@ -199,7 +199,6 @@ func TestWithReorgs(t *testing.T) { require.NoError(t, err) actualRollupExitRoot, err := syncer.GetLastRollupExitRoot(ctx) require.NoError(t, err) - t.Log("exit roots", common.Hash(expectedRollupExitRoot), actualRollupExitRoot.Hash) require.Equal(t, common.Hash(expectedRollupExitRoot), actualRollupExitRoot.Hash) // Assert L1 Info tree root @@ -230,7 +229,6 @@ func TestWithReorgs(t *testing.T) { require.NoError(t, err) actualRollupExitRoot, err = syncer.GetLastRollupExitRoot(ctx) require.ErrorContains(t, err, "not found") // rollup exit tree reorged, it does not have any exits in it - t.Log("exit roots", common.Hash(expectedRollupExitRoot), actualRollupExitRoot.Hash) require.Equal(t, common.Hash(expectedRollupExitRoot), actualRollupExitRoot.Hash) // Forking from block 3 again @@ -252,7 +250,6 @@ func TestWithReorgs(t *testing.T) { require.NoError(t, err) actualRollupExitRoot, err = syncer.GetLastRollupExitRoot(ctx) require.NoError(t, err) - t.Log("exit roots", common.Hash(expectedRollupExitRoot), actualRollupExitRoot.Hash) require.Equal(t, common.Hash(expectedRollupExitRoot), actualRollupExitRoot.Hash) } diff --git a/test/helpers/simulated.go b/test/helpers/simulated.go index b021d776..e9f0a555 100644 --- a/test/helpers/simulated.go +++ b/test/helpers/simulated.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain-paris/polygonzkevmbridgev2" + "github.com/0xPolygon/cdk/log" "github.com/0xPolygon/cdk/test/contracts/transparentupgradableproxy" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" @@ -111,7 +112,7 @@ func (s *SimulatedBackendSetup) DeployBridge(client *simulated.Backend, return err } - fmt.Printf("Bridge balance (%s)=%d\n", bridgeProxyAddr, bridgeBalance) + log.Debugf("Bridge@%s, balance=%d\n", bridgeProxyAddr, bridgeBalance) return nil } From e3cd98ef7a19452f954e4430ca18787549eade97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Thu, 19 Dec 2024 08:53:41 +0100 Subject: [PATCH 11/21] add extract rpc error data helper function --- bridgesync/e2e_test.go | 1 - test/helpers/ethtxmanmock_e2e.go | 17 ++++------------- test/helpers/simulated.go | 14 ++++++++++++++ 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/bridgesync/e2e_test.go b/bridgesync/e2e_test.go index be63c980..61e45674 100644 --- a/bridgesync/e2e_test.go +++ b/bridgesync/e2e_test.go @@ -47,7 +47,6 @@ func TestBridgeEventE2E(t *testing.T) { bridge.OriginAddress, true, nil, ) - t.Logf("BridgeAsset err: %+v", err) require.NoError(t, err) helpers.CommitBlocks(t, env.L1Client, 1, blockTime) bn, err := env.L1Client.Client().BlockNumber(ctx) diff --git a/test/helpers/ethtxmanmock_e2e.go b/test/helpers/ethtxmanmock_e2e.go index 8952e72d..1a42ea17 100644 --- a/test/helpers/ethtxmanmock_e2e.go +++ b/test/helpers/ethtxmanmock_e2e.go @@ -56,11 +56,11 @@ func NewEthTxManMock( _, err := client.Client().EstimateGas(ctx, msg) if err != nil { - log.Errorf("eth_estimateGas invocation failed: %+v", err) + log.Errorf("eth_estimateGas invocation failed: %w", ExtractRPCErrorData(err)) res, err := client.Client().CallContract(ctx, msg, nil) if err != nil { - log.Errorf("eth_call invocation failed: %+v", err) + log.Errorf("eth_call invocation failed: %w", ExtractRPCErrorData(err)) } else { log.Debugf("contract call result: %s", hex.EncodeToString(res)) } @@ -69,11 +69,9 @@ func NewEthTxManMock( err = SendTx(ctx, client, auth, to, data, common.Big0) if err != nil { - log.Errorf("failed to send transaction: %s", err) + log.Errorf("failed to send transaction: %w", err) return } - - client.Commit() }). Return(common.Hash{}, nil) ethTxMock.On("Result", mock.Anything, mock.Anything). @@ -102,7 +100,7 @@ func SendTx(ctx context.Context, client *simulated.Backend, auth *bind.TransactO gas, err = client.Client().EstimateGas(ctx, msg) if err != nil { - return err + return ExtractRPCErrorData(err) } } @@ -142,12 +140,5 @@ func SendTx(ctx context.Context, client *simulated.Backend, auth *bind.TransactO client.Commit() - receipt, err := client.Client().TransactionReceipt(ctx, signedTx.Hash()) - if err != nil { - return fmt.Errorf("transaction failed: %w", err) - } - - fmt.Printf("Transaction status: %d\n", receipt.Status) - return nil } diff --git a/test/helpers/simulated.go b/test/helpers/simulated.go index e9f0a555..4c283bf3 100644 --- a/test/helpers/simulated.go +++ b/test/helpers/simulated.go @@ -2,6 +2,7 @@ package helpers import ( "context" + "errors" "fmt" "math/big" "testing" @@ -157,6 +158,7 @@ func NewSimulatedBackend(t *testing.T, return client, setup } +// CreateAccount creates new private key and corresponding transaction signer func CreateAccount(chainID *big.Int) (*bind.TransactOpts, error) { privateKey, err := crypto.GenerateKey() if err != nil { @@ -165,3 +167,15 @@ func CreateAccount(chainID *big.Int) (*bind.TransactOpts, error) { return bind.NewKeyedTransactorWithChainID(privateKey, chainID) } + +// ExtractRPCErrorData tries to extract the error data from the provided error +func ExtractRPCErrorData(err error) error { + var ed rpc.DataError + if errors.As(err, &ed) { + if eds, ok := ed.ErrorData().(string); ok { + return fmt.Errorf("%w (error data: %s)", err, eds) + } + } + + return err +} From 897cbbc2bbfe9a1b9d2da105f8785f535805aa4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Thu, 19 Dec 2024 10:09:52 +0100 Subject: [PATCH 12/21] extract L1SetupResult and L2SetupResult --- test/helpers/e2e.go | 132 +++++++++++++++++++++++++------------------- 1 file changed, 75 insertions(+), 57 deletions(-) diff --git a/test/helpers/e2e.go b/test/helpers/e2e.go index 2f2af506..efc45069 100644 --- a/test/helpers/e2e.go +++ b/test/helpers/e2e.go @@ -57,74 +57,82 @@ type AggoracleWithEVMChainEnv struct { EthTxManMockL2 *EthTxManagerMock } +type SetupResult struct { + Client *simulated.Backend + GERAddr common.Address + BridgeContract *polygonzkevmbridgev2.Polygonzkevmbridgev2 + BridgeAddr common.Address + Auth *bind.TransactOpts + ReorgDetector *reorgdetector.ReorgDetector + BridgeSync *bridgesync.BridgeSync +} + +type L1SetupResult struct { + SetupResult + GERContract *polygonzkevmglobalexitrootv2.Polygonzkevmglobalexitrootv2 + InfoTreeSync *l1infotreesync.L1InfoTreeSync +} + +type L2SetupResult struct { + SetupResult + GERContract *globalexitrootmanagerl2sovereignchain.Globalexitrootmanagerl2sovereignchain + AggoracleSender aggoracle.ChainSender + EthTxManMock *EthTxManagerMock +} + func NewE2EEnvWithEVML2(t *testing.T) *AggoracleWithEVMChainEnv { t.Helper() ctx := context.Background() // Setup L1 - l1Client, syncer, - gerL1Contract, gerL1Addr, - bridgeL1Contract, bridgeL1Addr, - authL1, rdL1, bridgeL1Sync := CommonSetup(t) + l1Setup := L1Setup(t) // Setup L2 EVM - sender, l2Client, gerL2Contract, gerL2Addr, - bridgeL2Contract, bridgeL2Addr, authL2, - ethTxManMockL2, bridgeL2Sync, rdL2 := L2SetupEVM(t) + l2Setup := L2Setup(t) oracle, err := aggoracle.New( - log.GetDefaultLogger(), sender, - l1Client.Client(), syncer, + log.GetDefaultLogger(), l2Setup.AggoracleSender, + l1Setup.Client.Client(), l1Setup.InfoTreeSync, etherman.LatestBlock, time.Millisecond*20, //nolint:mnd ) require.NoError(t, err) go oracle.Start(ctx) return &AggoracleWithEVMChainEnv{ - L1Client: l1Client, - L2Client: l2Client, + L1Client: l1Setup.Client, + L2Client: l2Setup.Client, - L1InfoTreeSync: syncer, + L1InfoTreeSync: l1Setup.InfoTreeSync, - GERL1Contract: gerL1Contract, - GERL1Addr: gerL1Addr, + GERL1Contract: l1Setup.GERContract, + GERL1Addr: l1Setup.GERAddr, - GERL2Contract: gerL2Contract, - GERL2Addr: gerL2Addr, + GERL2Contract: l2Setup.GERContract, + GERL2Addr: l2Setup.GERAddr, - AuthL1: authL1, - AuthL2: authL2, + AuthL1: l1Setup.Auth, + AuthL2: l2Setup.Auth, AggOracle: oracle, - AggOracleSender: sender, + AggOracleSender: l2Setup.AggoracleSender, - ReorgDetectorL1: rdL1, - ReorgDetectorL2: rdL2, + ReorgDetectorL1: l1Setup.ReorgDetector, + ReorgDetectorL2: l2Setup.ReorgDetector, - BridgeL1Contract: bridgeL1Contract, - BridgeL1Addr: bridgeL1Addr, - BridgeL1Sync: bridgeL1Sync, + BridgeL1Contract: l1Setup.BridgeContract, + BridgeL1Addr: l1Setup.BridgeAddr, + BridgeL1Sync: l1Setup.BridgeSync, - BridgeL2Contract: bridgeL2Contract, - BridgeL2Addr: bridgeL2Addr, - BridgeL2Sync: bridgeL2Sync, + BridgeL2Contract: l2Setup.BridgeContract, + BridgeL2Addr: l2Setup.BridgeAddr, + BridgeL2Sync: l2Setup.BridgeSync, NetworkIDL2: rollupID, - EthTxManMockL2: ethTxManMockL2, + EthTxManMockL2: l2Setup.EthTxManMock, } } -func CommonSetup(t *testing.T) ( - *simulated.Backend, - *l1infotreesync.L1InfoTreeSync, - *polygonzkevmglobalexitrootv2.Polygonzkevmglobalexitrootv2, - common.Address, - *polygonzkevmbridgev2.Polygonzkevmbridgev2, - common.Address, - *bind.TransactOpts, - *reorgdetector.ReorgDetector, - *bridgesync.BridgeSync, -) { +func L1Setup(t *testing.T) *L1SetupResult { t.Helper() ctx := context.Background() @@ -173,22 +181,22 @@ func CommonSetup(t *testing.T) ( go bridgeL1Sync.Start(ctx) - return l1Client, l1InfoTreeSync, gerL1Contract, gerL1Addr, - bridgeL1Contract, bridgeL1Addr, authL1, rdL1, bridgeL1Sync + return &L1SetupResult{ + SetupResult: SetupResult{ + Client: l1Client, + GERAddr: gerL1Addr, + BridgeContract: bridgeL1Contract, + BridgeAddr: bridgeL1Addr, + Auth: authL1, + ReorgDetector: rdL1, + BridgeSync: bridgeL1Sync, + }, + GERContract: gerL1Contract, + InfoTreeSync: l1InfoTreeSync, + } } -func L2SetupEVM(t *testing.T) ( - aggoracle.ChainSender, - *simulated.Backend, - *globalexitrootmanagerl2sovereignchain.Globalexitrootmanagerl2sovereignchain, - common.Address, - *polygonzkevmbridgev2.Polygonzkevmbridgev2, - common.Address, - *bind.TransactOpts, - *EthTxManagerMock, - *bridgesync.BridgeSync, - *reorgdetector.ReorgDetector, -) { +func L2Setup(t *testing.T) *L2SetupResult { t.Helper() l2Client, authL2, gerL2Addr, gerL2Contract, @@ -232,10 +240,20 @@ func L2SetupEVM(t *testing.T) ( go bridgeL2Sync.Start(ctx) - return sender, l2Client, - gerL2Contract, gerL2Addr, - bridgeL2Contract, bridgeL2Addr, - authL2, ethTxManMock, bridgeL2Sync, rdL2 + return &L2SetupResult{ + SetupResult: SetupResult{ + Client: l2Client, + GERAddr: gerL2Addr, + BridgeContract: bridgeL2Contract, + BridgeAddr: bridgeL2Addr, + Auth: authL2, + ReorgDetector: rdL2, + BridgeSync: bridgeL2Sync, + }, + GERContract: gerL2Contract, + AggoracleSender: sender, + EthTxManMock: ethTxManMock, + } } func newSimulatedL1(t *testing.T) ( From fb51557e7087d417fecf262265e14bdf992e5ddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Thu, 19 Dec 2024 10:31:35 +0100 Subject: [PATCH 13/21] some more cleanups --- aggoracle/e2e_test.go | 12 ++-- bridgesync/e2e_test.go | 28 +++++----- claimsponsor/e2e_test.go | 34 ++++++------ lastgersync/e2e_test.go | 20 +++---- test/helpers/e2e.go | 117 +++++++++++++-------------------------- 5 files changed, 87 insertions(+), 124 deletions(-) diff --git a/aggoracle/e2e_test.go b/aggoracle/e2e_test.go index c39bf60b..648791eb 100644 --- a/aggoracle/e2e_test.go +++ b/aggoracle/e2e_test.go @@ -13,19 +13,19 @@ import ( ) func TestEVM(t *testing.T) { - env := helpers.NewE2EEnvWithEVML2(t) + setup := helpers.NewE2EEnvWithEVML2(t) for i := 0; i < 10; i++ { - _, err := env.GERL1Contract.UpdateExitRoot(env.AuthL1, common.HexToHash(strconv.Itoa(i))) + _, err := setup.L1Environment.GERContract.UpdateExitRoot(setup.L1Environment.Auth, common.HexToHash(strconv.Itoa(i))) require.NoError(t, err) - env.L1Client.Commit() + setup.L1Environment.SimBackend.Commit() - // wait for the GER to be processed by the L1InfoTree syncer + // wait for the GER to be processed by the InfoTree syncer time.Sleep(time.Millisecond * 100) - expectedGER, err := env.GERL1Contract.GetLastGlobalExitRoot(&bind.CallOpts{Pending: false}) + expectedGER, err := setup.L1Environment.GERContract.GetLastGlobalExitRoot(&bind.CallOpts{Pending: false}) require.NoError(t, err) - isInjected, err := env.AggOracleSender.IsGERInjected(expectedGER) + isInjected, err := setup.L2Environment.AggoracleSender.IsGERInjected(expectedGER) require.NoError(t, err) require.True(t, isInjected, fmt.Sprintf("iteration %d, GER: %s", i, common.Bytes2Hex(expectedGER[:]))) diff --git a/bridgesync/e2e_test.go b/bridgesync/e2e_test.go index 61e45674..4b1fc94a 100644 --- a/bridgesync/e2e_test.go +++ b/bridgesync/e2e_test.go @@ -22,7 +22,7 @@ func TestBridgeEventE2E(t *testing.T) { maxReorgDepth = 2 reorgEveryXIterations = 4 // every X blocks go back [1,maxReorgDepth] blocks ) - env := helpers.NewE2EEnvWithEVML2(t) + setup := helpers.NewE2EEnvWithEVML2(t) ctx := context.Background() // Send bridge txs bridgesSent := 0 @@ -39,8 +39,8 @@ func TestBridgeEventE2E(t *testing.T) { Metadata: []byte{}, } lastDepositCount++ - tx, err := env.BridgeL1Contract.BridgeAsset( - env.AuthL1, + tx, err := setup.L1Environment.BridgeContract.BridgeAsset( + setup.L1Environment.Auth, bridge.DestinationNetwork, bridge.DestinationAddress, bridge.Amount, @@ -48,11 +48,11 @@ func TestBridgeEventE2E(t *testing.T) { true, nil, ) require.NoError(t, err) - helpers.CommitBlocks(t, env.L1Client, 1, blockTime) - bn, err := env.L1Client.Client().BlockNumber(ctx) + helpers.CommitBlocks(t, setup.L1Environment.SimBackend, 1, blockTime) + bn, err := setup.L1Environment.SimBackend.Client().BlockNumber(ctx) require.NoError(t, err) bridge.BlockNum = bn - receipt, err := env.L1Client.Client().TransactionReceipt(ctx, tx.Hash()) + receipt, err := setup.L1Environment.SimBackend.Client().TransactionReceipt(ctx, tx.Hash()) require.NoError(t, err) require.Equal(t, receipt.Status, types.ReceiptStatusSuccessful) expectedBridges = append(expectedBridges, bridge) @@ -61,9 +61,9 @@ func TestBridgeEventE2E(t *testing.T) { // Trigger reorg if i%reorgEveryXIterations == 0 { blocksToReorg := 1 + i%maxReorgDepth - bn, err := env.L1Client.Client().BlockNumber(ctx) + bn, err := setup.L1Environment.SimBackend.Client().BlockNumber(ctx) require.NoError(t, err) - helpers.Reorg(t, env.L1Client, uint64(blocksToReorg)) + helpers.Reorg(t, setup.L1Environment.SimBackend, uint64(blocksToReorg)) // Clean expected bridges lastValidBlock := bn - uint64(blocksToReorg) reorgEffective := false @@ -90,20 +90,20 @@ func TestBridgeEventE2E(t *testing.T) { // Wait for syncer to catch up time.Sleep(time.Second * 2) // sleeping since the processor could be up to date, but have pending reorgs - lb, err := env.L1Client.Client().BlockNumber(ctx) + lb, err := setup.L1Environment.SimBackend.Client().BlockNumber(ctx) require.NoError(t, err) - helpers.RequireProcessorUpdated(t, env.BridgeL1Sync, lb) + helpers.RequireProcessorUpdated(t, setup.L1Environment.BridgeSync, lb) // Get bridges - lastBlock, err := env.L1Client.Client().BlockNumber(ctx) + lastBlock, err := setup.L1Environment.SimBackend.Client().BlockNumber(ctx) require.NoError(t, err) - actualBridges, err := env.BridgeL1Sync.GetBridges(ctx, 0, lastBlock) + actualBridges, err := setup.L1Environment.BridgeSync.GetBridges(ctx, 0, lastBlock) require.NoError(t, err) // Assert bridges - expectedRoot, err := env.BridgeL1Contract.GetRoot(nil) + expectedRoot, err := setup.L1Environment.BridgeContract.GetRoot(nil) require.NoError(t, err) - root, err := env.BridgeL1Sync.GetExitRootByIndex(ctx, expectedBridges[len(expectedBridges)-1].DepositCount) + root, err := setup.L1Environment.BridgeSync.GetExitRootByIndex(ctx, expectedBridges[len(expectedBridges)-1].DepositCount) require.NoError(t, err) require.Equal(t, common.Hash(expectedRoot).Hex(), root.Hash.Hex()) require.Equal(t, expectedBridges, actualBridges) diff --git a/claimsponsor/e2e_test.go b/claimsponsor/e2e_test.go index c06223b9..5ad332c0 100644 --- a/claimsponsor/e2e_test.go +++ b/claimsponsor/e2e_test.go @@ -21,19 +21,19 @@ import ( func TestE2EL1toEVML2(t *testing.T) { // start other needed components ctx := context.Background() - env := helpers.NewE2EEnvWithEVML2(t) + setup := helpers.NewE2EEnvWithEVML2(t) // start claim sponsor dbPathClaimSponsor := path.Join(t.TempDir(), "claimsponsorTestE2EL1toEVML2_cs.sqlite") claimer, err := claimsponsor.NewEVMClaimSponsor( log.GetDefaultLogger(), dbPathClaimSponsor, - env.L2Client.Client(), - env.BridgeL2Addr, - env.AuthL2.From, + setup.L2Environment.SimBackend.Client(), + setup.L2Environment.BridgeAddr, + setup.L2Environment.Auth.From, 200_000, 0, - env.EthTxManMockL2, + setup.EthTxManagerMock, 0, 0, time.Millisecond*10, time.Millisecond*10, ) require.NoError(t, err) @@ -43,26 +43,26 @@ func TestE2EL1toEVML2(t *testing.T) { for i := uint32(0); i < 3; i++ { // Send bridges to L2, wait for GER to be injected on L2 amount := new(big.Int).SetUint64(uint64(i) + 1) - env.AuthL1.Value = amount - _, err := env.BridgeL1Contract.BridgeAsset(env.AuthL1, env.NetworkIDL2, env.AuthL2.From, amount, common.Address{}, true, nil) + setup.L1Environment.Auth.Value = amount + _, err := setup.L1Environment.BridgeContract.BridgeAsset(setup.L1Environment.Auth, setup.NetworkIDL2, setup.L2Environment.Auth.From, amount, common.Address{}, true, nil) require.NoError(t, err) - env.L1Client.Commit() + setup.L1Environment.SimBackend.Commit() time.Sleep(time.Millisecond * 300) - expectedGER, err := env.GERL1Contract.GetLastGlobalExitRoot(&bind.CallOpts{Pending: false}) + expectedGER, err := setup.L1Environment.GERContract.GetLastGlobalExitRoot(&bind.CallOpts{Pending: false}) require.NoError(t, err) - isInjected, err := env.AggOracleSender.IsGERInjected(expectedGER) + isInjected, err := setup.L2Environment.AggoracleSender.IsGERInjected(expectedGER) require.NoError(t, err) require.True(t, isInjected, fmt.Sprintf("iteration %d, GER: %s", i, common.Bytes2Hex(expectedGER[:]))) - // Build MP using bridgeSyncL1 & env.L1InfoTreeSync - info, err := env.L1InfoTreeSync.GetInfoByIndex(ctx, i) + // Build MP using bridgeSyncL1 & env.InfoTreeSync + info, err := setup.L1Environment.InfoTreeSync.GetInfoByIndex(ctx, i) require.NoError(t, err) - localProof, err := env.BridgeL1Sync.GetProof(ctx, i, info.MainnetExitRoot) + localProof, err := setup.L1Environment.BridgeSync.GetProof(ctx, i, info.MainnetExitRoot) require.NoError(t, err) - rollupProof, err := env.L1InfoTreeSync.GetRollupExitTreeMerkleProof(ctx, 0, common.Hash{}) + rollupProof, err := setup.L1Environment.InfoTreeSync.GetRollupExitTreeMerkleProof(ctx, 0, common.Hash{}) require.NoError(t, err) // Request to sponsor claim @@ -76,8 +76,8 @@ func TestE2EL1toEVML2(t *testing.T) { RollupExitRoot: info.RollupExitRoot, OriginNetwork: 0, OriginTokenAddress: common.Address{}, - DestinationNetwork: env.NetworkIDL2, - DestinationAddress: env.AuthL2.From, + DestinationNetwork: setup.NetworkIDL2, + DestinationAddress: setup.L2Environment.Auth.From, Amount: amount, Metadata: nil, }) @@ -100,7 +100,7 @@ func TestE2EL1toEVML2(t *testing.T) { require.True(t, succeed) // Check on contract that is claimed - isClaimed, err := env.BridgeL2Contract.IsClaimed(&bind.CallOpts{Pending: false}, i, 0) + isClaimed, err := setup.L2Environment.BridgeContract.IsClaimed(&bind.CallOpts{Pending: false}, i, 0) require.NoError(t, err) require.True(t, isClaimed) } diff --git a/lastgersync/e2e_test.go b/lastgersync/e2e_test.go index ca956a20..b0782538 100644 --- a/lastgersync/e2e_test.go +++ b/lastgersync/e2e_test.go @@ -18,15 +18,15 @@ import ( func TestE2E(t *testing.T) { ctx := context.Background() - env := helpers.NewE2EEnvWithEVML2(t) + setup := helpers.NewE2EEnvWithEVML2(t) dbPathSyncer := path.Join(t.TempDir(), "lastgersyncTestE2E.sqlite") syncer, err := lastgersync.New( ctx, dbPathSyncer, - env.ReorgDetectorL2, - env.L2Client.Client(), - env.GERL2Addr, - env.L1InfoTreeSync, + setup.L2Environment.ReorgDetector, + setup.L2Environment.SimBackend.Client(), + setup.L2Environment.GERAddr, + setup.InfoTreeSync, 0, 0, etherman.LatestBlock, @@ -38,18 +38,18 @@ func TestE2E(t *testing.T) { for i := 0; i < 10; i++ { // Update GER on L1 - _, err := env.GERL1Contract.UpdateExitRoot(env.AuthL1, common.HexToHash(strconv.Itoa(i))) + _, err := setup.L1Environment.GERContract.UpdateExitRoot(setup.L1Environment.Auth, common.HexToHash(strconv.Itoa(i))) require.NoError(t, err) - env.L1Client.Commit() + setup.L1Environment.SimBackend.Commit() time.Sleep(time.Millisecond * 150) - expectedGER, err := env.GERL1Contract.GetLastGlobalExitRoot(&bind.CallOpts{Pending: false}) + expectedGER, err := setup.L1Environment.GERContract.GetLastGlobalExitRoot(&bind.CallOpts{Pending: false}) require.NoError(t, err) - isInjected, err := env.AggOracleSender.IsGERInjected(expectedGER) + isInjected, err := setup.AggoracleSender.IsGERInjected(expectedGER) require.NoError(t, err) require.True(t, isInjected, fmt.Sprintf("iteration %d, GER: %s", i, common.Bytes2Hex(expectedGER[:]))) // Wait for syncer to catch up - lb, err := env.L2Client.Client().BlockNumber(ctx) + lb, err := setup.L2Environment.SimBackend.Client().BlockNumber(ctx) require.NoError(t, err) helpers.RequireProcessorUpdated(t, syncer, lb) diff --git a/test/helpers/e2e.go b/test/helpers/e2e.go index efc45069..a0070885 100644 --- a/test/helpers/e2e.go +++ b/test/helpers/e2e.go @@ -33,32 +33,16 @@ const ( periodRetry = time.Millisecond * 100 ) -type AggoracleWithEVMChainEnv struct { - L1Client *simulated.Backend - L2Client *simulated.Backend - L1InfoTreeSync *l1infotreesync.L1InfoTreeSync - GERL1Contract *polygonzkevmglobalexitrootv2.Polygonzkevmglobalexitrootv2 - GERL1Addr common.Address - GERL2Contract *globalexitrootmanagerl2sovereignchain.Globalexitrootmanagerl2sovereignchain - GERL2Addr common.Address - AuthL1 *bind.TransactOpts - AuthL2 *bind.TransactOpts - AggOracle *aggoracle.AggOracle - AggOracleSender aggoracle.ChainSender - ReorgDetectorL1 *reorgdetector.ReorgDetector - ReorgDetectorL2 *reorgdetector.ReorgDetector - BridgeL1Contract *polygonzkevmbridgev2.Polygonzkevmbridgev2 - BridgeL1Addr common.Address - BridgeL1Sync *bridgesync.BridgeSync - BridgeL2Contract *polygonzkevmbridgev2.Polygonzkevmbridgev2 - BridgeL2Addr common.Address - BridgeL2Sync *bridgesync.BridgeSync - NetworkIDL2 uint32 - EthTxManMockL2 *EthTxManagerMock +type AggoracleWithEVMChain struct { + L1Environment + L2Environment + AggOracle *aggoracle.AggOracle + NetworkIDL2 uint32 } -type SetupResult struct { - Client *simulated.Backend +// CommonEnvironment contains common setup results used in both L1 and L2 network setups. +type CommonEnvironment struct { + SimBackend *simulated.Backend GERAddr common.Address BridgeContract *polygonzkevmbridgev2.Polygonzkevmbridgev2 BridgeAddr common.Address @@ -67,20 +51,23 @@ type SetupResult struct { BridgeSync *bridgesync.BridgeSync } -type L1SetupResult struct { - SetupResult +// L1Environment contains setup results for L1 network. +type L1Environment struct { + CommonEnvironment GERContract *polygonzkevmglobalexitrootv2.Polygonzkevmglobalexitrootv2 InfoTreeSync *l1infotreesync.L1InfoTreeSync } -type L2SetupResult struct { - SetupResult - GERContract *globalexitrootmanagerl2sovereignchain.Globalexitrootmanagerl2sovereignchain - AggoracleSender aggoracle.ChainSender - EthTxManMock *EthTxManagerMock +// L2Environment contains setup results for L1 network. +type L2Environment struct { + CommonEnvironment + GERContract *globalexitrootmanagerl2sovereignchain.Globalexitrootmanagerl2sovereignchain + AggoracleSender aggoracle.ChainSender + EthTxManagerMock *EthTxManagerMock } -func NewE2EEnvWithEVML2(t *testing.T) *AggoracleWithEVMChainEnv { +// NewE2EEnvWithEVML2 creates a new E2E environment with EVM L1 and L2 chains. +func NewE2EEnvWithEVML2(t *testing.T) *AggoracleWithEVMChain { t.Helper() ctx := context.Background() @@ -92,47 +79,22 @@ func NewE2EEnvWithEVML2(t *testing.T) *AggoracleWithEVMChainEnv { oracle, err := aggoracle.New( log.GetDefaultLogger(), l2Setup.AggoracleSender, - l1Setup.Client.Client(), l1Setup.InfoTreeSync, + l1Setup.SimBackend.Client(), l1Setup.InfoTreeSync, etherman.LatestBlock, time.Millisecond*20, //nolint:mnd ) require.NoError(t, err) go oracle.Start(ctx) - return &AggoracleWithEVMChainEnv{ - L1Client: l1Setup.Client, - L2Client: l2Setup.Client, - - L1InfoTreeSync: l1Setup.InfoTreeSync, - - GERL1Contract: l1Setup.GERContract, - GERL1Addr: l1Setup.GERAddr, - - GERL2Contract: l2Setup.GERContract, - GERL2Addr: l2Setup.GERAddr, - - AuthL1: l1Setup.Auth, - AuthL2: l2Setup.Auth, - - AggOracle: oracle, - AggOracleSender: l2Setup.AggoracleSender, - - ReorgDetectorL1: l1Setup.ReorgDetector, - ReorgDetectorL2: l2Setup.ReorgDetector, - - BridgeL1Contract: l1Setup.BridgeContract, - BridgeL1Addr: l1Setup.BridgeAddr, - BridgeL1Sync: l1Setup.BridgeSync, - - BridgeL2Contract: l2Setup.BridgeContract, - BridgeL2Addr: l2Setup.BridgeAddr, - BridgeL2Sync: l2Setup.BridgeSync, - - NetworkIDL2: rollupID, - EthTxManMockL2: l2Setup.EthTxManMock, + return &AggoracleWithEVMChain{ + L1Environment: *l1Setup, + L2Environment: *l2Setup, + AggOracle: oracle, + NetworkIDL2: rollupID, } } -func L1Setup(t *testing.T) *L1SetupResult { +// L1Setup creates a new L1 environment. +func L1Setup(t *testing.T) *L1Environment { t.Helper() ctx := context.Background() @@ -181,9 +143,9 @@ func L1Setup(t *testing.T) *L1SetupResult { go bridgeL1Sync.Start(ctx) - return &L1SetupResult{ - SetupResult: SetupResult{ - Client: l1Client, + return &L1Environment{ + CommonEnvironment: CommonEnvironment{ + SimBackend: l1Client, GERAddr: gerL1Addr, BridgeContract: bridgeL1Contract, BridgeAddr: bridgeL1Addr, @@ -196,18 +158,19 @@ func L1Setup(t *testing.T) *L1SetupResult { } } -func L2Setup(t *testing.T) *L2SetupResult { +// L2Setup creates a new L2 environment. +func L2Setup(t *testing.T) *L2Environment { t.Helper() l2Client, authL2, gerL2Addr, gerL2Contract, bridgeL2Addr, bridgeL2Contract := newSimulatedEVML2SovereignChain(t) - ethTxManMock := NewEthTxManMock(t, l2Client, authL2) + ethTxManagerMock := NewEthTxManMock(t, l2Client, authL2) const gerCheckFrequency = time.Millisecond * 50 sender, err := chaingersender.NewEVMChainGERSender( log.GetDefaultLogger(), gerL2Addr, l2Client.Client(), - ethTxManMock, 0, gerCheckFrequency, + ethTxManagerMock, 0, gerCheckFrequency, ) require.NoError(t, err) ctx := context.Background() @@ -240,9 +203,9 @@ func L2Setup(t *testing.T) *L2SetupResult { go bridgeL2Sync.Start(ctx) - return &L2SetupResult{ - SetupResult: SetupResult{ - Client: l2Client, + return &L2Environment{ + CommonEnvironment: CommonEnvironment{ + SimBackend: l2Client, GERAddr: gerL2Addr, BridgeContract: bridgeL2Contract, BridgeAddr: bridgeL2Addr, @@ -250,9 +213,9 @@ func L2Setup(t *testing.T) *L2SetupResult { ReorgDetector: rdL2, BridgeSync: bridgeL2Sync, }, - GERContract: gerL2Contract, - AggoracleSender: sender, - EthTxManMock: ethTxManMock, + GERContract: gerL2Contract, + AggoracleSender: sender, + EthTxManagerMock: ethTxManagerMock, } } From 6f9cb74ca6c2f80a36655924a0dc31d1c7d9aa33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Thu, 19 Dec 2024 11:11:26 +0100 Subject: [PATCH 14/21] fix: update import paths for l2-sovereign-chain contracts and use the Shanghai spec --- aggoracle/chaingersender/evm.go | 2 +- bridgesync/downloader.go | 2 +- claimsponsor/evmclaimsponsor.go | 2 +- dataavailability/datacommittee/datacommittee_test.go | 3 +-- etherman/etherman.go | 2 +- go.mod | 2 +- go.sum | 2 ++ l1infotreesync/downloader.go | 2 +- l1infotreesync/downloader_test.go | 2 +- l1infotreesync/e2e_test.go | 2 +- lastgersync/evmdownloader.go | 2 +- test/helpers/e2e.go | 6 +++--- test/helpers/simulated.go | 2 +- 13 files changed, 16 insertions(+), 15 deletions(-) diff --git a/aggoracle/chaingersender/evm.go b/aggoracle/chaingersender/evm.go index ef9e1b75..fe5e221d 100644 --- a/aggoracle/chaingersender/evm.go +++ b/aggoracle/chaingersender/evm.go @@ -6,7 +6,7 @@ import ( "math/big" "time" - "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain-paris/globalexitrootmanagerl2sovereignchain" + "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain/globalexitrootmanagerl2sovereignchain" cdkcommon "github.com/0xPolygon/cdk/common" cfgtypes "github.com/0xPolygon/cdk/config/types" "github.com/0xPolygon/cdk/log" diff --git a/bridgesync/downloader.go b/bridgesync/downloader.go index 4b774401..3756c970 100644 --- a/bridgesync/downloader.go +++ b/bridgesync/downloader.go @@ -7,7 +7,7 @@ import ( "strings" "github.com/0xPolygon/cdk-contracts-tooling/contracts/etrog/polygonzkevmbridge" - "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain-paris/polygonzkevmbridgev2" + "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain/polygonzkevmbridgev2" rpcTypes "github.com/0xPolygon/cdk-rpc/types" "github.com/0xPolygon/cdk/db" "github.com/0xPolygon/cdk/sync" diff --git a/claimsponsor/evmclaimsponsor.go b/claimsponsor/evmclaimsponsor.go index d8fbfb22..8915c683 100644 --- a/claimsponsor/evmclaimsponsor.go +++ b/claimsponsor/evmclaimsponsor.go @@ -6,7 +6,7 @@ import ( "math/big" "time" - "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain-paris/polygonzkevmbridgev2" + "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain/polygonzkevmbridgev2" configTypes "github.com/0xPolygon/cdk/config/types" "github.com/0xPolygon/cdk/log" "github.com/0xPolygon/zkevm-ethtx-manager/ethtxmanager" diff --git a/dataavailability/datacommittee/datacommittee_test.go b/dataavailability/datacommittee/datacommittee_test.go index 63d04c57..ac138b44 100644 --- a/dataavailability/datacommittee/datacommittee_test.go +++ b/dataavailability/datacommittee/datacommittee_test.go @@ -5,7 +5,6 @@ import ( "math/big" "testing" - scparis "github.com/0xPolygon/cdk-contracts-tooling/contracts/banana-paris/polygondatacommittee" "github.com/0xPolygon/cdk-contracts-tooling/contracts/banana/polygondatacommittee" "github.com/0xPolygon/cdk/log" "github.com/0xPolygon/cdk/test/contracts/erc1967proxy" @@ -79,7 +78,7 @@ func newSimulatedDACBackend(t *testing.T) ( ethBackend, setup := helpers.NewSimulatedBackend(t, nil, deployerAuth) // DAC Setup - addr, _, _, err := scparis.DeployPolygondatacommittee(setup.UserAuth, ethBackend.Client()) + addr, _, _, err := polygondatacommittee.DeployPolygondatacommittee(setup.UserAuth, ethBackend.Client()) require.NoError(t, err) ethBackend.Commit() diff --git a/etherman/etherman.go b/etherman/etherman.go index 2736897d..fa003303 100644 --- a/etherman/etherman.go +++ b/etherman/etherman.go @@ -10,7 +10,7 @@ import ( "path/filepath" "time" - "github.com/0xPolygon/cdk-contracts-tooling/contracts/banana/idataavailabilityprotocol" + "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain/idataavailabilityprotocol" cdkcommon "github.com/0xPolygon/cdk/common" "github.com/0xPolygon/cdk/etherman/config" "github.com/0xPolygon/cdk/etherman/contracts" diff --git a/go.mod b/go.mod index 2444cba6..a1674925 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/0xPolygon/cdk go 1.22.4 require ( - github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20241217070745-faeedeaaea77 + github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20241219094120-7a2d1f4d7b9b github.com/0xPolygon/cdk-data-availability v0.0.11 github.com/0xPolygon/cdk-rpc v0.0.0-20241004114257-6c3cb6eebfb6 github.com/0xPolygon/zkevm-ethtx-manager v0.2.1 diff --git a/go.sum b/go.sum index 69b3f541..415f5502 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,7 @@ github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20241217070745-faeedeaaea77 h1:EEPwISL8b1mIh0k7l0/2b2MxzbHfakkIUdFNKiD+dwg= github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20241217070745-faeedeaaea77/go.mod h1:mFlcEjsm2YBBsu8atHJ3zyVnwM+Z/fMXpVmIJge+WVU= +github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20241219094120-7a2d1f4d7b9b h1:d5GAidL7MokCpNj2QN2jEPnSbvL9cHrupCMZOttlCeE= +github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20241219094120-7a2d1f4d7b9b/go.mod h1:mFlcEjsm2YBBsu8atHJ3zyVnwM+Z/fMXpVmIJge+WVU= github.com/0xPolygon/cdk-data-availability v0.0.10 h1:pVcke2I7GuPH7JeRLKokEOHffPMwEHmJd9yDXHqh9B4= github.com/0xPolygon/cdk-data-availability v0.0.10/go.mod h1:nn5RmnkzOiugAxizSbaYnA+em79YLLLoR25i0UlKc5Q= github.com/0xPolygon/cdk-data-availability v0.0.11 h1:enmlyFYCvmDmcX/2fnDjWnn3svqqm9o2Fe+Kupoykdo= diff --git a/l1infotreesync/downloader.go b/l1infotreesync/downloader.go index 9521c726..48e23702 100644 --- a/l1infotreesync/downloader.go +++ b/l1infotreesync/downloader.go @@ -3,8 +3,8 @@ package l1infotreesync import ( "fmt" - "github.com/0xPolygon/cdk-contracts-tooling/contracts/banana/polygonzkevmglobalexitrootv2" "github.com/0xPolygon/cdk-contracts-tooling/contracts/etrog/polygonrollupmanager" + "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain/polygonzkevmglobalexitrootv2" "github.com/0xPolygon/cdk/log" "github.com/0xPolygon/cdk/sync" "github.com/ethereum/go-ethereum" diff --git a/l1infotreesync/downloader_test.go b/l1infotreesync/downloader_test.go index 6007a3d6..9d79b9a6 100644 --- a/l1infotreesync/downloader_test.go +++ b/l1infotreesync/downloader_test.go @@ -6,7 +6,7 @@ import ( "strings" "testing" - "github.com/0xPolygon/cdk-contracts-tooling/contracts/banana/polygonzkevmglobalexitrootv2" + "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain/polygonzkevmglobalexitrootv2" mocks_l1infotreesync "github.com/0xPolygon/cdk/l1infotreesync/mocks" "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" diff --git a/l1infotreesync/e2e_test.go b/l1infotreesync/e2e_test.go index 7b5c7be8..ee4f464f 100644 --- a/l1infotreesync/e2e_test.go +++ b/l1infotreesync/e2e_test.go @@ -9,7 +9,7 @@ import ( "testing" "time" - "github.com/0xPolygon/cdk-contracts-tooling/contracts/banana-paris/polygonzkevmglobalexitrootv2" + "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain/polygonzkevmglobalexitrootv2" cdktypes "github.com/0xPolygon/cdk/config/types" "github.com/0xPolygon/cdk/etherman" "github.com/0xPolygon/cdk/l1infotreesync" diff --git a/lastgersync/evmdownloader.go b/lastgersync/evmdownloader.go index 819a52bd..9a203b59 100644 --- a/lastgersync/evmdownloader.go +++ b/lastgersync/evmdownloader.go @@ -7,7 +7,7 @@ import ( "math/big" "time" - "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain-paris/globalexitrootmanagerl2sovereignchain" + "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain/globalexitrootmanagerl2sovereignchain" cdkcommon "github.com/0xPolygon/cdk/common" "github.com/0xPolygon/cdk/db" "github.com/0xPolygon/cdk/l1infotreesync" diff --git a/test/helpers/e2e.go b/test/helpers/e2e.go index a0070885..fc6b1d4f 100644 --- a/test/helpers/e2e.go +++ b/test/helpers/e2e.go @@ -7,9 +7,9 @@ import ( "testing" "time" - "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain-paris/globalexitrootmanagerl2sovereignchain" - "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain-paris/polygonzkevmbridgev2" - "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain-paris/polygonzkevmglobalexitrootv2" + "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain/globalexitrootmanagerl2sovereignchain" + "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain/polygonzkevmbridgev2" + "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain/polygonzkevmglobalexitrootv2" "github.com/0xPolygon/cdk/aggoracle" "github.com/0xPolygon/cdk/aggoracle/chaingersender" "github.com/0xPolygon/cdk/bridgesync" diff --git a/test/helpers/simulated.go b/test/helpers/simulated.go index 4c283bf3..2b0b0dac 100644 --- a/test/helpers/simulated.go +++ b/test/helpers/simulated.go @@ -7,7 +7,7 @@ import ( "math/big" "testing" - "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain-paris/polygonzkevmbridgev2" + "github.com/0xPolygon/cdk-contracts-tooling/contracts/l2-sovereign-chain/polygonzkevmbridgev2" "github.com/0xPolygon/cdk/log" "github.com/0xPolygon/cdk/test/contracts/transparentupgradableproxy" "github.com/ethereum/go-ethereum/accounts/abi/bind" From f7e69de54eabf91a14c8ee6b2197d73daebabb7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Thu, 19 Dec 2024 11:27:40 +0100 Subject: [PATCH 15/21] refactor: rename waitTxToBeSuccessOrFail to waitForTxResult and update logging messages --- claimsponsor/claimsponsor.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/claimsponsor/claimsponsor.go b/claimsponsor/claimsponsor.go index 73d08eb7..e93f1898 100644 --- a/claimsponsor/claimsponsor.go +++ b/claimsponsor/claimsponsor.go @@ -146,12 +146,12 @@ func (c *ClaimSponsor) claim(ctx context.Context) error { } } - c.logger.Infof("waiting for tx %s with global index %s", claim.TxID, claim.GlobalIndex.String()) - status, err := c.waitTxToBeSuccessOrFail(ctx, claim.TxID) + c.logger.Infof("waiting for tx %s with global index %s to be processed", claim.TxID, claim.GlobalIndex.String()) + status, err := c.waitForTxResult(ctx, claim.TxID) if err != nil { - return fmt.Errorf("error calling waitTxToBeSuccessOrFail for tx %s: %w", claim.TxID, err) + return fmt.Errorf("error calling waitForTxResult for tx %s: %w", claim.TxID, err) } - c.logger.Infof("tx %s with global index %s concluded with status: %s", claim.TxID, claim.GlobalIndex.String(), status) + c.logger.Infof("tx %s with global index %s is processed, status: %s", claim.TxID, claim.GlobalIndex.String(), status) return c.updateClaimStatus(claim.GlobalIndex, status) } @@ -211,7 +211,7 @@ func (c *ClaimSponsor) updateClaimStatus(globalIndex *big.Int, status ClaimStatu return nil } -func (c *ClaimSponsor) waitTxToBeSuccessOrFail(ctx context.Context, txID string) (ClaimStatus, error) { +func (c *ClaimSponsor) waitForTxResult(ctx context.Context, txID string) (ClaimStatus, error) { ticker := time.NewTicker(c.waitTxToBeMinedPeriod) defer ticker.Stop() @@ -224,6 +224,7 @@ func (c *ClaimSponsor) waitTxToBeSuccessOrFail(ctx context.Context, txID string) if err != nil { return "", err } + if status == FailedClaimStatus || status == SuccessClaimStatus { return status, nil } From fca049df2a5f0334a16fcec8eda944c8c3ec57b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Thu, 19 Dec 2024 11:59:11 +0100 Subject: [PATCH 16/21] chore: update cdk-contracts-tooling dependency to v0.0.1 --- go.mod | 2 +- go.sum | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index a1674925..9e3e8964 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/0xPolygon/cdk go 1.22.4 require ( - github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20241219094120-7a2d1f4d7b9b + github.com/0xPolygon/cdk-contracts-tooling v0.0.1 github.com/0xPolygon/cdk-data-availability v0.0.11 github.com/0xPolygon/cdk-rpc v0.0.0-20241004114257-6c3cb6eebfb6 github.com/0xPolygon/zkevm-ethtx-manager v0.2.1 diff --git a/go.sum b/go.sum index 415f5502..7baf269b 100644 --- a/go.sum +++ b/go.sum @@ -1,7 +1,5 @@ -github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20241217070745-faeedeaaea77 h1:EEPwISL8b1mIh0k7l0/2b2MxzbHfakkIUdFNKiD+dwg= -github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20241217070745-faeedeaaea77/go.mod h1:mFlcEjsm2YBBsu8atHJ3zyVnwM+Z/fMXpVmIJge+WVU= -github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20241219094120-7a2d1f4d7b9b h1:d5GAidL7MokCpNj2QN2jEPnSbvL9cHrupCMZOttlCeE= -github.com/0xPolygon/cdk-contracts-tooling v0.0.0-20241219094120-7a2d1f4d7b9b/go.mod h1:mFlcEjsm2YBBsu8atHJ3zyVnwM+Z/fMXpVmIJge+WVU= +github.com/0xPolygon/cdk-contracts-tooling v0.0.1 h1:2HH8KpO1CZRl1zHfn0IYwJhPA7l91DOWrjdExmaB9Kk= +github.com/0xPolygon/cdk-contracts-tooling v0.0.1/go.mod h1:mFlcEjsm2YBBsu8atHJ3zyVnwM+Z/fMXpVmIJge+WVU= github.com/0xPolygon/cdk-data-availability v0.0.10 h1:pVcke2I7GuPH7JeRLKokEOHffPMwEHmJd9yDXHqh9B4= github.com/0xPolygon/cdk-data-availability v0.0.10/go.mod h1:nn5RmnkzOiugAxizSbaYnA+em79YLLLoR25i0UlKc5Q= github.com/0xPolygon/cdk-data-availability v0.0.11 h1:enmlyFYCvmDmcX/2fnDjWnn3svqqm9o2Fe+Kupoykdo= From 1a95a1ed82cdad3381d8f73f0e401fd745903ac2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Fri, 20 Dec 2024 12:29:32 +0100 Subject: [PATCH 17/21] fix: remove duplicated recipes in test/makefile --- agglayer/mock_agglayer_client.go | 2 +- aggregator/mocks/mock_eth_tx_manager.go | 335 ++++++++++++++- aggregator/mocks/mock_etherman.go | 185 ++++++++- aggregator/mocks/mock_prover.go | 270 ++++++++++++- aggregator/mocks/mock_rpc.go | 67 ++- aggregator/mocks/mock_storage.go | 368 ++++++++++++++++- aggregator/mocks/mock_synchronizer.go | 382 +++++++++++++++++- aggregator/mocks/mock_txer.go | 232 ++++++++++- aggregator/prover/mocks/mock_channel.go | 236 ++++++++++- aggsender/mocks/agg_sender_storage.go | 2 +- aggsender/mocks/block_notifier.go | 2 +- aggsender/mocks/epoch_notifier.go | 4 +- aggsender/mocks/generic_subscriber.go | 2 +- aggsender/mocks/l2_bridge_syncer.go | 4 +- aggsender/mocks/logger.go | 18 +- bridgesync/mocks/bridge_contractor.go | 93 ----- bridgesync/mocks/eth_clienter.go | 2 +- dataavailability/mocks_da/da_backender.go | 2 +- l1infotreesync/mocks/eth_clienter.go | 2 +- l1infotreesync/mocks/mock_reorgdetector.go | 69 +++- reorgdetector/mock_eth_client.go | 97 ++++- sequencesender/mocks/mock_etherman.go | 128 +++++- sequencesender/mocks/mock_ethtxmanager.go | 160 +++++++- sequencesender/mocks/mock_rpc.go | 67 ++- .../global_exit_root_banana_contractor.go | 2 +- ...lobal_exit_root_banana_zkevm_contractor.go | 2 +- .../txbuilder/mocks_txbuilder/tx_builder.go | 2 +- sync/mock_downloader_test.go | 2 +- test/Makefile | 56 ++- test/helpers/mock_ethtxmanager.go | 156 ++++++- 30 files changed, 2760 insertions(+), 189 deletions(-) delete mode 100644 bridgesync/mocks/bridge_contractor.go diff --git a/agglayer/mock_agglayer_client.go b/agglayer/mock_agglayer_client.go index 6c5a3fbf..8b8c8689 100644 --- a/agglayer/mock_agglayer_client.go +++ b/agglayer/mock_agglayer_client.go @@ -81,7 +81,7 @@ func (_c *AgglayerClientMock_GetCertificateHeader_Call) RunAndReturn(run func(co return _c } -// GetEpochConfiguration provides a mock function with given fields: +// GetEpochConfiguration provides a mock function with no fields func (_m *AgglayerClientMock) GetEpochConfiguration() (*ClockConfiguration, error) { ret := _m.Called() diff --git a/aggregator/mocks/mock_eth_tx_manager.go b/aggregator/mocks/mock_eth_tx_manager.go index 8db7a440..47dabe1c 100644 --- a/aggregator/mocks/mock_eth_tx_manager.go +++ b/aggregator/mocks/mock_eth_tx_manager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.0. DO NOT EDIT. +// Code generated by mockery. DO NOT EDIT. package mocks @@ -24,6 +24,14 @@ type EthTxManagerClientMock struct { mock.Mock } +type EthTxManagerClientMock_Expecter struct { + mock *mock.Mock +} + +func (_m *EthTxManagerClientMock) EXPECT() *EthTxManagerClientMock_Expecter { + return &EthTxManagerClientMock_Expecter{mock: &_m.Mock} +} + // Add provides a mock function with given fields: ctx, to, value, data, gasOffset, sidecar func (_m *EthTxManagerClientMock) Add(ctx context.Context, to *common.Address, value *big.Int, data []byte, gasOffset uint64, sidecar *types.BlobTxSidecar) (common.Hash, error) { ret := _m.Called(ctx, to, value, data, gasOffset, sidecar) @@ -54,6 +62,39 @@ func (_m *EthTxManagerClientMock) Add(ctx context.Context, to *common.Address, v return r0, r1 } +// EthTxManagerClientMock_Add_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Add' +type EthTxManagerClientMock_Add_Call struct { + *mock.Call +} + +// Add is a helper method to define mock.On call +// - ctx context.Context +// - to *common.Address +// - value *big.Int +// - data []byte +// - gasOffset uint64 +// - sidecar *types.BlobTxSidecar +func (_e *EthTxManagerClientMock_Expecter) Add(ctx interface{}, to interface{}, value interface{}, data interface{}, gasOffset interface{}, sidecar interface{}) *EthTxManagerClientMock_Add_Call { + return &EthTxManagerClientMock_Add_Call{Call: _e.mock.On("Add", ctx, to, value, data, gasOffset, sidecar)} +} + +func (_c *EthTxManagerClientMock_Add_Call) Run(run func(ctx context.Context, to *common.Address, value *big.Int, data []byte, gasOffset uint64, sidecar *types.BlobTxSidecar)) *EthTxManagerClientMock_Add_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*common.Address), args[2].(*big.Int), args[3].([]byte), args[4].(uint64), args[5].(*types.BlobTxSidecar)) + }) + return _c +} + +func (_c *EthTxManagerClientMock_Add_Call) Return(_a0 common.Hash, _a1 error) *EthTxManagerClientMock_Add_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EthTxManagerClientMock_Add_Call) RunAndReturn(run func(context.Context, *common.Address, *big.Int, []byte, uint64, *types.BlobTxSidecar) (common.Hash, error)) *EthTxManagerClientMock_Add_Call { + _c.Call.Return(run) + return _c +} + // AddWithGas provides a mock function with given fields: ctx, to, value, data, gasOffset, sidecar, gas func (_m *EthTxManagerClientMock) AddWithGas(ctx context.Context, to *common.Address, value *big.Int, data []byte, gasOffset uint64, sidecar *types.BlobTxSidecar, gas uint64) (common.Hash, error) { ret := _m.Called(ctx, to, value, data, gasOffset, sidecar, gas) @@ -84,6 +125,40 @@ func (_m *EthTxManagerClientMock) AddWithGas(ctx context.Context, to *common.Add return r0, r1 } +// EthTxManagerClientMock_AddWithGas_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddWithGas' +type EthTxManagerClientMock_AddWithGas_Call struct { + *mock.Call +} + +// AddWithGas is a helper method to define mock.On call +// - ctx context.Context +// - to *common.Address +// - value *big.Int +// - data []byte +// - gasOffset uint64 +// - sidecar *types.BlobTxSidecar +// - gas uint64 +func (_e *EthTxManagerClientMock_Expecter) AddWithGas(ctx interface{}, to interface{}, value interface{}, data interface{}, gasOffset interface{}, sidecar interface{}, gas interface{}) *EthTxManagerClientMock_AddWithGas_Call { + return &EthTxManagerClientMock_AddWithGas_Call{Call: _e.mock.On("AddWithGas", ctx, to, value, data, gasOffset, sidecar, gas)} +} + +func (_c *EthTxManagerClientMock_AddWithGas_Call) Run(run func(ctx context.Context, to *common.Address, value *big.Int, data []byte, gasOffset uint64, sidecar *types.BlobTxSidecar, gas uint64)) *EthTxManagerClientMock_AddWithGas_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*common.Address), args[2].(*big.Int), args[3].([]byte), args[4].(uint64), args[5].(*types.BlobTxSidecar), args[6].(uint64)) + }) + return _c +} + +func (_c *EthTxManagerClientMock_AddWithGas_Call) Return(_a0 common.Hash, _a1 error) *EthTxManagerClientMock_AddWithGas_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EthTxManagerClientMock_AddWithGas_Call) RunAndReturn(run func(context.Context, *common.Address, *big.Int, []byte, uint64, *types.BlobTxSidecar, uint64) (common.Hash, error)) *EthTxManagerClientMock_AddWithGas_Call { + _c.Call.Return(run) + return _c +} + // EncodeBlobData provides a mock function with given fields: data func (_m *EthTxManagerClientMock) EncodeBlobData(data []byte) (kzg4844.Blob, error) { ret := _m.Called(data) @@ -114,6 +189,34 @@ func (_m *EthTxManagerClientMock) EncodeBlobData(data []byte) (kzg4844.Blob, err return r0, r1 } +// EthTxManagerClientMock_EncodeBlobData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EncodeBlobData' +type EthTxManagerClientMock_EncodeBlobData_Call struct { + *mock.Call +} + +// EncodeBlobData is a helper method to define mock.On call +// - data []byte +func (_e *EthTxManagerClientMock_Expecter) EncodeBlobData(data interface{}) *EthTxManagerClientMock_EncodeBlobData_Call { + return &EthTxManagerClientMock_EncodeBlobData_Call{Call: _e.mock.On("EncodeBlobData", data)} +} + +func (_c *EthTxManagerClientMock_EncodeBlobData_Call) Run(run func(data []byte)) *EthTxManagerClientMock_EncodeBlobData_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].([]byte)) + }) + return _c +} + +func (_c *EthTxManagerClientMock_EncodeBlobData_Call) Return(_a0 kzg4844.Blob, _a1 error) *EthTxManagerClientMock_EncodeBlobData_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EthTxManagerClientMock_EncodeBlobData_Call) RunAndReturn(run func([]byte) (kzg4844.Blob, error)) *EthTxManagerClientMock_EncodeBlobData_Call { + _c.Call.Return(run) + return _c +} + // MakeBlobSidecar provides a mock function with given fields: blobs func (_m *EthTxManagerClientMock) MakeBlobSidecar(blobs []kzg4844.Blob) *types.BlobTxSidecar { ret := _m.Called(blobs) @@ -134,11 +237,68 @@ func (_m *EthTxManagerClientMock) MakeBlobSidecar(blobs []kzg4844.Blob) *types.B return r0 } +// EthTxManagerClientMock_MakeBlobSidecar_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'MakeBlobSidecar' +type EthTxManagerClientMock_MakeBlobSidecar_Call struct { + *mock.Call +} + +// MakeBlobSidecar is a helper method to define mock.On call +// - blobs []kzg4844.Blob +func (_e *EthTxManagerClientMock_Expecter) MakeBlobSidecar(blobs interface{}) *EthTxManagerClientMock_MakeBlobSidecar_Call { + return &EthTxManagerClientMock_MakeBlobSidecar_Call{Call: _e.mock.On("MakeBlobSidecar", blobs)} +} + +func (_c *EthTxManagerClientMock_MakeBlobSidecar_Call) Run(run func(blobs []kzg4844.Blob)) *EthTxManagerClientMock_MakeBlobSidecar_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].([]kzg4844.Blob)) + }) + return _c +} + +func (_c *EthTxManagerClientMock_MakeBlobSidecar_Call) Return(_a0 *types.BlobTxSidecar) *EthTxManagerClientMock_MakeBlobSidecar_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EthTxManagerClientMock_MakeBlobSidecar_Call) RunAndReturn(run func([]kzg4844.Blob) *types.BlobTxSidecar) *EthTxManagerClientMock_MakeBlobSidecar_Call { + _c.Call.Return(run) + return _c +} + // ProcessPendingMonitoredTxs provides a mock function with given fields: ctx, resultHandler func (_m *EthTxManagerClientMock) ProcessPendingMonitoredTxs(ctx context.Context, resultHandler ethtxmanager.ResultHandler) { _m.Called(ctx, resultHandler) } +// EthTxManagerClientMock_ProcessPendingMonitoredTxs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ProcessPendingMonitoredTxs' +type EthTxManagerClientMock_ProcessPendingMonitoredTxs_Call struct { + *mock.Call +} + +// ProcessPendingMonitoredTxs is a helper method to define mock.On call +// - ctx context.Context +// - resultHandler ethtxmanager.ResultHandler +func (_e *EthTxManagerClientMock_Expecter) ProcessPendingMonitoredTxs(ctx interface{}, resultHandler interface{}) *EthTxManagerClientMock_ProcessPendingMonitoredTxs_Call { + return &EthTxManagerClientMock_ProcessPendingMonitoredTxs_Call{Call: _e.mock.On("ProcessPendingMonitoredTxs", ctx, resultHandler)} +} + +func (_c *EthTxManagerClientMock_ProcessPendingMonitoredTxs_Call) Run(run func(ctx context.Context, resultHandler ethtxmanager.ResultHandler)) *EthTxManagerClientMock_ProcessPendingMonitoredTxs_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(ethtxmanager.ResultHandler)) + }) + return _c +} + +func (_c *EthTxManagerClientMock_ProcessPendingMonitoredTxs_Call) Return() *EthTxManagerClientMock_ProcessPendingMonitoredTxs_Call { + _c.Call.Return() + return _c +} + +func (_c *EthTxManagerClientMock_ProcessPendingMonitoredTxs_Call) RunAndReturn(run func(context.Context, ethtxmanager.ResultHandler)) *EthTxManagerClientMock_ProcessPendingMonitoredTxs_Call { + _c.Run(run) + return _c +} + // Remove provides a mock function with given fields: ctx, id func (_m *EthTxManagerClientMock) Remove(ctx context.Context, id common.Hash) error { ret := _m.Called(ctx, id) @@ -157,6 +317,35 @@ func (_m *EthTxManagerClientMock) Remove(ctx context.Context, id common.Hash) er return r0 } +// EthTxManagerClientMock_Remove_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Remove' +type EthTxManagerClientMock_Remove_Call struct { + *mock.Call +} + +// Remove is a helper method to define mock.On call +// - ctx context.Context +// - id common.Hash +func (_e *EthTxManagerClientMock_Expecter) Remove(ctx interface{}, id interface{}) *EthTxManagerClientMock_Remove_Call { + return &EthTxManagerClientMock_Remove_Call{Call: _e.mock.On("Remove", ctx, id)} +} + +func (_c *EthTxManagerClientMock_Remove_Call) Run(run func(ctx context.Context, id common.Hash)) *EthTxManagerClientMock_Remove_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(common.Hash)) + }) + return _c +} + +func (_c *EthTxManagerClientMock_Remove_Call) Return(_a0 error) *EthTxManagerClientMock_Remove_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EthTxManagerClientMock_Remove_Call) RunAndReturn(run func(context.Context, common.Hash) error) *EthTxManagerClientMock_Remove_Call { + _c.Call.Return(run) + return _c +} + // RemoveAll provides a mock function with given fields: ctx func (_m *EthTxManagerClientMock) RemoveAll(ctx context.Context) error { ret := _m.Called(ctx) @@ -175,6 +364,34 @@ func (_m *EthTxManagerClientMock) RemoveAll(ctx context.Context) error { return r0 } +// EthTxManagerClientMock_RemoveAll_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveAll' +type EthTxManagerClientMock_RemoveAll_Call struct { + *mock.Call +} + +// RemoveAll is a helper method to define mock.On call +// - ctx context.Context +func (_e *EthTxManagerClientMock_Expecter) RemoveAll(ctx interface{}) *EthTxManagerClientMock_RemoveAll_Call { + return &EthTxManagerClientMock_RemoveAll_Call{Call: _e.mock.On("RemoveAll", ctx)} +} + +func (_c *EthTxManagerClientMock_RemoveAll_Call) Run(run func(ctx context.Context)) *EthTxManagerClientMock_RemoveAll_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *EthTxManagerClientMock_RemoveAll_Call) Return(_a0 error) *EthTxManagerClientMock_RemoveAll_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EthTxManagerClientMock_RemoveAll_Call) RunAndReturn(run func(context.Context) error) *EthTxManagerClientMock_RemoveAll_Call { + _c.Call.Return(run) + return _c +} + // Result provides a mock function with given fields: ctx, id func (_m *EthTxManagerClientMock) Result(ctx context.Context, id common.Hash) (zkevm_ethtx_managertypes.MonitoredTxResult, error) { ret := _m.Called(ctx, id) @@ -203,6 +420,35 @@ func (_m *EthTxManagerClientMock) Result(ctx context.Context, id common.Hash) (z return r0, r1 } +// EthTxManagerClientMock_Result_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Result' +type EthTxManagerClientMock_Result_Call struct { + *mock.Call +} + +// Result is a helper method to define mock.On call +// - ctx context.Context +// - id common.Hash +func (_e *EthTxManagerClientMock_Expecter) Result(ctx interface{}, id interface{}) *EthTxManagerClientMock_Result_Call { + return &EthTxManagerClientMock_Result_Call{Call: _e.mock.On("Result", ctx, id)} +} + +func (_c *EthTxManagerClientMock_Result_Call) Run(run func(ctx context.Context, id common.Hash)) *EthTxManagerClientMock_Result_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(common.Hash)) + }) + return _c +} + +func (_c *EthTxManagerClientMock_Result_Call) Return(_a0 zkevm_ethtx_managertypes.MonitoredTxResult, _a1 error) *EthTxManagerClientMock_Result_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EthTxManagerClientMock_Result_Call) RunAndReturn(run func(context.Context, common.Hash) (zkevm_ethtx_managertypes.MonitoredTxResult, error)) *EthTxManagerClientMock_Result_Call { + _c.Call.Return(run) + return _c +} + // ResultsByStatus provides a mock function with given fields: ctx, statuses func (_m *EthTxManagerClientMock) ResultsByStatus(ctx context.Context, statuses []zkevm_ethtx_managertypes.MonitoredTxStatus) ([]zkevm_ethtx_managertypes.MonitoredTxResult, error) { ret := _m.Called(ctx, statuses) @@ -233,16 +479,99 @@ func (_m *EthTxManagerClientMock) ResultsByStatus(ctx context.Context, statuses return r0, r1 } -// Start provides a mock function with given fields: +// EthTxManagerClientMock_ResultsByStatus_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ResultsByStatus' +type EthTxManagerClientMock_ResultsByStatus_Call struct { + *mock.Call +} + +// ResultsByStatus is a helper method to define mock.On call +// - ctx context.Context +// - statuses []zkevm_ethtx_managertypes.MonitoredTxStatus +func (_e *EthTxManagerClientMock_Expecter) ResultsByStatus(ctx interface{}, statuses interface{}) *EthTxManagerClientMock_ResultsByStatus_Call { + return &EthTxManagerClientMock_ResultsByStatus_Call{Call: _e.mock.On("ResultsByStatus", ctx, statuses)} +} + +func (_c *EthTxManagerClientMock_ResultsByStatus_Call) Run(run func(ctx context.Context, statuses []zkevm_ethtx_managertypes.MonitoredTxStatus)) *EthTxManagerClientMock_ResultsByStatus_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].([]zkevm_ethtx_managertypes.MonitoredTxStatus)) + }) + return _c +} + +func (_c *EthTxManagerClientMock_ResultsByStatus_Call) Return(_a0 []zkevm_ethtx_managertypes.MonitoredTxResult, _a1 error) *EthTxManagerClientMock_ResultsByStatus_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EthTxManagerClientMock_ResultsByStatus_Call) RunAndReturn(run func(context.Context, []zkevm_ethtx_managertypes.MonitoredTxStatus) ([]zkevm_ethtx_managertypes.MonitoredTxResult, error)) *EthTxManagerClientMock_ResultsByStatus_Call { + _c.Call.Return(run) + return _c +} + +// Start provides a mock function with no fields func (_m *EthTxManagerClientMock) Start() { _m.Called() } -// Stop provides a mock function with given fields: +// EthTxManagerClientMock_Start_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Start' +type EthTxManagerClientMock_Start_Call struct { + *mock.Call +} + +// Start is a helper method to define mock.On call +func (_e *EthTxManagerClientMock_Expecter) Start() *EthTxManagerClientMock_Start_Call { + return &EthTxManagerClientMock_Start_Call{Call: _e.mock.On("Start")} +} + +func (_c *EthTxManagerClientMock_Start_Call) Run(run func()) *EthTxManagerClientMock_Start_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EthTxManagerClientMock_Start_Call) Return() *EthTxManagerClientMock_Start_Call { + _c.Call.Return() + return _c +} + +func (_c *EthTxManagerClientMock_Start_Call) RunAndReturn(run func()) *EthTxManagerClientMock_Start_Call { + _c.Run(run) + return _c +} + +// Stop provides a mock function with no fields func (_m *EthTxManagerClientMock) Stop() { _m.Called() } +// EthTxManagerClientMock_Stop_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Stop' +type EthTxManagerClientMock_Stop_Call struct { + *mock.Call +} + +// Stop is a helper method to define mock.On call +func (_e *EthTxManagerClientMock_Expecter) Stop() *EthTxManagerClientMock_Stop_Call { + return &EthTxManagerClientMock_Stop_Call{Call: _e.mock.On("Stop")} +} + +func (_c *EthTxManagerClientMock_Stop_Call) Run(run func()) *EthTxManagerClientMock_Stop_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EthTxManagerClientMock_Stop_Call) Return() *EthTxManagerClientMock_Stop_Call { + _c.Call.Return() + return _c +} + +func (_c *EthTxManagerClientMock_Stop_Call) RunAndReturn(run func()) *EthTxManagerClientMock_Stop_Call { + _c.Run(run) + return _c +} + // NewEthTxManagerClientMock creates a new instance of EthTxManagerClientMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewEthTxManagerClientMock(t interface { diff --git a/aggregator/mocks/mock_etherman.go b/aggregator/mocks/mock_etherman.go index 351acef3..2982430d 100644 --- a/aggregator/mocks/mock_etherman.go +++ b/aggregator/mocks/mock_etherman.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.0. DO NOT EDIT. +// Code generated by mockery. DO NOT EDIT. package mocks @@ -20,6 +20,14 @@ type EthermanMock struct { mock.Mock } +type EthermanMock_Expecter struct { + mock *mock.Mock +} + +func (_m *EthermanMock) EXPECT() *EthermanMock_Expecter { + return &EthermanMock_Expecter{mock: &_m.Mock} +} + // BuildTrustedVerifyBatchesTxData provides a mock function with given fields: lastVerifiedBatch, newVerifiedBatch, inputs, beneficiary func (_m *EthermanMock) BuildTrustedVerifyBatchesTxData(lastVerifiedBatch uint64, newVerifiedBatch uint64, inputs *ethmantypes.FinalProofInputs, beneficiary common.Address) (*common.Address, []byte, error) { ret := _m.Called(lastVerifiedBatch, newVerifiedBatch, inputs, beneficiary) @@ -59,6 +67,37 @@ func (_m *EthermanMock) BuildTrustedVerifyBatchesTxData(lastVerifiedBatch uint64 return r0, r1, r2 } +// EthermanMock_BuildTrustedVerifyBatchesTxData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'BuildTrustedVerifyBatchesTxData' +type EthermanMock_BuildTrustedVerifyBatchesTxData_Call struct { + *mock.Call +} + +// BuildTrustedVerifyBatchesTxData is a helper method to define mock.On call +// - lastVerifiedBatch uint64 +// - newVerifiedBatch uint64 +// - inputs *ethmantypes.FinalProofInputs +// - beneficiary common.Address +func (_e *EthermanMock_Expecter) BuildTrustedVerifyBatchesTxData(lastVerifiedBatch interface{}, newVerifiedBatch interface{}, inputs interface{}, beneficiary interface{}) *EthermanMock_BuildTrustedVerifyBatchesTxData_Call { + return &EthermanMock_BuildTrustedVerifyBatchesTxData_Call{Call: _e.mock.On("BuildTrustedVerifyBatchesTxData", lastVerifiedBatch, newVerifiedBatch, inputs, beneficiary)} +} + +func (_c *EthermanMock_BuildTrustedVerifyBatchesTxData_Call) Run(run func(lastVerifiedBatch uint64, newVerifiedBatch uint64, inputs *ethmantypes.FinalProofInputs, beneficiary common.Address)) *EthermanMock_BuildTrustedVerifyBatchesTxData_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(uint64), args[1].(uint64), args[2].(*ethmantypes.FinalProofInputs), args[3].(common.Address)) + }) + return _c +} + +func (_c *EthermanMock_BuildTrustedVerifyBatchesTxData_Call) Return(to *common.Address, data []byte, err error) *EthermanMock_BuildTrustedVerifyBatchesTxData_Call { + _c.Call.Return(to, data, err) + return _c +} + +func (_c *EthermanMock_BuildTrustedVerifyBatchesTxData_Call) RunAndReturn(run func(uint64, uint64, *ethmantypes.FinalProofInputs, common.Address) (*common.Address, []byte, error)) *EthermanMock_BuildTrustedVerifyBatchesTxData_Call { + _c.Call.Return(run) + return _c +} + // GetBatchAccInputHash provides a mock function with given fields: ctx, batchNumber func (_m *EthermanMock) GetBatchAccInputHash(ctx context.Context, batchNumber uint64) (common.Hash, error) { ret := _m.Called(ctx, batchNumber) @@ -89,6 +128,35 @@ func (_m *EthermanMock) GetBatchAccInputHash(ctx context.Context, batchNumber ui return r0, r1 } +// EthermanMock_GetBatchAccInputHash_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetBatchAccInputHash' +type EthermanMock_GetBatchAccInputHash_Call struct { + *mock.Call +} + +// GetBatchAccInputHash is a helper method to define mock.On call +// - ctx context.Context +// - batchNumber uint64 +func (_e *EthermanMock_Expecter) GetBatchAccInputHash(ctx interface{}, batchNumber interface{}) *EthermanMock_GetBatchAccInputHash_Call { + return &EthermanMock_GetBatchAccInputHash_Call{Call: _e.mock.On("GetBatchAccInputHash", ctx, batchNumber)} +} + +func (_c *EthermanMock_GetBatchAccInputHash_Call) Run(run func(ctx context.Context, batchNumber uint64)) *EthermanMock_GetBatchAccInputHash_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uint64)) + }) + return _c +} + +func (_c *EthermanMock_GetBatchAccInputHash_Call) Return(_a0 common.Hash, _a1 error) *EthermanMock_GetBatchAccInputHash_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EthermanMock_GetBatchAccInputHash_Call) RunAndReturn(run func(context.Context, uint64) (common.Hash, error)) *EthermanMock_GetBatchAccInputHash_Call { + _c.Call.Return(run) + return _c +} + // GetLatestBlockHeader provides a mock function with given fields: ctx func (_m *EthermanMock) GetLatestBlockHeader(ctx context.Context) (*types.Header, error) { ret := _m.Called(ctx) @@ -119,7 +187,35 @@ func (_m *EthermanMock) GetLatestBlockHeader(ctx context.Context) (*types.Header return r0, r1 } -// GetLatestVerifiedBatchNum provides a mock function with given fields: +// EthermanMock_GetLatestBlockHeader_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetLatestBlockHeader' +type EthermanMock_GetLatestBlockHeader_Call struct { + *mock.Call +} + +// GetLatestBlockHeader is a helper method to define mock.On call +// - ctx context.Context +func (_e *EthermanMock_Expecter) GetLatestBlockHeader(ctx interface{}) *EthermanMock_GetLatestBlockHeader_Call { + return &EthermanMock_GetLatestBlockHeader_Call{Call: _e.mock.On("GetLatestBlockHeader", ctx)} +} + +func (_c *EthermanMock_GetLatestBlockHeader_Call) Run(run func(ctx context.Context)) *EthermanMock_GetLatestBlockHeader_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *EthermanMock_GetLatestBlockHeader_Call) Return(_a0 *types.Header, _a1 error) *EthermanMock_GetLatestBlockHeader_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EthermanMock_GetLatestBlockHeader_Call) RunAndReturn(run func(context.Context) (*types.Header, error)) *EthermanMock_GetLatestBlockHeader_Call { + _c.Call.Return(run) + return _c +} + +// GetLatestVerifiedBatchNum provides a mock function with no fields func (_m *EthermanMock) GetLatestVerifiedBatchNum() (uint64, error) { ret := _m.Called() @@ -147,7 +243,34 @@ func (_m *EthermanMock) GetLatestVerifiedBatchNum() (uint64, error) { return r0, r1 } -// GetRollupId provides a mock function with given fields: +// EthermanMock_GetLatestVerifiedBatchNum_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetLatestVerifiedBatchNum' +type EthermanMock_GetLatestVerifiedBatchNum_Call struct { + *mock.Call +} + +// GetLatestVerifiedBatchNum is a helper method to define mock.On call +func (_e *EthermanMock_Expecter) GetLatestVerifiedBatchNum() *EthermanMock_GetLatestVerifiedBatchNum_Call { + return &EthermanMock_GetLatestVerifiedBatchNum_Call{Call: _e.mock.On("GetLatestVerifiedBatchNum")} +} + +func (_c *EthermanMock_GetLatestVerifiedBatchNum_Call) Run(run func()) *EthermanMock_GetLatestVerifiedBatchNum_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EthermanMock_GetLatestVerifiedBatchNum_Call) Return(_a0 uint64, _a1 error) *EthermanMock_GetLatestVerifiedBatchNum_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EthermanMock_GetLatestVerifiedBatchNum_Call) RunAndReturn(run func() (uint64, error)) *EthermanMock_GetLatestVerifiedBatchNum_Call { + _c.Call.Return(run) + return _c +} + +// GetRollupId provides a mock function with no fields func (_m *EthermanMock) GetRollupId() uint32 { ret := _m.Called() @@ -165,6 +288,33 @@ func (_m *EthermanMock) GetRollupId() uint32 { return r0 } +// EthermanMock_GetRollupId_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetRollupId' +type EthermanMock_GetRollupId_Call struct { + *mock.Call +} + +// GetRollupId is a helper method to define mock.On call +func (_e *EthermanMock_Expecter) GetRollupId() *EthermanMock_GetRollupId_Call { + return &EthermanMock_GetRollupId_Call{Call: _e.mock.On("GetRollupId")} +} + +func (_c *EthermanMock_GetRollupId_Call) Run(run func()) *EthermanMock_GetRollupId_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EthermanMock_GetRollupId_Call) Return(_a0 uint32) *EthermanMock_GetRollupId_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EthermanMock_GetRollupId_Call) RunAndReturn(run func() uint32) *EthermanMock_GetRollupId_Call { + _c.Call.Return(run) + return _c +} + // HeaderByNumber provides a mock function with given fields: ctx, number func (_m *EthermanMock) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) { ret := _m.Called(ctx, number) @@ -195,6 +345,35 @@ func (_m *EthermanMock) HeaderByNumber(ctx context.Context, number *big.Int) (*t return r0, r1 } +// EthermanMock_HeaderByNumber_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HeaderByNumber' +type EthermanMock_HeaderByNumber_Call struct { + *mock.Call +} + +// HeaderByNumber is a helper method to define mock.On call +// - ctx context.Context +// - number *big.Int +func (_e *EthermanMock_Expecter) HeaderByNumber(ctx interface{}, number interface{}) *EthermanMock_HeaderByNumber_Call { + return &EthermanMock_HeaderByNumber_Call{Call: _e.mock.On("HeaderByNumber", ctx, number)} +} + +func (_c *EthermanMock_HeaderByNumber_Call) Run(run func(ctx context.Context, number *big.Int)) *EthermanMock_HeaderByNumber_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*big.Int)) + }) + return _c +} + +func (_c *EthermanMock_HeaderByNumber_Call) Return(_a0 *types.Header, _a1 error) *EthermanMock_HeaderByNumber_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EthermanMock_HeaderByNumber_Call) RunAndReturn(run func(context.Context, *big.Int) (*types.Header, error)) *EthermanMock_HeaderByNumber_Call { + _c.Call.Return(run) + return _c +} + // NewEthermanMock creates a new instance of EthermanMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewEthermanMock(t interface { diff --git a/aggregator/mocks/mock_prover.go b/aggregator/mocks/mock_prover.go index b6ce1011..7939667d 100644 --- a/aggregator/mocks/mock_prover.go +++ b/aggregator/mocks/mock_prover.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.0. DO NOT EDIT. +// Code generated by mockery. DO NOT EDIT. package mocks @@ -17,7 +17,15 @@ type ProverInterfaceMock struct { mock.Mock } -// Addr provides a mock function with given fields: +type ProverInterfaceMock_Expecter struct { + mock *mock.Mock +} + +func (_m *ProverInterfaceMock) EXPECT() *ProverInterfaceMock_Expecter { + return &ProverInterfaceMock_Expecter{mock: &_m.Mock} +} + +// Addr provides a mock function with no fields func (_m *ProverInterfaceMock) Addr() string { ret := _m.Called() @@ -35,6 +43,33 @@ func (_m *ProverInterfaceMock) Addr() string { return r0 } +// ProverInterfaceMock_Addr_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Addr' +type ProverInterfaceMock_Addr_Call struct { + *mock.Call +} + +// Addr is a helper method to define mock.On call +func (_e *ProverInterfaceMock_Expecter) Addr() *ProverInterfaceMock_Addr_Call { + return &ProverInterfaceMock_Addr_Call{Call: _e.mock.On("Addr")} +} + +func (_c *ProverInterfaceMock_Addr_Call) Run(run func()) *ProverInterfaceMock_Addr_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *ProverInterfaceMock_Addr_Call) Return(_a0 string) *ProverInterfaceMock_Addr_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ProverInterfaceMock_Addr_Call) RunAndReturn(run func() string) *ProverInterfaceMock_Addr_Call { + _c.Call.Return(run) + return _c +} + // AggregatedProof provides a mock function with given fields: inputProof1, inputProof2 func (_m *ProverInterfaceMock) AggregatedProof(inputProof1 string, inputProof2 string) (*string, error) { ret := _m.Called(inputProof1, inputProof2) @@ -65,6 +100,35 @@ func (_m *ProverInterfaceMock) AggregatedProof(inputProof1 string, inputProof2 s return r0, r1 } +// ProverInterfaceMock_AggregatedProof_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AggregatedProof' +type ProverInterfaceMock_AggregatedProof_Call struct { + *mock.Call +} + +// AggregatedProof is a helper method to define mock.On call +// - inputProof1 string +// - inputProof2 string +func (_e *ProverInterfaceMock_Expecter) AggregatedProof(inputProof1 interface{}, inputProof2 interface{}) *ProverInterfaceMock_AggregatedProof_Call { + return &ProverInterfaceMock_AggregatedProof_Call{Call: _e.mock.On("AggregatedProof", inputProof1, inputProof2)} +} + +func (_c *ProverInterfaceMock_AggregatedProof_Call) Run(run func(inputProof1 string, inputProof2 string)) *ProverInterfaceMock_AggregatedProof_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(string)) + }) + return _c +} + +func (_c *ProverInterfaceMock_AggregatedProof_Call) Return(_a0 *string, _a1 error) *ProverInterfaceMock_AggregatedProof_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ProverInterfaceMock_AggregatedProof_Call) RunAndReturn(run func(string, string) (*string, error)) *ProverInterfaceMock_AggregatedProof_Call { + _c.Call.Return(run) + return _c +} + // BatchProof provides a mock function with given fields: input func (_m *ProverInterfaceMock) BatchProof(input *prover.StatelessInputProver) (*string, error) { ret := _m.Called(input) @@ -95,6 +159,34 @@ func (_m *ProverInterfaceMock) BatchProof(input *prover.StatelessInputProver) (* return r0, r1 } +// ProverInterfaceMock_BatchProof_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'BatchProof' +type ProverInterfaceMock_BatchProof_Call struct { + *mock.Call +} + +// BatchProof is a helper method to define mock.On call +// - input *prover.StatelessInputProver +func (_e *ProverInterfaceMock_Expecter) BatchProof(input interface{}) *ProverInterfaceMock_BatchProof_Call { + return &ProverInterfaceMock_BatchProof_Call{Call: _e.mock.On("BatchProof", input)} +} + +func (_c *ProverInterfaceMock_BatchProof_Call) Run(run func(input *prover.StatelessInputProver)) *ProverInterfaceMock_BatchProof_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*prover.StatelessInputProver)) + }) + return _c +} + +func (_c *ProverInterfaceMock_BatchProof_Call) Return(_a0 *string, _a1 error) *ProverInterfaceMock_BatchProof_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ProverInterfaceMock_BatchProof_Call) RunAndReturn(run func(*prover.StatelessInputProver) (*string, error)) *ProverInterfaceMock_BatchProof_Call { + _c.Call.Return(run) + return _c +} + // FinalProof provides a mock function with given fields: inputProof, aggregatorAddr func (_m *ProverInterfaceMock) FinalProof(inputProof string, aggregatorAddr string) (*string, error) { ret := _m.Called(inputProof, aggregatorAddr) @@ -125,7 +217,36 @@ func (_m *ProverInterfaceMock) FinalProof(inputProof string, aggregatorAddr stri return r0, r1 } -// ID provides a mock function with given fields: +// ProverInterfaceMock_FinalProof_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FinalProof' +type ProverInterfaceMock_FinalProof_Call struct { + *mock.Call +} + +// FinalProof is a helper method to define mock.On call +// - inputProof string +// - aggregatorAddr string +func (_e *ProverInterfaceMock_Expecter) FinalProof(inputProof interface{}, aggregatorAddr interface{}) *ProverInterfaceMock_FinalProof_Call { + return &ProverInterfaceMock_FinalProof_Call{Call: _e.mock.On("FinalProof", inputProof, aggregatorAddr)} +} + +func (_c *ProverInterfaceMock_FinalProof_Call) Run(run func(inputProof string, aggregatorAddr string)) *ProverInterfaceMock_FinalProof_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(string)) + }) + return _c +} + +func (_c *ProverInterfaceMock_FinalProof_Call) Return(_a0 *string, _a1 error) *ProverInterfaceMock_FinalProof_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ProverInterfaceMock_FinalProof_Call) RunAndReturn(run func(string, string) (*string, error)) *ProverInterfaceMock_FinalProof_Call { + _c.Call.Return(run) + return _c +} + +// ID provides a mock function with no fields func (_m *ProverInterfaceMock) ID() string { ret := _m.Called() @@ -143,7 +264,34 @@ func (_m *ProverInterfaceMock) ID() string { return r0 } -// IsIdle provides a mock function with given fields: +// ProverInterfaceMock_ID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ID' +type ProverInterfaceMock_ID_Call struct { + *mock.Call +} + +// ID is a helper method to define mock.On call +func (_e *ProverInterfaceMock_Expecter) ID() *ProverInterfaceMock_ID_Call { + return &ProverInterfaceMock_ID_Call{Call: _e.mock.On("ID")} +} + +func (_c *ProverInterfaceMock_ID_Call) Run(run func()) *ProverInterfaceMock_ID_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *ProverInterfaceMock_ID_Call) Return(_a0 string) *ProverInterfaceMock_ID_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ProverInterfaceMock_ID_Call) RunAndReturn(run func() string) *ProverInterfaceMock_ID_Call { + _c.Call.Return(run) + return _c +} + +// IsIdle provides a mock function with no fields func (_m *ProverInterfaceMock) IsIdle() (bool, error) { ret := _m.Called() @@ -171,7 +319,34 @@ func (_m *ProverInterfaceMock) IsIdle() (bool, error) { return r0, r1 } -// Name provides a mock function with given fields: +// ProverInterfaceMock_IsIdle_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsIdle' +type ProverInterfaceMock_IsIdle_Call struct { + *mock.Call +} + +// IsIdle is a helper method to define mock.On call +func (_e *ProverInterfaceMock_Expecter) IsIdle() *ProverInterfaceMock_IsIdle_Call { + return &ProverInterfaceMock_IsIdle_Call{Call: _e.mock.On("IsIdle")} +} + +func (_c *ProverInterfaceMock_IsIdle_Call) Run(run func()) *ProverInterfaceMock_IsIdle_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *ProverInterfaceMock_IsIdle_Call) Return(_a0 bool, _a1 error) *ProverInterfaceMock_IsIdle_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ProverInterfaceMock_IsIdle_Call) RunAndReturn(run func() (bool, error)) *ProverInterfaceMock_IsIdle_Call { + _c.Call.Return(run) + return _c +} + +// Name provides a mock function with no fields func (_m *ProverInterfaceMock) Name() string { ret := _m.Called() @@ -189,6 +364,33 @@ func (_m *ProverInterfaceMock) Name() string { return r0 } +// ProverInterfaceMock_Name_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Name' +type ProverInterfaceMock_Name_Call struct { + *mock.Call +} + +// Name is a helper method to define mock.On call +func (_e *ProverInterfaceMock_Expecter) Name() *ProverInterfaceMock_Name_Call { + return &ProverInterfaceMock_Name_Call{Call: _e.mock.On("Name")} +} + +func (_c *ProverInterfaceMock_Name_Call) Run(run func()) *ProverInterfaceMock_Name_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *ProverInterfaceMock_Name_Call) Return(_a0 string) *ProverInterfaceMock_Name_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ProverInterfaceMock_Name_Call) RunAndReturn(run func() string) *ProverInterfaceMock_Name_Call { + _c.Call.Return(run) + return _c +} + // WaitFinalProof provides a mock function with given fields: ctx, proofID func (_m *ProverInterfaceMock) WaitFinalProof(ctx context.Context, proofID string) (*prover.FinalProof, error) { ret := _m.Called(ctx, proofID) @@ -219,6 +421,35 @@ func (_m *ProverInterfaceMock) WaitFinalProof(ctx context.Context, proofID strin return r0, r1 } +// ProverInterfaceMock_WaitFinalProof_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WaitFinalProof' +type ProverInterfaceMock_WaitFinalProof_Call struct { + *mock.Call +} + +// WaitFinalProof is a helper method to define mock.On call +// - ctx context.Context +// - proofID string +func (_e *ProverInterfaceMock_Expecter) WaitFinalProof(ctx interface{}, proofID interface{}) *ProverInterfaceMock_WaitFinalProof_Call { + return &ProverInterfaceMock_WaitFinalProof_Call{Call: _e.mock.On("WaitFinalProof", ctx, proofID)} +} + +func (_c *ProverInterfaceMock_WaitFinalProof_Call) Run(run func(ctx context.Context, proofID string)) *ProverInterfaceMock_WaitFinalProof_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *ProverInterfaceMock_WaitFinalProof_Call) Return(_a0 *prover.FinalProof, _a1 error) *ProverInterfaceMock_WaitFinalProof_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ProverInterfaceMock_WaitFinalProof_Call) RunAndReturn(run func(context.Context, string) (*prover.FinalProof, error)) *ProverInterfaceMock_WaitFinalProof_Call { + _c.Call.Return(run) + return _c +} + // WaitRecursiveProof provides a mock function with given fields: ctx, proofID func (_m *ProverInterfaceMock) WaitRecursiveProof(ctx context.Context, proofID string) (string, common.Hash, common.Hash, error) { ret := _m.Called(ctx, proofID) @@ -265,6 +496,35 @@ func (_m *ProverInterfaceMock) WaitRecursiveProof(ctx context.Context, proofID s return r0, r1, r2, r3 } +// ProverInterfaceMock_WaitRecursiveProof_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WaitRecursiveProof' +type ProverInterfaceMock_WaitRecursiveProof_Call struct { + *mock.Call +} + +// WaitRecursiveProof is a helper method to define mock.On call +// - ctx context.Context +// - proofID string +func (_e *ProverInterfaceMock_Expecter) WaitRecursiveProof(ctx interface{}, proofID interface{}) *ProverInterfaceMock_WaitRecursiveProof_Call { + return &ProverInterfaceMock_WaitRecursiveProof_Call{Call: _e.mock.On("WaitRecursiveProof", ctx, proofID)} +} + +func (_c *ProverInterfaceMock_WaitRecursiveProof_Call) Run(run func(ctx context.Context, proofID string)) *ProverInterfaceMock_WaitRecursiveProof_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *ProverInterfaceMock_WaitRecursiveProof_Call) Return(_a0 string, _a1 common.Hash, _a2 common.Hash, _a3 error) *ProverInterfaceMock_WaitRecursiveProof_Call { + _c.Call.Return(_a0, _a1, _a2, _a3) + return _c +} + +func (_c *ProverInterfaceMock_WaitRecursiveProof_Call) RunAndReturn(run func(context.Context, string) (string, common.Hash, common.Hash, error)) *ProverInterfaceMock_WaitRecursiveProof_Call { + _c.Call.Return(run) + return _c +} + // NewProverInterfaceMock creates a new instance of ProverInterfaceMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewProverInterfaceMock(t interface { diff --git a/aggregator/mocks/mock_rpc.go b/aggregator/mocks/mock_rpc.go index 2f3c07e4..3927b5db 100644 --- a/aggregator/mocks/mock_rpc.go +++ b/aggregator/mocks/mock_rpc.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.0. DO NOT EDIT. +// Code generated by mockery. DO NOT EDIT. package mocks @@ -12,6 +12,14 @@ type RPCInterfaceMock struct { mock.Mock } +type RPCInterfaceMock_Expecter struct { + mock *mock.Mock +} + +func (_m *RPCInterfaceMock) EXPECT() *RPCInterfaceMock_Expecter { + return &RPCInterfaceMock_Expecter{mock: &_m.Mock} +} + // GetBatch provides a mock function with given fields: batchNumber func (_m *RPCInterfaceMock) GetBatch(batchNumber uint64) (*types.RPCBatch, error) { ret := _m.Called(batchNumber) @@ -42,6 +50,34 @@ func (_m *RPCInterfaceMock) GetBatch(batchNumber uint64) (*types.RPCBatch, error return r0, r1 } +// RPCInterfaceMock_GetBatch_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetBatch' +type RPCInterfaceMock_GetBatch_Call struct { + *mock.Call +} + +// GetBatch is a helper method to define mock.On call +// - batchNumber uint64 +func (_e *RPCInterfaceMock_Expecter) GetBatch(batchNumber interface{}) *RPCInterfaceMock_GetBatch_Call { + return &RPCInterfaceMock_GetBatch_Call{Call: _e.mock.On("GetBatch", batchNumber)} +} + +func (_c *RPCInterfaceMock_GetBatch_Call) Run(run func(batchNumber uint64)) *RPCInterfaceMock_GetBatch_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(uint64)) + }) + return _c +} + +func (_c *RPCInterfaceMock_GetBatch_Call) Return(_a0 *types.RPCBatch, _a1 error) *RPCInterfaceMock_GetBatch_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *RPCInterfaceMock_GetBatch_Call) RunAndReturn(run func(uint64) (*types.RPCBatch, error)) *RPCInterfaceMock_GetBatch_Call { + _c.Call.Return(run) + return _c +} + // GetWitness provides a mock function with given fields: batchNumber, fullWitness func (_m *RPCInterfaceMock) GetWitness(batchNumber uint64, fullWitness bool) ([]byte, error) { ret := _m.Called(batchNumber, fullWitness) @@ -72,6 +108,35 @@ func (_m *RPCInterfaceMock) GetWitness(batchNumber uint64, fullWitness bool) ([] return r0, r1 } +// RPCInterfaceMock_GetWitness_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWitness' +type RPCInterfaceMock_GetWitness_Call struct { + *mock.Call +} + +// GetWitness is a helper method to define mock.On call +// - batchNumber uint64 +// - fullWitness bool +func (_e *RPCInterfaceMock_Expecter) GetWitness(batchNumber interface{}, fullWitness interface{}) *RPCInterfaceMock_GetWitness_Call { + return &RPCInterfaceMock_GetWitness_Call{Call: _e.mock.On("GetWitness", batchNumber, fullWitness)} +} + +func (_c *RPCInterfaceMock_GetWitness_Call) Run(run func(batchNumber uint64, fullWitness bool)) *RPCInterfaceMock_GetWitness_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(uint64), args[1].(bool)) + }) + return _c +} + +func (_c *RPCInterfaceMock_GetWitness_Call) Return(_a0 []byte, _a1 error) *RPCInterfaceMock_GetWitness_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *RPCInterfaceMock_GetWitness_Call) RunAndReturn(run func(uint64, bool) ([]byte, error)) *RPCInterfaceMock_GetWitness_Call { + _c.Call.Return(run) + return _c +} + // NewRPCInterfaceMock creates a new instance of RPCInterfaceMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewRPCInterfaceMock(t interface { diff --git a/aggregator/mocks/mock_storage.go b/aggregator/mocks/mock_storage.go index 405cba46..2615f6bc 100644 --- a/aggregator/mocks/mock_storage.go +++ b/aggregator/mocks/mock_storage.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.0. DO NOT EDIT. +// Code generated by mockery. DO NOT EDIT. package mocks @@ -18,6 +18,14 @@ type StorageInterfaceMock struct { mock.Mock } +type StorageInterfaceMock_Expecter struct { + mock *mock.Mock +} + +func (_m *StorageInterfaceMock) EXPECT() *StorageInterfaceMock_Expecter { + return &StorageInterfaceMock_Expecter{mock: &_m.Mock} +} + // AddGeneratedProof provides a mock function with given fields: ctx, proof, dbTx func (_m *StorageInterfaceMock) AddGeneratedProof(ctx context.Context, proof *state.Proof, dbTx db.Txer) error { ret := _m.Called(ctx, proof, dbTx) @@ -36,6 +44,36 @@ func (_m *StorageInterfaceMock) AddGeneratedProof(ctx context.Context, proof *st return r0 } +// StorageInterfaceMock_AddGeneratedProof_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddGeneratedProof' +type StorageInterfaceMock_AddGeneratedProof_Call struct { + *mock.Call +} + +// AddGeneratedProof is a helper method to define mock.On call +// - ctx context.Context +// - proof *state.Proof +// - dbTx db.Txer +func (_e *StorageInterfaceMock_Expecter) AddGeneratedProof(ctx interface{}, proof interface{}, dbTx interface{}) *StorageInterfaceMock_AddGeneratedProof_Call { + return &StorageInterfaceMock_AddGeneratedProof_Call{Call: _e.mock.On("AddGeneratedProof", ctx, proof, dbTx)} +} + +func (_c *StorageInterfaceMock_AddGeneratedProof_Call) Run(run func(ctx context.Context, proof *state.Proof, dbTx db.Txer)) *StorageInterfaceMock_AddGeneratedProof_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*state.Proof), args[2].(db.Txer)) + }) + return _c +} + +func (_c *StorageInterfaceMock_AddGeneratedProof_Call) Return(_a0 error) *StorageInterfaceMock_AddGeneratedProof_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *StorageInterfaceMock_AddGeneratedProof_Call) RunAndReturn(run func(context.Context, *state.Proof, db.Txer) error) *StorageInterfaceMock_AddGeneratedProof_Call { + _c.Call.Return(run) + return _c +} + // AddSequence provides a mock function with given fields: ctx, sequence, dbTx func (_m *StorageInterfaceMock) AddSequence(ctx context.Context, sequence state.Sequence, dbTx db.Txer) error { ret := _m.Called(ctx, sequence, dbTx) @@ -54,6 +92,36 @@ func (_m *StorageInterfaceMock) AddSequence(ctx context.Context, sequence state. return r0 } +// StorageInterfaceMock_AddSequence_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddSequence' +type StorageInterfaceMock_AddSequence_Call struct { + *mock.Call +} + +// AddSequence is a helper method to define mock.On call +// - ctx context.Context +// - sequence state.Sequence +// - dbTx db.Txer +func (_e *StorageInterfaceMock_Expecter) AddSequence(ctx interface{}, sequence interface{}, dbTx interface{}) *StorageInterfaceMock_AddSequence_Call { + return &StorageInterfaceMock_AddSequence_Call{Call: _e.mock.On("AddSequence", ctx, sequence, dbTx)} +} + +func (_c *StorageInterfaceMock_AddSequence_Call) Run(run func(ctx context.Context, sequence state.Sequence, dbTx db.Txer)) *StorageInterfaceMock_AddSequence_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(state.Sequence), args[2].(db.Txer)) + }) + return _c +} + +func (_c *StorageInterfaceMock_AddSequence_Call) Return(_a0 error) *StorageInterfaceMock_AddSequence_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *StorageInterfaceMock_AddSequence_Call) RunAndReturn(run func(context.Context, state.Sequence, db.Txer) error) *StorageInterfaceMock_AddSequence_Call { + _c.Call.Return(run) + return _c +} + // BeginTx provides a mock function with given fields: ctx, options func (_m *StorageInterfaceMock) BeginTx(ctx context.Context, options *sql.TxOptions) (db.Txer, error) { ret := _m.Called(ctx, options) @@ -84,6 +152,35 @@ func (_m *StorageInterfaceMock) BeginTx(ctx context.Context, options *sql.TxOpti return r0, r1 } +// StorageInterfaceMock_BeginTx_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'BeginTx' +type StorageInterfaceMock_BeginTx_Call struct { + *mock.Call +} + +// BeginTx is a helper method to define mock.On call +// - ctx context.Context +// - options *sql.TxOptions +func (_e *StorageInterfaceMock_Expecter) BeginTx(ctx interface{}, options interface{}) *StorageInterfaceMock_BeginTx_Call { + return &StorageInterfaceMock_BeginTx_Call{Call: _e.mock.On("BeginTx", ctx, options)} +} + +func (_c *StorageInterfaceMock_BeginTx_Call) Run(run func(ctx context.Context, options *sql.TxOptions)) *StorageInterfaceMock_BeginTx_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*sql.TxOptions)) + }) + return _c +} + +func (_c *StorageInterfaceMock_BeginTx_Call) Return(_a0 db.Txer, _a1 error) *StorageInterfaceMock_BeginTx_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *StorageInterfaceMock_BeginTx_Call) RunAndReturn(run func(context.Context, *sql.TxOptions) (db.Txer, error)) *StorageInterfaceMock_BeginTx_Call { + _c.Call.Return(run) + return _c +} + // CheckProofContainsCompleteSequences provides a mock function with given fields: ctx, proof, dbTx func (_m *StorageInterfaceMock) CheckProofContainsCompleteSequences(ctx context.Context, proof *state.Proof, dbTx db.Txer) (bool, error) { ret := _m.Called(ctx, proof, dbTx) @@ -112,6 +209,36 @@ func (_m *StorageInterfaceMock) CheckProofContainsCompleteSequences(ctx context. return r0, r1 } +// StorageInterfaceMock_CheckProofContainsCompleteSequences_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CheckProofContainsCompleteSequences' +type StorageInterfaceMock_CheckProofContainsCompleteSequences_Call struct { + *mock.Call +} + +// CheckProofContainsCompleteSequences is a helper method to define mock.On call +// - ctx context.Context +// - proof *state.Proof +// - dbTx db.Txer +func (_e *StorageInterfaceMock_Expecter) CheckProofContainsCompleteSequences(ctx interface{}, proof interface{}, dbTx interface{}) *StorageInterfaceMock_CheckProofContainsCompleteSequences_Call { + return &StorageInterfaceMock_CheckProofContainsCompleteSequences_Call{Call: _e.mock.On("CheckProofContainsCompleteSequences", ctx, proof, dbTx)} +} + +func (_c *StorageInterfaceMock_CheckProofContainsCompleteSequences_Call) Run(run func(ctx context.Context, proof *state.Proof, dbTx db.Txer)) *StorageInterfaceMock_CheckProofContainsCompleteSequences_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*state.Proof), args[2].(db.Txer)) + }) + return _c +} + +func (_c *StorageInterfaceMock_CheckProofContainsCompleteSequences_Call) Return(_a0 bool, _a1 error) *StorageInterfaceMock_CheckProofContainsCompleteSequences_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *StorageInterfaceMock_CheckProofContainsCompleteSequences_Call) RunAndReturn(run func(context.Context, *state.Proof, db.Txer) (bool, error)) *StorageInterfaceMock_CheckProofContainsCompleteSequences_Call { + _c.Call.Return(run) + return _c +} + // CheckProofExistsForBatch provides a mock function with given fields: ctx, batchNumber, dbTx func (_m *StorageInterfaceMock) CheckProofExistsForBatch(ctx context.Context, batchNumber uint64, dbTx db.Txer) (bool, error) { ret := _m.Called(ctx, batchNumber, dbTx) @@ -140,6 +267,36 @@ func (_m *StorageInterfaceMock) CheckProofExistsForBatch(ctx context.Context, ba return r0, r1 } +// StorageInterfaceMock_CheckProofExistsForBatch_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CheckProofExistsForBatch' +type StorageInterfaceMock_CheckProofExistsForBatch_Call struct { + *mock.Call +} + +// CheckProofExistsForBatch is a helper method to define mock.On call +// - ctx context.Context +// - batchNumber uint64 +// - dbTx db.Txer +func (_e *StorageInterfaceMock_Expecter) CheckProofExistsForBatch(ctx interface{}, batchNumber interface{}, dbTx interface{}) *StorageInterfaceMock_CheckProofExistsForBatch_Call { + return &StorageInterfaceMock_CheckProofExistsForBatch_Call{Call: _e.mock.On("CheckProofExistsForBatch", ctx, batchNumber, dbTx)} +} + +func (_c *StorageInterfaceMock_CheckProofExistsForBatch_Call) Run(run func(ctx context.Context, batchNumber uint64, dbTx db.Txer)) *StorageInterfaceMock_CheckProofExistsForBatch_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uint64), args[2].(db.Txer)) + }) + return _c +} + +func (_c *StorageInterfaceMock_CheckProofExistsForBatch_Call) Return(_a0 bool, _a1 error) *StorageInterfaceMock_CheckProofExistsForBatch_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *StorageInterfaceMock_CheckProofExistsForBatch_Call) RunAndReturn(run func(context.Context, uint64, db.Txer) (bool, error)) *StorageInterfaceMock_CheckProofExistsForBatch_Call { + _c.Call.Return(run) + return _c +} + // CleanupGeneratedProofs provides a mock function with given fields: ctx, batchNumber, dbTx func (_m *StorageInterfaceMock) CleanupGeneratedProofs(ctx context.Context, batchNumber uint64, dbTx db.Txer) error { ret := _m.Called(ctx, batchNumber, dbTx) @@ -158,6 +315,36 @@ func (_m *StorageInterfaceMock) CleanupGeneratedProofs(ctx context.Context, batc return r0 } +// StorageInterfaceMock_CleanupGeneratedProofs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CleanupGeneratedProofs' +type StorageInterfaceMock_CleanupGeneratedProofs_Call struct { + *mock.Call +} + +// CleanupGeneratedProofs is a helper method to define mock.On call +// - ctx context.Context +// - batchNumber uint64 +// - dbTx db.Txer +func (_e *StorageInterfaceMock_Expecter) CleanupGeneratedProofs(ctx interface{}, batchNumber interface{}, dbTx interface{}) *StorageInterfaceMock_CleanupGeneratedProofs_Call { + return &StorageInterfaceMock_CleanupGeneratedProofs_Call{Call: _e.mock.On("CleanupGeneratedProofs", ctx, batchNumber, dbTx)} +} + +func (_c *StorageInterfaceMock_CleanupGeneratedProofs_Call) Run(run func(ctx context.Context, batchNumber uint64, dbTx db.Txer)) *StorageInterfaceMock_CleanupGeneratedProofs_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uint64), args[2].(db.Txer)) + }) + return _c +} + +func (_c *StorageInterfaceMock_CleanupGeneratedProofs_Call) Return(_a0 error) *StorageInterfaceMock_CleanupGeneratedProofs_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *StorageInterfaceMock_CleanupGeneratedProofs_Call) RunAndReturn(run func(context.Context, uint64, db.Txer) error) *StorageInterfaceMock_CleanupGeneratedProofs_Call { + _c.Call.Return(run) + return _c +} + // CleanupLockedProofs provides a mock function with given fields: ctx, duration, dbTx func (_m *StorageInterfaceMock) CleanupLockedProofs(ctx context.Context, duration string, dbTx db.Txer) (int64, error) { ret := _m.Called(ctx, duration, dbTx) @@ -186,6 +373,36 @@ func (_m *StorageInterfaceMock) CleanupLockedProofs(ctx context.Context, duratio return r0, r1 } +// StorageInterfaceMock_CleanupLockedProofs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CleanupLockedProofs' +type StorageInterfaceMock_CleanupLockedProofs_Call struct { + *mock.Call +} + +// CleanupLockedProofs is a helper method to define mock.On call +// - ctx context.Context +// - duration string +// - dbTx db.Txer +func (_e *StorageInterfaceMock_Expecter) CleanupLockedProofs(ctx interface{}, duration interface{}, dbTx interface{}) *StorageInterfaceMock_CleanupLockedProofs_Call { + return &StorageInterfaceMock_CleanupLockedProofs_Call{Call: _e.mock.On("CleanupLockedProofs", ctx, duration, dbTx)} +} + +func (_c *StorageInterfaceMock_CleanupLockedProofs_Call) Run(run func(ctx context.Context, duration string, dbTx db.Txer)) *StorageInterfaceMock_CleanupLockedProofs_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(db.Txer)) + }) + return _c +} + +func (_c *StorageInterfaceMock_CleanupLockedProofs_Call) Return(_a0 int64, _a1 error) *StorageInterfaceMock_CleanupLockedProofs_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *StorageInterfaceMock_CleanupLockedProofs_Call) RunAndReturn(run func(context.Context, string, db.Txer) (int64, error)) *StorageInterfaceMock_CleanupLockedProofs_Call { + _c.Call.Return(run) + return _c +} + // DeleteGeneratedProofs provides a mock function with given fields: ctx, batchNumber, batchNumberFinal, dbTx func (_m *StorageInterfaceMock) DeleteGeneratedProofs(ctx context.Context, batchNumber uint64, batchNumberFinal uint64, dbTx db.Txer) error { ret := _m.Called(ctx, batchNumber, batchNumberFinal, dbTx) @@ -204,6 +421,37 @@ func (_m *StorageInterfaceMock) DeleteGeneratedProofs(ctx context.Context, batch return r0 } +// StorageInterfaceMock_DeleteGeneratedProofs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteGeneratedProofs' +type StorageInterfaceMock_DeleteGeneratedProofs_Call struct { + *mock.Call +} + +// DeleteGeneratedProofs is a helper method to define mock.On call +// - ctx context.Context +// - batchNumber uint64 +// - batchNumberFinal uint64 +// - dbTx db.Txer +func (_e *StorageInterfaceMock_Expecter) DeleteGeneratedProofs(ctx interface{}, batchNumber interface{}, batchNumberFinal interface{}, dbTx interface{}) *StorageInterfaceMock_DeleteGeneratedProofs_Call { + return &StorageInterfaceMock_DeleteGeneratedProofs_Call{Call: _e.mock.On("DeleteGeneratedProofs", ctx, batchNumber, batchNumberFinal, dbTx)} +} + +func (_c *StorageInterfaceMock_DeleteGeneratedProofs_Call) Run(run func(ctx context.Context, batchNumber uint64, batchNumberFinal uint64, dbTx db.Txer)) *StorageInterfaceMock_DeleteGeneratedProofs_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uint64), args[2].(uint64), args[3].(db.Txer)) + }) + return _c +} + +func (_c *StorageInterfaceMock_DeleteGeneratedProofs_Call) Return(_a0 error) *StorageInterfaceMock_DeleteGeneratedProofs_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *StorageInterfaceMock_DeleteGeneratedProofs_Call) RunAndReturn(run func(context.Context, uint64, uint64, db.Txer) error) *StorageInterfaceMock_DeleteGeneratedProofs_Call { + _c.Call.Return(run) + return _c +} + // DeleteUngeneratedProofs provides a mock function with given fields: ctx, dbTx func (_m *StorageInterfaceMock) DeleteUngeneratedProofs(ctx context.Context, dbTx db.Txer) error { ret := _m.Called(ctx, dbTx) @@ -222,6 +470,35 @@ func (_m *StorageInterfaceMock) DeleteUngeneratedProofs(ctx context.Context, dbT return r0 } +// StorageInterfaceMock_DeleteUngeneratedProofs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteUngeneratedProofs' +type StorageInterfaceMock_DeleteUngeneratedProofs_Call struct { + *mock.Call +} + +// DeleteUngeneratedProofs is a helper method to define mock.On call +// - ctx context.Context +// - dbTx db.Txer +func (_e *StorageInterfaceMock_Expecter) DeleteUngeneratedProofs(ctx interface{}, dbTx interface{}) *StorageInterfaceMock_DeleteUngeneratedProofs_Call { + return &StorageInterfaceMock_DeleteUngeneratedProofs_Call{Call: _e.mock.On("DeleteUngeneratedProofs", ctx, dbTx)} +} + +func (_c *StorageInterfaceMock_DeleteUngeneratedProofs_Call) Run(run func(ctx context.Context, dbTx db.Txer)) *StorageInterfaceMock_DeleteUngeneratedProofs_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(db.Txer)) + }) + return _c +} + +func (_c *StorageInterfaceMock_DeleteUngeneratedProofs_Call) Return(_a0 error) *StorageInterfaceMock_DeleteUngeneratedProofs_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *StorageInterfaceMock_DeleteUngeneratedProofs_Call) RunAndReturn(run func(context.Context, db.Txer) error) *StorageInterfaceMock_DeleteUngeneratedProofs_Call { + _c.Call.Return(run) + return _c +} + // GetProofReadyToVerify provides a mock function with given fields: ctx, lastVerfiedBatchNumber, dbTx func (_m *StorageInterfaceMock) GetProofReadyToVerify(ctx context.Context, lastVerfiedBatchNumber uint64, dbTx db.Txer) (*state.Proof, error) { ret := _m.Called(ctx, lastVerfiedBatchNumber, dbTx) @@ -252,6 +529,36 @@ func (_m *StorageInterfaceMock) GetProofReadyToVerify(ctx context.Context, lastV return r0, r1 } +// StorageInterfaceMock_GetProofReadyToVerify_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetProofReadyToVerify' +type StorageInterfaceMock_GetProofReadyToVerify_Call struct { + *mock.Call +} + +// GetProofReadyToVerify is a helper method to define mock.On call +// - ctx context.Context +// - lastVerfiedBatchNumber uint64 +// - dbTx db.Txer +func (_e *StorageInterfaceMock_Expecter) GetProofReadyToVerify(ctx interface{}, lastVerfiedBatchNumber interface{}, dbTx interface{}) *StorageInterfaceMock_GetProofReadyToVerify_Call { + return &StorageInterfaceMock_GetProofReadyToVerify_Call{Call: _e.mock.On("GetProofReadyToVerify", ctx, lastVerfiedBatchNumber, dbTx)} +} + +func (_c *StorageInterfaceMock_GetProofReadyToVerify_Call) Run(run func(ctx context.Context, lastVerfiedBatchNumber uint64, dbTx db.Txer)) *StorageInterfaceMock_GetProofReadyToVerify_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uint64), args[2].(db.Txer)) + }) + return _c +} + +func (_c *StorageInterfaceMock_GetProofReadyToVerify_Call) Return(_a0 *state.Proof, _a1 error) *StorageInterfaceMock_GetProofReadyToVerify_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *StorageInterfaceMock_GetProofReadyToVerify_Call) RunAndReturn(run func(context.Context, uint64, db.Txer) (*state.Proof, error)) *StorageInterfaceMock_GetProofReadyToVerify_Call { + _c.Call.Return(run) + return _c +} + // GetProofsToAggregate provides a mock function with given fields: ctx, dbTx func (_m *StorageInterfaceMock) GetProofsToAggregate(ctx context.Context, dbTx db.Txer) (*state.Proof, *state.Proof, error) { ret := _m.Called(ctx, dbTx) @@ -291,6 +598,35 @@ func (_m *StorageInterfaceMock) GetProofsToAggregate(ctx context.Context, dbTx d return r0, r1, r2 } +// StorageInterfaceMock_GetProofsToAggregate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetProofsToAggregate' +type StorageInterfaceMock_GetProofsToAggregate_Call struct { + *mock.Call +} + +// GetProofsToAggregate is a helper method to define mock.On call +// - ctx context.Context +// - dbTx db.Txer +func (_e *StorageInterfaceMock_Expecter) GetProofsToAggregate(ctx interface{}, dbTx interface{}) *StorageInterfaceMock_GetProofsToAggregate_Call { + return &StorageInterfaceMock_GetProofsToAggregate_Call{Call: _e.mock.On("GetProofsToAggregate", ctx, dbTx)} +} + +func (_c *StorageInterfaceMock_GetProofsToAggregate_Call) Run(run func(ctx context.Context, dbTx db.Txer)) *StorageInterfaceMock_GetProofsToAggregate_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(db.Txer)) + }) + return _c +} + +func (_c *StorageInterfaceMock_GetProofsToAggregate_Call) Return(_a0 *state.Proof, _a1 *state.Proof, _a2 error) *StorageInterfaceMock_GetProofsToAggregate_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *StorageInterfaceMock_GetProofsToAggregate_Call) RunAndReturn(run func(context.Context, db.Txer) (*state.Proof, *state.Proof, error)) *StorageInterfaceMock_GetProofsToAggregate_Call { + _c.Call.Return(run) + return _c +} + // UpdateGeneratedProof provides a mock function with given fields: ctx, proof, dbTx func (_m *StorageInterfaceMock) UpdateGeneratedProof(ctx context.Context, proof *state.Proof, dbTx db.Txer) error { ret := _m.Called(ctx, proof, dbTx) @@ -309,6 +645,36 @@ func (_m *StorageInterfaceMock) UpdateGeneratedProof(ctx context.Context, proof return r0 } +// StorageInterfaceMock_UpdateGeneratedProof_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateGeneratedProof' +type StorageInterfaceMock_UpdateGeneratedProof_Call struct { + *mock.Call +} + +// UpdateGeneratedProof is a helper method to define mock.On call +// - ctx context.Context +// - proof *state.Proof +// - dbTx db.Txer +func (_e *StorageInterfaceMock_Expecter) UpdateGeneratedProof(ctx interface{}, proof interface{}, dbTx interface{}) *StorageInterfaceMock_UpdateGeneratedProof_Call { + return &StorageInterfaceMock_UpdateGeneratedProof_Call{Call: _e.mock.On("UpdateGeneratedProof", ctx, proof, dbTx)} +} + +func (_c *StorageInterfaceMock_UpdateGeneratedProof_Call) Run(run func(ctx context.Context, proof *state.Proof, dbTx db.Txer)) *StorageInterfaceMock_UpdateGeneratedProof_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*state.Proof), args[2].(db.Txer)) + }) + return _c +} + +func (_c *StorageInterfaceMock_UpdateGeneratedProof_Call) Return(_a0 error) *StorageInterfaceMock_UpdateGeneratedProof_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *StorageInterfaceMock_UpdateGeneratedProof_Call) RunAndReturn(run func(context.Context, *state.Proof, db.Txer) error) *StorageInterfaceMock_UpdateGeneratedProof_Call { + _c.Call.Return(run) + return _c +} + // NewStorageInterfaceMock creates a new instance of StorageInterfaceMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewStorageInterfaceMock(t interface { diff --git a/aggregator/mocks/mock_synchronizer.go b/aggregator/mocks/mock_synchronizer.go index 28811e8c..ae7735b1 100644 --- a/aggregator/mocks/mock_synchronizer.go +++ b/aggregator/mocks/mock_synchronizer.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.0. DO NOT EDIT. +// Code generated by mockery. DO NOT EDIT. package mocks @@ -17,6 +17,14 @@ type SynchronizerInterfaceMock struct { mock.Mock } +type SynchronizerInterfaceMock_Expecter struct { + mock *mock.Mock +} + +func (_m *SynchronizerInterfaceMock) EXPECT() *SynchronizerInterfaceMock_Expecter { + return &SynchronizerInterfaceMock_Expecter{mock: &_m.Mock} +} + // GetL1BlockByNumber provides a mock function with given fields: ctx, blockNumber func (_m *SynchronizerInterfaceMock) GetL1BlockByNumber(ctx context.Context, blockNumber uint64) (*synchronizer.L1Block, error) { ret := _m.Called(ctx, blockNumber) @@ -47,6 +55,35 @@ func (_m *SynchronizerInterfaceMock) GetL1BlockByNumber(ctx context.Context, blo return r0, r1 } +// SynchronizerInterfaceMock_GetL1BlockByNumber_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetL1BlockByNumber' +type SynchronizerInterfaceMock_GetL1BlockByNumber_Call struct { + *mock.Call +} + +// GetL1BlockByNumber is a helper method to define mock.On call +// - ctx context.Context +// - blockNumber uint64 +func (_e *SynchronizerInterfaceMock_Expecter) GetL1BlockByNumber(ctx interface{}, blockNumber interface{}) *SynchronizerInterfaceMock_GetL1BlockByNumber_Call { + return &SynchronizerInterfaceMock_GetL1BlockByNumber_Call{Call: _e.mock.On("GetL1BlockByNumber", ctx, blockNumber)} +} + +func (_c *SynchronizerInterfaceMock_GetL1BlockByNumber_Call) Run(run func(ctx context.Context, blockNumber uint64)) *SynchronizerInterfaceMock_GetL1BlockByNumber_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uint64)) + }) + return _c +} + +func (_c *SynchronizerInterfaceMock_GetL1BlockByNumber_Call) Return(_a0 *synchronizer.L1Block, _a1 error) *SynchronizerInterfaceMock_GetL1BlockByNumber_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SynchronizerInterfaceMock_GetL1BlockByNumber_Call) RunAndReturn(run func(context.Context, uint64) (*synchronizer.L1Block, error)) *SynchronizerInterfaceMock_GetL1BlockByNumber_Call { + _c.Call.Return(run) + return _c +} + // GetL1InfoRootPerIndex provides a mock function with given fields: ctx, L1InfoTreeIndex func (_m *SynchronizerInterfaceMock) GetL1InfoRootPerIndex(ctx context.Context, L1InfoTreeIndex uint32) (common.Hash, error) { ret := _m.Called(ctx, L1InfoTreeIndex) @@ -77,6 +114,35 @@ func (_m *SynchronizerInterfaceMock) GetL1InfoRootPerIndex(ctx context.Context, return r0, r1 } +// SynchronizerInterfaceMock_GetL1InfoRootPerIndex_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetL1InfoRootPerIndex' +type SynchronizerInterfaceMock_GetL1InfoRootPerIndex_Call struct { + *mock.Call +} + +// GetL1InfoRootPerIndex is a helper method to define mock.On call +// - ctx context.Context +// - L1InfoTreeIndex uint32 +func (_e *SynchronizerInterfaceMock_Expecter) GetL1InfoRootPerIndex(ctx interface{}, L1InfoTreeIndex interface{}) *SynchronizerInterfaceMock_GetL1InfoRootPerIndex_Call { + return &SynchronizerInterfaceMock_GetL1InfoRootPerIndex_Call{Call: _e.mock.On("GetL1InfoRootPerIndex", ctx, L1InfoTreeIndex)} +} + +func (_c *SynchronizerInterfaceMock_GetL1InfoRootPerIndex_Call) Run(run func(ctx context.Context, L1InfoTreeIndex uint32)) *SynchronizerInterfaceMock_GetL1InfoRootPerIndex_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uint32)) + }) + return _c +} + +func (_c *SynchronizerInterfaceMock_GetL1InfoRootPerIndex_Call) Return(_a0 common.Hash, _a1 error) *SynchronizerInterfaceMock_GetL1InfoRootPerIndex_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SynchronizerInterfaceMock_GetL1InfoRootPerIndex_Call) RunAndReturn(run func(context.Context, uint32) (common.Hash, error)) *SynchronizerInterfaceMock_GetL1InfoRootPerIndex_Call { + _c.Call.Return(run) + return _c +} + // GetL1InfoTreeLeaves provides a mock function with given fields: ctx, indexLeaves func (_m *SynchronizerInterfaceMock) GetL1InfoTreeLeaves(ctx context.Context, indexLeaves []uint32) (map[uint32]synchronizer.L1InfoTreeLeaf, error) { ret := _m.Called(ctx, indexLeaves) @@ -107,6 +173,35 @@ func (_m *SynchronizerInterfaceMock) GetL1InfoTreeLeaves(ctx context.Context, in return r0, r1 } +// SynchronizerInterfaceMock_GetL1InfoTreeLeaves_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetL1InfoTreeLeaves' +type SynchronizerInterfaceMock_GetL1InfoTreeLeaves_Call struct { + *mock.Call +} + +// GetL1InfoTreeLeaves is a helper method to define mock.On call +// - ctx context.Context +// - indexLeaves []uint32 +func (_e *SynchronizerInterfaceMock_Expecter) GetL1InfoTreeLeaves(ctx interface{}, indexLeaves interface{}) *SynchronizerInterfaceMock_GetL1InfoTreeLeaves_Call { + return &SynchronizerInterfaceMock_GetL1InfoTreeLeaves_Call{Call: _e.mock.On("GetL1InfoTreeLeaves", ctx, indexLeaves)} +} + +func (_c *SynchronizerInterfaceMock_GetL1InfoTreeLeaves_Call) Run(run func(ctx context.Context, indexLeaves []uint32)) *SynchronizerInterfaceMock_GetL1InfoTreeLeaves_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].([]uint32)) + }) + return _c +} + +func (_c *SynchronizerInterfaceMock_GetL1InfoTreeLeaves_Call) Return(_a0 map[uint32]synchronizer.L1InfoTreeLeaf, _a1 error) *SynchronizerInterfaceMock_GetL1InfoTreeLeaves_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SynchronizerInterfaceMock_GetL1InfoTreeLeaves_Call) RunAndReturn(run func(context.Context, []uint32) (map[uint32]synchronizer.L1InfoTreeLeaf, error)) *SynchronizerInterfaceMock_GetL1InfoTreeLeaves_Call { + _c.Call.Return(run) + return _c +} + // GetLastL1Block provides a mock function with given fields: ctx func (_m *SynchronizerInterfaceMock) GetLastL1Block(ctx context.Context) (*synchronizer.L1Block, error) { ret := _m.Called(ctx) @@ -137,6 +232,34 @@ func (_m *SynchronizerInterfaceMock) GetLastL1Block(ctx context.Context) (*synch return r0, r1 } +// SynchronizerInterfaceMock_GetLastL1Block_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetLastL1Block' +type SynchronizerInterfaceMock_GetLastL1Block_Call struct { + *mock.Call +} + +// GetLastL1Block is a helper method to define mock.On call +// - ctx context.Context +func (_e *SynchronizerInterfaceMock_Expecter) GetLastL1Block(ctx interface{}) *SynchronizerInterfaceMock_GetLastL1Block_Call { + return &SynchronizerInterfaceMock_GetLastL1Block_Call{Call: _e.mock.On("GetLastL1Block", ctx)} +} + +func (_c *SynchronizerInterfaceMock_GetLastL1Block_Call) Run(run func(ctx context.Context)) *SynchronizerInterfaceMock_GetLastL1Block_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *SynchronizerInterfaceMock_GetLastL1Block_Call) Return(_a0 *synchronizer.L1Block, _a1 error) *SynchronizerInterfaceMock_GetLastL1Block_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SynchronizerInterfaceMock_GetLastL1Block_Call) RunAndReturn(run func(context.Context) (*synchronizer.L1Block, error)) *SynchronizerInterfaceMock_GetLastL1Block_Call { + _c.Call.Return(run) + return _c +} + // GetLastestVirtualBatchNumber provides a mock function with given fields: ctx func (_m *SynchronizerInterfaceMock) GetLastestVirtualBatchNumber(ctx context.Context) (uint64, error) { ret := _m.Called(ctx) @@ -165,6 +288,34 @@ func (_m *SynchronizerInterfaceMock) GetLastestVirtualBatchNumber(ctx context.Co return r0, r1 } +// SynchronizerInterfaceMock_GetLastestVirtualBatchNumber_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetLastestVirtualBatchNumber' +type SynchronizerInterfaceMock_GetLastestVirtualBatchNumber_Call struct { + *mock.Call +} + +// GetLastestVirtualBatchNumber is a helper method to define mock.On call +// - ctx context.Context +func (_e *SynchronizerInterfaceMock_Expecter) GetLastestVirtualBatchNumber(ctx interface{}) *SynchronizerInterfaceMock_GetLastestVirtualBatchNumber_Call { + return &SynchronizerInterfaceMock_GetLastestVirtualBatchNumber_Call{Call: _e.mock.On("GetLastestVirtualBatchNumber", ctx)} +} + +func (_c *SynchronizerInterfaceMock_GetLastestVirtualBatchNumber_Call) Run(run func(ctx context.Context)) *SynchronizerInterfaceMock_GetLastestVirtualBatchNumber_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *SynchronizerInterfaceMock_GetLastestVirtualBatchNumber_Call) Return(_a0 uint64, _a1 error) *SynchronizerInterfaceMock_GetLastestVirtualBatchNumber_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SynchronizerInterfaceMock_GetLastestVirtualBatchNumber_Call) RunAndReturn(run func(context.Context) (uint64, error)) *SynchronizerInterfaceMock_GetLastestVirtualBatchNumber_Call { + _c.Call.Return(run) + return _c +} + // GetLeafsByL1InfoRoot provides a mock function with given fields: ctx, l1InfoRoot func (_m *SynchronizerInterfaceMock) GetLeafsByL1InfoRoot(ctx context.Context, l1InfoRoot common.Hash) ([]synchronizer.L1InfoTreeLeaf, error) { ret := _m.Called(ctx, l1InfoRoot) @@ -195,6 +346,35 @@ func (_m *SynchronizerInterfaceMock) GetLeafsByL1InfoRoot(ctx context.Context, l return r0, r1 } +// SynchronizerInterfaceMock_GetLeafsByL1InfoRoot_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetLeafsByL1InfoRoot' +type SynchronizerInterfaceMock_GetLeafsByL1InfoRoot_Call struct { + *mock.Call +} + +// GetLeafsByL1InfoRoot is a helper method to define mock.On call +// - ctx context.Context +// - l1InfoRoot common.Hash +func (_e *SynchronizerInterfaceMock_Expecter) GetLeafsByL1InfoRoot(ctx interface{}, l1InfoRoot interface{}) *SynchronizerInterfaceMock_GetLeafsByL1InfoRoot_Call { + return &SynchronizerInterfaceMock_GetLeafsByL1InfoRoot_Call{Call: _e.mock.On("GetLeafsByL1InfoRoot", ctx, l1InfoRoot)} +} + +func (_c *SynchronizerInterfaceMock_GetLeafsByL1InfoRoot_Call) Run(run func(ctx context.Context, l1InfoRoot common.Hash)) *SynchronizerInterfaceMock_GetLeafsByL1InfoRoot_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(common.Hash)) + }) + return _c +} + +func (_c *SynchronizerInterfaceMock_GetLeafsByL1InfoRoot_Call) Return(_a0 []synchronizer.L1InfoTreeLeaf, _a1 error) *SynchronizerInterfaceMock_GetLeafsByL1InfoRoot_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SynchronizerInterfaceMock_GetLeafsByL1InfoRoot_Call) RunAndReturn(run func(context.Context, common.Hash) ([]synchronizer.L1InfoTreeLeaf, error)) *SynchronizerInterfaceMock_GetLeafsByL1InfoRoot_Call { + _c.Call.Return(run) + return _c +} + // GetSequenceByBatchNumber provides a mock function with given fields: ctx, batchNumber func (_m *SynchronizerInterfaceMock) GetSequenceByBatchNumber(ctx context.Context, batchNumber uint64) (*synchronizer.SequencedBatches, error) { ret := _m.Called(ctx, batchNumber) @@ -225,6 +405,35 @@ func (_m *SynchronizerInterfaceMock) GetSequenceByBatchNumber(ctx context.Contex return r0, r1 } +// SynchronizerInterfaceMock_GetSequenceByBatchNumber_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSequenceByBatchNumber' +type SynchronizerInterfaceMock_GetSequenceByBatchNumber_Call struct { + *mock.Call +} + +// GetSequenceByBatchNumber is a helper method to define mock.On call +// - ctx context.Context +// - batchNumber uint64 +func (_e *SynchronizerInterfaceMock_Expecter) GetSequenceByBatchNumber(ctx interface{}, batchNumber interface{}) *SynchronizerInterfaceMock_GetSequenceByBatchNumber_Call { + return &SynchronizerInterfaceMock_GetSequenceByBatchNumber_Call{Call: _e.mock.On("GetSequenceByBatchNumber", ctx, batchNumber)} +} + +func (_c *SynchronizerInterfaceMock_GetSequenceByBatchNumber_Call) Run(run func(ctx context.Context, batchNumber uint64)) *SynchronizerInterfaceMock_GetSequenceByBatchNumber_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uint64)) + }) + return _c +} + +func (_c *SynchronizerInterfaceMock_GetSequenceByBatchNumber_Call) Return(_a0 *synchronizer.SequencedBatches, _a1 error) *SynchronizerInterfaceMock_GetSequenceByBatchNumber_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SynchronizerInterfaceMock_GetSequenceByBatchNumber_Call) RunAndReturn(run func(context.Context, uint64) (*synchronizer.SequencedBatches, error)) *SynchronizerInterfaceMock_GetSequenceByBatchNumber_Call { + _c.Call.Return(run) + return _c +} + // GetVirtualBatchByBatchNumber provides a mock function with given fields: ctx, batchNumber func (_m *SynchronizerInterfaceMock) GetVirtualBatchByBatchNumber(ctx context.Context, batchNumber uint64) (*synchronizer.VirtualBatch, error) { ret := _m.Called(ctx, batchNumber) @@ -255,7 +464,36 @@ func (_m *SynchronizerInterfaceMock) GetVirtualBatchByBatchNumber(ctx context.Co return r0, r1 } -// IsSynced provides a mock function with given fields: +// SynchronizerInterfaceMock_GetVirtualBatchByBatchNumber_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetVirtualBatchByBatchNumber' +type SynchronizerInterfaceMock_GetVirtualBatchByBatchNumber_Call struct { + *mock.Call +} + +// GetVirtualBatchByBatchNumber is a helper method to define mock.On call +// - ctx context.Context +// - batchNumber uint64 +func (_e *SynchronizerInterfaceMock_Expecter) GetVirtualBatchByBatchNumber(ctx interface{}, batchNumber interface{}) *SynchronizerInterfaceMock_GetVirtualBatchByBatchNumber_Call { + return &SynchronizerInterfaceMock_GetVirtualBatchByBatchNumber_Call{Call: _e.mock.On("GetVirtualBatchByBatchNumber", ctx, batchNumber)} +} + +func (_c *SynchronizerInterfaceMock_GetVirtualBatchByBatchNumber_Call) Run(run func(ctx context.Context, batchNumber uint64)) *SynchronizerInterfaceMock_GetVirtualBatchByBatchNumber_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(uint64)) + }) + return _c +} + +func (_c *SynchronizerInterfaceMock_GetVirtualBatchByBatchNumber_Call) Return(_a0 *synchronizer.VirtualBatch, _a1 error) *SynchronizerInterfaceMock_GetVirtualBatchByBatchNumber_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *SynchronizerInterfaceMock_GetVirtualBatchByBatchNumber_Call) RunAndReturn(run func(context.Context, uint64) (*synchronizer.VirtualBatch, error)) *SynchronizerInterfaceMock_GetVirtualBatchByBatchNumber_Call { + _c.Call.Return(run) + return _c +} + +// IsSynced provides a mock function with no fields func (_m *SynchronizerInterfaceMock) IsSynced() bool { ret := _m.Called() @@ -273,21 +511,131 @@ func (_m *SynchronizerInterfaceMock) IsSynced() bool { return r0 } +// SynchronizerInterfaceMock_IsSynced_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsSynced' +type SynchronizerInterfaceMock_IsSynced_Call struct { + *mock.Call +} + +// IsSynced is a helper method to define mock.On call +func (_e *SynchronizerInterfaceMock_Expecter) IsSynced() *SynchronizerInterfaceMock_IsSynced_Call { + return &SynchronizerInterfaceMock_IsSynced_Call{Call: _e.mock.On("IsSynced")} +} + +func (_c *SynchronizerInterfaceMock_IsSynced_Call) Run(run func()) *SynchronizerInterfaceMock_IsSynced_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *SynchronizerInterfaceMock_IsSynced_Call) Return(_a0 bool) *SynchronizerInterfaceMock_IsSynced_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *SynchronizerInterfaceMock_IsSynced_Call) RunAndReturn(run func() bool) *SynchronizerInterfaceMock_IsSynced_Call { + _c.Call.Return(run) + return _c +} + // SetCallbackOnReorgDone provides a mock function with given fields: callback func (_m *SynchronizerInterfaceMock) SetCallbackOnReorgDone(callback func(synchronizer.ReorgExecutionResult)) { _m.Called(callback) } +// SynchronizerInterfaceMock_SetCallbackOnReorgDone_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetCallbackOnReorgDone' +type SynchronizerInterfaceMock_SetCallbackOnReorgDone_Call struct { + *mock.Call +} + +// SetCallbackOnReorgDone is a helper method to define mock.On call +// - callback func(synchronizer.ReorgExecutionResult) +func (_e *SynchronizerInterfaceMock_Expecter) SetCallbackOnReorgDone(callback interface{}) *SynchronizerInterfaceMock_SetCallbackOnReorgDone_Call { + return &SynchronizerInterfaceMock_SetCallbackOnReorgDone_Call{Call: _e.mock.On("SetCallbackOnReorgDone", callback)} +} + +func (_c *SynchronizerInterfaceMock_SetCallbackOnReorgDone_Call) Run(run func(callback func(synchronizer.ReorgExecutionResult))) *SynchronizerInterfaceMock_SetCallbackOnReorgDone_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(func(synchronizer.ReorgExecutionResult))) + }) + return _c +} + +func (_c *SynchronizerInterfaceMock_SetCallbackOnReorgDone_Call) Return() *SynchronizerInterfaceMock_SetCallbackOnReorgDone_Call { + _c.Call.Return() + return _c +} + +func (_c *SynchronizerInterfaceMock_SetCallbackOnReorgDone_Call) RunAndReturn(run func(func(synchronizer.ReorgExecutionResult))) *SynchronizerInterfaceMock_SetCallbackOnReorgDone_Call { + _c.Run(run) + return _c +} + // SetCallbackOnRollbackBatches provides a mock function with given fields: callback func (_m *SynchronizerInterfaceMock) SetCallbackOnRollbackBatches(callback func(synchronizer.RollbackBatchesData)) { _m.Called(callback) } -// Stop provides a mock function with given fields: +// SynchronizerInterfaceMock_SetCallbackOnRollbackBatches_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetCallbackOnRollbackBatches' +type SynchronizerInterfaceMock_SetCallbackOnRollbackBatches_Call struct { + *mock.Call +} + +// SetCallbackOnRollbackBatches is a helper method to define mock.On call +// - callback func(synchronizer.RollbackBatchesData) +func (_e *SynchronizerInterfaceMock_Expecter) SetCallbackOnRollbackBatches(callback interface{}) *SynchronizerInterfaceMock_SetCallbackOnRollbackBatches_Call { + return &SynchronizerInterfaceMock_SetCallbackOnRollbackBatches_Call{Call: _e.mock.On("SetCallbackOnRollbackBatches", callback)} +} + +func (_c *SynchronizerInterfaceMock_SetCallbackOnRollbackBatches_Call) Run(run func(callback func(synchronizer.RollbackBatchesData))) *SynchronizerInterfaceMock_SetCallbackOnRollbackBatches_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(func(synchronizer.RollbackBatchesData))) + }) + return _c +} + +func (_c *SynchronizerInterfaceMock_SetCallbackOnRollbackBatches_Call) Return() *SynchronizerInterfaceMock_SetCallbackOnRollbackBatches_Call { + _c.Call.Return() + return _c +} + +func (_c *SynchronizerInterfaceMock_SetCallbackOnRollbackBatches_Call) RunAndReturn(run func(func(synchronizer.RollbackBatchesData))) *SynchronizerInterfaceMock_SetCallbackOnRollbackBatches_Call { + _c.Run(run) + return _c +} + +// Stop provides a mock function with no fields func (_m *SynchronizerInterfaceMock) Stop() { _m.Called() } +// SynchronizerInterfaceMock_Stop_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Stop' +type SynchronizerInterfaceMock_Stop_Call struct { + *mock.Call +} + +// Stop is a helper method to define mock.On call +func (_e *SynchronizerInterfaceMock_Expecter) Stop() *SynchronizerInterfaceMock_Stop_Call { + return &SynchronizerInterfaceMock_Stop_Call{Call: _e.mock.On("Stop")} +} + +func (_c *SynchronizerInterfaceMock_Stop_Call) Run(run func()) *SynchronizerInterfaceMock_Stop_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *SynchronizerInterfaceMock_Stop_Call) Return() *SynchronizerInterfaceMock_Stop_Call { + _c.Call.Return() + return _c +} + +func (_c *SynchronizerInterfaceMock_Stop_Call) RunAndReturn(run func()) *SynchronizerInterfaceMock_Stop_Call { + _c.Run(run) + return _c +} + // Sync provides a mock function with given fields: returnOnSync func (_m *SynchronizerInterfaceMock) Sync(returnOnSync bool) error { ret := _m.Called(returnOnSync) @@ -306,6 +654,34 @@ func (_m *SynchronizerInterfaceMock) Sync(returnOnSync bool) error { return r0 } +// SynchronizerInterfaceMock_Sync_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Sync' +type SynchronizerInterfaceMock_Sync_Call struct { + *mock.Call +} + +// Sync is a helper method to define mock.On call +// - returnOnSync bool +func (_e *SynchronizerInterfaceMock_Expecter) Sync(returnOnSync interface{}) *SynchronizerInterfaceMock_Sync_Call { + return &SynchronizerInterfaceMock_Sync_Call{Call: _e.mock.On("Sync", returnOnSync)} +} + +func (_c *SynchronizerInterfaceMock_Sync_Call) Run(run func(returnOnSync bool)) *SynchronizerInterfaceMock_Sync_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(bool)) + }) + return _c +} + +func (_c *SynchronizerInterfaceMock_Sync_Call) Return(_a0 error) *SynchronizerInterfaceMock_Sync_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *SynchronizerInterfaceMock_Sync_Call) RunAndReturn(run func(bool) error) *SynchronizerInterfaceMock_Sync_Call { + _c.Call.Return(run) + return _c +} + // NewSynchronizerInterfaceMock creates a new instance of SynchronizerInterfaceMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewSynchronizerInterfaceMock(t interface { diff --git a/aggregator/mocks/mock_txer.go b/aggregator/mocks/mock_txer.go index 1de07124..39a98d03 100644 --- a/aggregator/mocks/mock_txer.go +++ b/aggregator/mocks/mock_txer.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.0. DO NOT EDIT. +// Code generated by mockery. DO NOT EDIT. package mocks @@ -13,17 +13,81 @@ type TxerMock struct { mock.Mock } +type TxerMock_Expecter struct { + mock *mock.Mock +} + +func (_m *TxerMock) EXPECT() *TxerMock_Expecter { + return &TxerMock_Expecter{mock: &_m.Mock} +} + // AddCommitCallback provides a mock function with given fields: cb func (_m *TxerMock) AddCommitCallback(cb func()) { _m.Called(cb) } +// TxerMock_AddCommitCallback_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddCommitCallback' +type TxerMock_AddCommitCallback_Call struct { + *mock.Call +} + +// AddCommitCallback is a helper method to define mock.On call +// - cb func() +func (_e *TxerMock_Expecter) AddCommitCallback(cb interface{}) *TxerMock_AddCommitCallback_Call { + return &TxerMock_AddCommitCallback_Call{Call: _e.mock.On("AddCommitCallback", cb)} +} + +func (_c *TxerMock_AddCommitCallback_Call) Run(run func(cb func())) *TxerMock_AddCommitCallback_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(func())) + }) + return _c +} + +func (_c *TxerMock_AddCommitCallback_Call) Return() *TxerMock_AddCommitCallback_Call { + _c.Call.Return() + return _c +} + +func (_c *TxerMock_AddCommitCallback_Call) RunAndReturn(run func(func())) *TxerMock_AddCommitCallback_Call { + _c.Run(run) + return _c +} + // AddRollbackCallback provides a mock function with given fields: cb func (_m *TxerMock) AddRollbackCallback(cb func()) { _m.Called(cb) } -// Commit provides a mock function with given fields: +// TxerMock_AddRollbackCallback_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddRollbackCallback' +type TxerMock_AddRollbackCallback_Call struct { + *mock.Call +} + +// AddRollbackCallback is a helper method to define mock.On call +// - cb func() +func (_e *TxerMock_Expecter) AddRollbackCallback(cb interface{}) *TxerMock_AddRollbackCallback_Call { + return &TxerMock_AddRollbackCallback_Call{Call: _e.mock.On("AddRollbackCallback", cb)} +} + +func (_c *TxerMock_AddRollbackCallback_Call) Run(run func(cb func())) *TxerMock_AddRollbackCallback_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(func())) + }) + return _c +} + +func (_c *TxerMock_AddRollbackCallback_Call) Return() *TxerMock_AddRollbackCallback_Call { + _c.Call.Return() + return _c +} + +func (_c *TxerMock_AddRollbackCallback_Call) RunAndReturn(run func(func())) *TxerMock_AddRollbackCallback_Call { + _c.Run(run) + return _c +} + +// Commit provides a mock function with no fields func (_m *TxerMock) Commit() error { ret := _m.Called() @@ -41,6 +105,33 @@ func (_m *TxerMock) Commit() error { return r0 } +// TxerMock_Commit_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Commit' +type TxerMock_Commit_Call struct { + *mock.Call +} + +// Commit is a helper method to define mock.On call +func (_e *TxerMock_Expecter) Commit() *TxerMock_Commit_Call { + return &TxerMock_Commit_Call{Call: _e.mock.On("Commit")} +} + +func (_c *TxerMock_Commit_Call) Run(run func()) *TxerMock_Commit_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *TxerMock_Commit_Call) Return(_a0 error) *TxerMock_Commit_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *TxerMock_Commit_Call) RunAndReturn(run func() error) *TxerMock_Commit_Call { + _c.Call.Return(run) + return _c +} + // Exec provides a mock function with given fields: query, args func (_m *TxerMock) Exec(query string, args ...interface{}) (sql.Result, error) { var _ca []interface{} @@ -74,6 +165,42 @@ func (_m *TxerMock) Exec(query string, args ...interface{}) (sql.Result, error) return r0, r1 } +// TxerMock_Exec_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Exec' +type TxerMock_Exec_Call struct { + *mock.Call +} + +// Exec is a helper method to define mock.On call +// - query string +// - args ...interface{} +func (_e *TxerMock_Expecter) Exec(query interface{}, args ...interface{}) *TxerMock_Exec_Call { + return &TxerMock_Exec_Call{Call: _e.mock.On("Exec", + append([]interface{}{query}, args...)...)} +} + +func (_c *TxerMock_Exec_Call) Run(run func(query string, args ...interface{})) *TxerMock_Exec_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]interface{}, len(args)-1) + for i, a := range args[1:] { + if a != nil { + variadicArgs[i] = a.(interface{}) + } + } + run(args[0].(string), variadicArgs...) + }) + return _c +} + +func (_c *TxerMock_Exec_Call) Return(_a0 sql.Result, _a1 error) *TxerMock_Exec_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *TxerMock_Exec_Call) RunAndReturn(run func(string, ...interface{}) (sql.Result, error)) *TxerMock_Exec_Call { + _c.Call.Return(run) + return _c +} + // Query provides a mock function with given fields: query, args func (_m *TxerMock) Query(query string, args ...interface{}) (*sql.Rows, error) { var _ca []interface{} @@ -107,6 +234,42 @@ func (_m *TxerMock) Query(query string, args ...interface{}) (*sql.Rows, error) return r0, r1 } +// TxerMock_Query_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Query' +type TxerMock_Query_Call struct { + *mock.Call +} + +// Query is a helper method to define mock.On call +// - query string +// - args ...interface{} +func (_e *TxerMock_Expecter) Query(query interface{}, args ...interface{}) *TxerMock_Query_Call { + return &TxerMock_Query_Call{Call: _e.mock.On("Query", + append([]interface{}{query}, args...)...)} +} + +func (_c *TxerMock_Query_Call) Run(run func(query string, args ...interface{})) *TxerMock_Query_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]interface{}, len(args)-1) + for i, a := range args[1:] { + if a != nil { + variadicArgs[i] = a.(interface{}) + } + } + run(args[0].(string), variadicArgs...) + }) + return _c +} + +func (_c *TxerMock_Query_Call) Return(_a0 *sql.Rows, _a1 error) *TxerMock_Query_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *TxerMock_Query_Call) RunAndReturn(run func(string, ...interface{}) (*sql.Rows, error)) *TxerMock_Query_Call { + _c.Call.Return(run) + return _c +} + // QueryRow provides a mock function with given fields: query, args func (_m *TxerMock) QueryRow(query string, args ...interface{}) *sql.Row { var _ca []interface{} @@ -130,7 +293,43 @@ func (_m *TxerMock) QueryRow(query string, args ...interface{}) *sql.Row { return r0 } -// Rollback provides a mock function with given fields: +// TxerMock_QueryRow_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'QueryRow' +type TxerMock_QueryRow_Call struct { + *mock.Call +} + +// QueryRow is a helper method to define mock.On call +// - query string +// - args ...interface{} +func (_e *TxerMock_Expecter) QueryRow(query interface{}, args ...interface{}) *TxerMock_QueryRow_Call { + return &TxerMock_QueryRow_Call{Call: _e.mock.On("QueryRow", + append([]interface{}{query}, args...)...)} +} + +func (_c *TxerMock_QueryRow_Call) Run(run func(query string, args ...interface{})) *TxerMock_QueryRow_Call { + _c.Call.Run(func(args mock.Arguments) { + variadicArgs := make([]interface{}, len(args)-1) + for i, a := range args[1:] { + if a != nil { + variadicArgs[i] = a.(interface{}) + } + } + run(args[0].(string), variadicArgs...) + }) + return _c +} + +func (_c *TxerMock_QueryRow_Call) Return(_a0 *sql.Row) *TxerMock_QueryRow_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *TxerMock_QueryRow_Call) RunAndReturn(run func(string, ...interface{}) *sql.Row) *TxerMock_QueryRow_Call { + _c.Call.Return(run) + return _c +} + +// Rollback provides a mock function with no fields func (_m *TxerMock) Rollback() error { ret := _m.Called() @@ -148,6 +347,33 @@ func (_m *TxerMock) Rollback() error { return r0 } +// TxerMock_Rollback_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Rollback' +type TxerMock_Rollback_Call struct { + *mock.Call +} + +// Rollback is a helper method to define mock.On call +func (_e *TxerMock_Expecter) Rollback() *TxerMock_Rollback_Call { + return &TxerMock_Rollback_Call{Call: _e.mock.On("Rollback")} +} + +func (_c *TxerMock_Rollback_Call) Run(run func()) *TxerMock_Rollback_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *TxerMock_Rollback_Call) Return(_a0 error) *TxerMock_Rollback_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *TxerMock_Rollback_Call) RunAndReturn(run func() error) *TxerMock_Rollback_Call { + _c.Call.Return(run) + return _c +} + // NewTxerMock creates a new instance of TxerMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewTxerMock(t interface { diff --git a/aggregator/prover/mocks/mock_channel.go b/aggregator/prover/mocks/mock_channel.go index d125896d..9ed3c47b 100644 --- a/aggregator/prover/mocks/mock_channel.go +++ b/aggregator/prover/mocks/mock_channel.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.0. DO NOT EDIT. +// Code generated by mockery. DO NOT EDIT. package mocks @@ -16,7 +16,15 @@ type ChannelMock struct { mock.Mock } -// Context provides a mock function with given fields: +type ChannelMock_Expecter struct { + mock *mock.Mock +} + +func (_m *ChannelMock) EXPECT() *ChannelMock_Expecter { + return &ChannelMock_Expecter{mock: &_m.Mock} +} + +// Context provides a mock function with no fields func (_m *ChannelMock) Context() context.Context { ret := _m.Called() @@ -36,7 +44,34 @@ func (_m *ChannelMock) Context() context.Context { return r0 } -// Recv provides a mock function with given fields: +// ChannelMock_Context_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Context' +type ChannelMock_Context_Call struct { + *mock.Call +} + +// Context is a helper method to define mock.On call +func (_e *ChannelMock_Expecter) Context() *ChannelMock_Context_Call { + return &ChannelMock_Context_Call{Call: _e.mock.On("Context")} +} + +func (_c *ChannelMock_Context_Call) Run(run func()) *ChannelMock_Context_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *ChannelMock_Context_Call) Return(_a0 context.Context) *ChannelMock_Context_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ChannelMock_Context_Call) RunAndReturn(run func() context.Context) *ChannelMock_Context_Call { + _c.Call.Return(run) + return _c +} + +// Recv provides a mock function with no fields func (_m *ChannelMock) Recv() (*prover.ProverMessage, error) { ret := _m.Called() @@ -66,6 +101,33 @@ func (_m *ChannelMock) Recv() (*prover.ProverMessage, error) { return r0, r1 } +// ChannelMock_Recv_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Recv' +type ChannelMock_Recv_Call struct { + *mock.Call +} + +// Recv is a helper method to define mock.On call +func (_e *ChannelMock_Expecter) Recv() *ChannelMock_Recv_Call { + return &ChannelMock_Recv_Call{Call: _e.mock.On("Recv")} +} + +func (_c *ChannelMock_Recv_Call) Run(run func()) *ChannelMock_Recv_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *ChannelMock_Recv_Call) Return(_a0 *prover.ProverMessage, _a1 error) *ChannelMock_Recv_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ChannelMock_Recv_Call) RunAndReturn(run func() (*prover.ProverMessage, error)) *ChannelMock_Recv_Call { + _c.Call.Return(run) + return _c +} + // RecvMsg provides a mock function with given fields: m func (_m *ChannelMock) RecvMsg(m interface{}) error { ret := _m.Called(m) @@ -84,6 +146,34 @@ func (_m *ChannelMock) RecvMsg(m interface{}) error { return r0 } +// ChannelMock_RecvMsg_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RecvMsg' +type ChannelMock_RecvMsg_Call struct { + *mock.Call +} + +// RecvMsg is a helper method to define mock.On call +// - m interface{} +func (_e *ChannelMock_Expecter) RecvMsg(m interface{}) *ChannelMock_RecvMsg_Call { + return &ChannelMock_RecvMsg_Call{Call: _e.mock.On("RecvMsg", m)} +} + +func (_c *ChannelMock_RecvMsg_Call) Run(run func(m interface{})) *ChannelMock_RecvMsg_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(interface{})) + }) + return _c +} + +func (_c *ChannelMock_RecvMsg_Call) Return(_a0 error) *ChannelMock_RecvMsg_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ChannelMock_RecvMsg_Call) RunAndReturn(run func(interface{}) error) *ChannelMock_RecvMsg_Call { + _c.Call.Return(run) + return _c +} + // Send provides a mock function with given fields: _a0 func (_m *ChannelMock) Send(_a0 *prover.AggregatorMessage) error { ret := _m.Called(_a0) @@ -102,6 +192,34 @@ func (_m *ChannelMock) Send(_a0 *prover.AggregatorMessage) error { return r0 } +// ChannelMock_Send_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Send' +type ChannelMock_Send_Call struct { + *mock.Call +} + +// Send is a helper method to define mock.On call +// - _a0 *prover.AggregatorMessage +func (_e *ChannelMock_Expecter) Send(_a0 interface{}) *ChannelMock_Send_Call { + return &ChannelMock_Send_Call{Call: _e.mock.On("Send", _a0)} +} + +func (_c *ChannelMock_Send_Call) Run(run func(_a0 *prover.AggregatorMessage)) *ChannelMock_Send_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*prover.AggregatorMessage)) + }) + return _c +} + +func (_c *ChannelMock_Send_Call) Return(_a0 error) *ChannelMock_Send_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ChannelMock_Send_Call) RunAndReturn(run func(*prover.AggregatorMessage) error) *ChannelMock_Send_Call { + _c.Call.Return(run) + return _c +} + // SendHeader provides a mock function with given fields: _a0 func (_m *ChannelMock) SendHeader(_a0 metadata.MD) error { ret := _m.Called(_a0) @@ -120,6 +238,34 @@ func (_m *ChannelMock) SendHeader(_a0 metadata.MD) error { return r0 } +// ChannelMock_SendHeader_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SendHeader' +type ChannelMock_SendHeader_Call struct { + *mock.Call +} + +// SendHeader is a helper method to define mock.On call +// - _a0 metadata.MD +func (_e *ChannelMock_Expecter) SendHeader(_a0 interface{}) *ChannelMock_SendHeader_Call { + return &ChannelMock_SendHeader_Call{Call: _e.mock.On("SendHeader", _a0)} +} + +func (_c *ChannelMock_SendHeader_Call) Run(run func(_a0 metadata.MD)) *ChannelMock_SendHeader_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(metadata.MD)) + }) + return _c +} + +func (_c *ChannelMock_SendHeader_Call) Return(_a0 error) *ChannelMock_SendHeader_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ChannelMock_SendHeader_Call) RunAndReturn(run func(metadata.MD) error) *ChannelMock_SendHeader_Call { + _c.Call.Return(run) + return _c +} + // SendMsg provides a mock function with given fields: m func (_m *ChannelMock) SendMsg(m interface{}) error { ret := _m.Called(m) @@ -138,6 +284,34 @@ func (_m *ChannelMock) SendMsg(m interface{}) error { return r0 } +// ChannelMock_SendMsg_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SendMsg' +type ChannelMock_SendMsg_Call struct { + *mock.Call +} + +// SendMsg is a helper method to define mock.On call +// - m interface{} +func (_e *ChannelMock_Expecter) SendMsg(m interface{}) *ChannelMock_SendMsg_Call { + return &ChannelMock_SendMsg_Call{Call: _e.mock.On("SendMsg", m)} +} + +func (_c *ChannelMock_SendMsg_Call) Run(run func(m interface{})) *ChannelMock_SendMsg_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(interface{})) + }) + return _c +} + +func (_c *ChannelMock_SendMsg_Call) Return(_a0 error) *ChannelMock_SendMsg_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ChannelMock_SendMsg_Call) RunAndReturn(run func(interface{}) error) *ChannelMock_SendMsg_Call { + _c.Call.Return(run) + return _c +} + // SetHeader provides a mock function with given fields: _a0 func (_m *ChannelMock) SetHeader(_a0 metadata.MD) error { ret := _m.Called(_a0) @@ -156,11 +330,67 @@ func (_m *ChannelMock) SetHeader(_a0 metadata.MD) error { return r0 } +// ChannelMock_SetHeader_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetHeader' +type ChannelMock_SetHeader_Call struct { + *mock.Call +} + +// SetHeader is a helper method to define mock.On call +// - _a0 metadata.MD +func (_e *ChannelMock_Expecter) SetHeader(_a0 interface{}) *ChannelMock_SetHeader_Call { + return &ChannelMock_SetHeader_Call{Call: _e.mock.On("SetHeader", _a0)} +} + +func (_c *ChannelMock_SetHeader_Call) Run(run func(_a0 metadata.MD)) *ChannelMock_SetHeader_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(metadata.MD)) + }) + return _c +} + +func (_c *ChannelMock_SetHeader_Call) Return(_a0 error) *ChannelMock_SetHeader_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ChannelMock_SetHeader_Call) RunAndReturn(run func(metadata.MD) error) *ChannelMock_SetHeader_Call { + _c.Call.Return(run) + return _c +} + // SetTrailer provides a mock function with given fields: _a0 func (_m *ChannelMock) SetTrailer(_a0 metadata.MD) { _m.Called(_a0) } +// ChannelMock_SetTrailer_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetTrailer' +type ChannelMock_SetTrailer_Call struct { + *mock.Call +} + +// SetTrailer is a helper method to define mock.On call +// - _a0 metadata.MD +func (_e *ChannelMock_Expecter) SetTrailer(_a0 interface{}) *ChannelMock_SetTrailer_Call { + return &ChannelMock_SetTrailer_Call{Call: _e.mock.On("SetTrailer", _a0)} +} + +func (_c *ChannelMock_SetTrailer_Call) Run(run func(_a0 metadata.MD)) *ChannelMock_SetTrailer_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(metadata.MD)) + }) + return _c +} + +func (_c *ChannelMock_SetTrailer_Call) Return() *ChannelMock_SetTrailer_Call { + _c.Call.Return() + return _c +} + +func (_c *ChannelMock_SetTrailer_Call) RunAndReturn(run func(metadata.MD)) *ChannelMock_SetTrailer_Call { + _c.Run(run) + return _c +} + // NewChannelMock creates a new instance of ChannelMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewChannelMock(t interface { diff --git a/aggsender/mocks/agg_sender_storage.go b/aggsender/mocks/agg_sender_storage.go index b6337180..9c0d20a6 100644 --- a/aggsender/mocks/agg_sender_storage.go +++ b/aggsender/mocks/agg_sender_storage.go @@ -189,7 +189,7 @@ func (_c *AggSenderStorage_GetCertificatesByStatus_Call) RunAndReturn(run func([ return _c } -// GetLastSentCertificate provides a mock function with given fields: +// GetLastSentCertificate provides a mock function with no fields func (_m *AggSenderStorage) GetLastSentCertificate() (*types.CertificateInfo, error) { ret := _m.Called() diff --git a/aggsender/mocks/block_notifier.go b/aggsender/mocks/block_notifier.go index f8fc556d..24d751b3 100644 --- a/aggsender/mocks/block_notifier.go +++ b/aggsender/mocks/block_notifier.go @@ -20,7 +20,7 @@ func (_m *BlockNotifier) EXPECT() *BlockNotifier_Expecter { return &BlockNotifier_Expecter{mock: &_m.Mock} } -// String provides a mock function with given fields: +// String provides a mock function with no fields func (_m *BlockNotifier) String() string { ret := _m.Called() diff --git a/aggsender/mocks/epoch_notifier.go b/aggsender/mocks/epoch_notifier.go index fb8bf35f..0da06d93 100644 --- a/aggsender/mocks/epoch_notifier.go +++ b/aggsender/mocks/epoch_notifier.go @@ -51,11 +51,11 @@ func (_c *EpochNotifier_Start_Call) Return() *EpochNotifier_Start_Call { } func (_c *EpochNotifier_Start_Call) RunAndReturn(run func(context.Context)) *EpochNotifier_Start_Call { - _c.Call.Return(run) + _c.Run(run) return _c } -// String provides a mock function with given fields: +// String provides a mock function with no fields func (_m *EpochNotifier) String() string { ret := _m.Called() diff --git a/aggsender/mocks/generic_subscriber.go b/aggsender/mocks/generic_subscriber.go index b4bee4b4..59a27642 100644 --- a/aggsender/mocks/generic_subscriber.go +++ b/aggsender/mocks/generic_subscriber.go @@ -46,7 +46,7 @@ func (_c *GenericSubscriber_Publish_Call[T]) Return() *GenericSubscriber_Publish } func (_c *GenericSubscriber_Publish_Call[T]) RunAndReturn(run func(T)) *GenericSubscriber_Publish_Call[T] { - _c.Call.Return(run) + _c.Run(run) return _c } diff --git a/aggsender/mocks/l2_bridge_syncer.go b/aggsender/mocks/l2_bridge_syncer.go index 800007ff..b8eeb084 100644 --- a/aggsender/mocks/l2_bridge_syncer.go +++ b/aggsender/mocks/l2_bridge_syncer.go @@ -28,7 +28,7 @@ func (_m *L2BridgeSyncer) EXPECT() *L2BridgeSyncer_Expecter { return &L2BridgeSyncer_Expecter{mock: &_m.Mock} } -// BlockFinality provides a mock function with given fields: +// BlockFinality provides a mock function with no fields func (_m *L2BridgeSyncer) BlockFinality() etherman.BlockNumberFinality { ret := _m.Called() @@ -363,7 +363,7 @@ func (_c *L2BridgeSyncer_GetLastProcessedBlock_Call) RunAndReturn(run func(conte return _c } -// OriginNetwork provides a mock function with given fields: +// OriginNetwork provides a mock function with no fields func (_m *L2BridgeSyncer) OriginNetwork() uint32 { ret := _m.Called() diff --git a/aggsender/mocks/logger.go b/aggsender/mocks/logger.go index 54be6942..b2a845ca 100644 --- a/aggsender/mocks/logger.go +++ b/aggsender/mocks/logger.go @@ -55,7 +55,7 @@ func (_c *Logger_Debug_Call) Return() *Logger_Debug_Call { } func (_c *Logger_Debug_Call) RunAndReturn(run func(...interface{})) *Logger_Debug_Call { - _c.Call.Return(run) + _c.Run(run) return _c } @@ -99,7 +99,7 @@ func (_c *Logger_Debugf_Call) Return() *Logger_Debugf_Call { } func (_c *Logger_Debugf_Call) RunAndReturn(run func(string, ...interface{})) *Logger_Debugf_Call { - _c.Call.Return(run) + _c.Run(run) return _c } @@ -141,7 +141,7 @@ func (_c *Logger_Error_Call) Return() *Logger_Error_Call { } func (_c *Logger_Error_Call) RunAndReturn(run func(...interface{})) *Logger_Error_Call { - _c.Call.Return(run) + _c.Run(run) return _c } @@ -185,7 +185,7 @@ func (_c *Logger_Errorf_Call) Return() *Logger_Errorf_Call { } func (_c *Logger_Errorf_Call) RunAndReturn(run func(string, ...interface{})) *Logger_Errorf_Call { - _c.Call.Return(run) + _c.Run(run) return _c } @@ -229,7 +229,7 @@ func (_c *Logger_Fatalf_Call) Return() *Logger_Fatalf_Call { } func (_c *Logger_Fatalf_Call) RunAndReturn(run func(string, ...interface{})) *Logger_Fatalf_Call { - _c.Call.Return(run) + _c.Run(run) return _c } @@ -271,7 +271,7 @@ func (_c *Logger_Info_Call) Return() *Logger_Info_Call { } func (_c *Logger_Info_Call) RunAndReturn(run func(...interface{})) *Logger_Info_Call { - _c.Call.Return(run) + _c.Run(run) return _c } @@ -315,7 +315,7 @@ func (_c *Logger_Infof_Call) Return() *Logger_Infof_Call { } func (_c *Logger_Infof_Call) RunAndReturn(run func(string, ...interface{})) *Logger_Infof_Call { - _c.Call.Return(run) + _c.Run(run) return _c } @@ -357,7 +357,7 @@ func (_c *Logger_Warn_Call) Return() *Logger_Warn_Call { } func (_c *Logger_Warn_Call) RunAndReturn(run func(...interface{})) *Logger_Warn_Call { - _c.Call.Return(run) + _c.Run(run) return _c } @@ -401,7 +401,7 @@ func (_c *Logger_Warnf_Call) Return() *Logger_Warnf_Call { } func (_c *Logger_Warnf_Call) RunAndReturn(run func(string, ...interface{})) *Logger_Warnf_Call { - _c.Call.Return(run) + _c.Run(run) return _c } diff --git a/bridgesync/mocks/bridge_contractor.go b/bridgesync/mocks/bridge_contractor.go deleted file mode 100644 index fd559850..00000000 --- a/bridgesync/mocks/bridge_contractor.go +++ /dev/null @@ -1,93 +0,0 @@ -// Code generated by mockery. DO NOT EDIT. - -package mocks_bridgesync - -import ( - context "context" - - mock "github.com/stretchr/testify/mock" -) - -// BridgeContractor is an autogenerated mock type for the BridgeContractor type -type BridgeContractor struct { - mock.Mock -} - -type BridgeContractor_Expecter struct { - mock *mock.Mock -} - -func (_m *BridgeContractor) EXPECT() *BridgeContractor_Expecter { - return &BridgeContractor_Expecter{mock: &_m.Mock} -} - -// LastUpdatedDepositCount provides a mock function with given fields: ctx, BlockNumber -func (_m *BridgeContractor) LastUpdatedDepositCount(ctx context.Context, BlockNumber uint64) (uint32, error) { - ret := _m.Called(ctx, BlockNumber) - - if len(ret) == 0 { - panic("no return value specified for LastUpdatedDepositCount") - } - - var r0 uint32 - var r1 error - if rf, ok := ret.Get(0).(func(context.Context, uint64) (uint32, error)); ok { - return rf(ctx, BlockNumber) - } - if rf, ok := ret.Get(0).(func(context.Context, uint64) uint32); ok { - r0 = rf(ctx, BlockNumber) - } else { - r0 = ret.Get(0).(uint32) - } - - if rf, ok := ret.Get(1).(func(context.Context, uint64) error); ok { - r1 = rf(ctx, BlockNumber) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// BridgeContractor_LastUpdatedDepositCount_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LastUpdatedDepositCount' -type BridgeContractor_LastUpdatedDepositCount_Call struct { - *mock.Call -} - -// LastUpdatedDepositCount is a helper method to define mock.On call -// - ctx context.Context -// - BlockNumber uint64 -func (_e *BridgeContractor_Expecter) LastUpdatedDepositCount(ctx interface{}, BlockNumber interface{}) *BridgeContractor_LastUpdatedDepositCount_Call { - return &BridgeContractor_LastUpdatedDepositCount_Call{Call: _e.mock.On("LastUpdatedDepositCount", ctx, BlockNumber)} -} - -func (_c *BridgeContractor_LastUpdatedDepositCount_Call) Run(run func(ctx context.Context, BlockNumber uint64)) *BridgeContractor_LastUpdatedDepositCount_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(context.Context), args[1].(uint64)) - }) - return _c -} - -func (_c *BridgeContractor_LastUpdatedDepositCount_Call) Return(_a0 uint32, _a1 error) *BridgeContractor_LastUpdatedDepositCount_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *BridgeContractor_LastUpdatedDepositCount_Call) RunAndReturn(run func(context.Context, uint64) (uint32, error)) *BridgeContractor_LastUpdatedDepositCount_Call { - _c.Call.Return(run) - return _c -} - -// NewBridgeContractor creates a new instance of BridgeContractor. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -// The first argument is typically a *testing.T value. -func NewBridgeContractor(t interface { - mock.TestingT - Cleanup(func()) -}) *BridgeContractor { - mock := &BridgeContractor{} - mock.Mock.Test(t) - - t.Cleanup(func() { mock.AssertExpectations(t) }) - - return mock -} diff --git a/bridgesync/mocks/eth_clienter.go b/bridgesync/mocks/eth_clienter.go index 3d208e45..12a99a98 100644 --- a/bridgesync/mocks/eth_clienter.go +++ b/bridgesync/mocks/eth_clienter.go @@ -265,7 +265,7 @@ func (_c *EthClienter_CallContract_Call) RunAndReturn(run func(context.Context, return _c } -// Client provides a mock function with given fields: +// Client provides a mock function with no fields func (_m *EthClienter) Client() *rpc.Client { ret := _m.Called() diff --git a/dataavailability/mocks_da/da_backender.go b/dataavailability/mocks_da/da_backender.go index 773e447c..d7ae9a05 100644 --- a/dataavailability/mocks_da/da_backender.go +++ b/dataavailability/mocks_da/da_backender.go @@ -85,7 +85,7 @@ func (_c *DABackender_GetSequence_Call) RunAndReturn(run func(context.Context, [ return _c } -// Init provides a mock function with given fields: +// Init provides a mock function with no fields func (_m *DABackender) Init() error { ret := _m.Called() diff --git a/l1infotreesync/mocks/eth_clienter.go b/l1infotreesync/mocks/eth_clienter.go index 3e5897f9..270c40d9 100644 --- a/l1infotreesync/mocks/eth_clienter.go +++ b/l1infotreesync/mocks/eth_clienter.go @@ -1083,4 +1083,4 @@ func NewEthClienter(t interface { t.Cleanup(func() { mock.AssertExpectations(t) }) return mock -} \ No newline at end of file +} diff --git a/l1infotreesync/mocks/mock_reorgdetector.go b/l1infotreesync/mocks/mock_reorgdetector.go index 79c6232e..74a8afc3 100644 --- a/l1infotreesync/mocks/mock_reorgdetector.go +++ b/l1infotreesync/mocks/mock_reorgdetector.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.0. DO NOT EDIT. +// Code generated by mockery. DO NOT EDIT. package mocks_l1infotreesync @@ -17,6 +17,14 @@ type ReorgDetectorMock struct { mock.Mock } +type ReorgDetectorMock_Expecter struct { + mock *mock.Mock +} + +func (_m *ReorgDetectorMock) EXPECT() *ReorgDetectorMock_Expecter { + return &ReorgDetectorMock_Expecter{mock: &_m.Mock} +} + // AddBlockToTrack provides a mock function with given fields: ctx, id, blockNum, blockHash func (_m *ReorgDetectorMock) AddBlockToTrack(ctx context.Context, id string, blockNum uint64, blockHash common.Hash) error { ret := _m.Called(ctx, id, blockNum, blockHash) @@ -35,6 +43,37 @@ func (_m *ReorgDetectorMock) AddBlockToTrack(ctx context.Context, id string, blo return r0 } +// ReorgDetectorMock_AddBlockToTrack_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddBlockToTrack' +type ReorgDetectorMock_AddBlockToTrack_Call struct { + *mock.Call +} + +// AddBlockToTrack is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - blockNum uint64 +// - blockHash common.Hash +func (_e *ReorgDetectorMock_Expecter) AddBlockToTrack(ctx interface{}, id interface{}, blockNum interface{}, blockHash interface{}) *ReorgDetectorMock_AddBlockToTrack_Call { + return &ReorgDetectorMock_AddBlockToTrack_Call{Call: _e.mock.On("AddBlockToTrack", ctx, id, blockNum, blockHash)} +} + +func (_c *ReorgDetectorMock_AddBlockToTrack_Call) Run(run func(ctx context.Context, id string, blockNum uint64, blockHash common.Hash)) *ReorgDetectorMock_AddBlockToTrack_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(uint64), args[3].(common.Hash)) + }) + return _c +} + +func (_c *ReorgDetectorMock_AddBlockToTrack_Call) Return(_a0 error) *ReorgDetectorMock_AddBlockToTrack_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *ReorgDetectorMock_AddBlockToTrack_Call) RunAndReturn(run func(context.Context, string, uint64, common.Hash) error) *ReorgDetectorMock_AddBlockToTrack_Call { + _c.Call.Return(run) + return _c +} + // Subscribe provides a mock function with given fields: id func (_m *ReorgDetectorMock) Subscribe(id string) (*reorgdetector.Subscription, error) { ret := _m.Called(id) @@ -65,6 +104,34 @@ func (_m *ReorgDetectorMock) Subscribe(id string) (*reorgdetector.Subscription, return r0, r1 } +// ReorgDetectorMock_Subscribe_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Subscribe' +type ReorgDetectorMock_Subscribe_Call struct { + *mock.Call +} + +// Subscribe is a helper method to define mock.On call +// - id string +func (_e *ReorgDetectorMock_Expecter) Subscribe(id interface{}) *ReorgDetectorMock_Subscribe_Call { + return &ReorgDetectorMock_Subscribe_Call{Call: _e.mock.On("Subscribe", id)} +} + +func (_c *ReorgDetectorMock_Subscribe_Call) Run(run func(id string)) *ReorgDetectorMock_Subscribe_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *ReorgDetectorMock_Subscribe_Call) Return(_a0 *reorgdetector.Subscription, _a1 error) *ReorgDetectorMock_Subscribe_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *ReorgDetectorMock_Subscribe_Call) RunAndReturn(run func(string) (*reorgdetector.Subscription, error)) *ReorgDetectorMock_Subscribe_Call { + _c.Call.Return(run) + return _c +} + // NewReorgDetectorMock creates a new instance of ReorgDetectorMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewReorgDetectorMock(t interface { diff --git a/reorgdetector/mock_eth_client.go b/reorgdetector/mock_eth_client.go index 0c561ab3..1a42104b 100644 --- a/reorgdetector/mock_eth_client.go +++ b/reorgdetector/mock_eth_client.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.0. DO NOT EDIT. +// Code generated by mockery. DO NOT EDIT. package reorgdetector @@ -20,6 +20,14 @@ type EthClientMock struct { mock.Mock } +type EthClientMock_Expecter struct { + mock *mock.Mock +} + +func (_m *EthClientMock) EXPECT() *EthClientMock_Expecter { + return &EthClientMock_Expecter{mock: &_m.Mock} +} + // HeaderByHash provides a mock function with given fields: ctx, hash func (_m *EthClientMock) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error) { ret := _m.Called(ctx, hash) @@ -50,6 +58,35 @@ func (_m *EthClientMock) HeaderByHash(ctx context.Context, hash common.Hash) (*t return r0, r1 } +// EthClientMock_HeaderByHash_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HeaderByHash' +type EthClientMock_HeaderByHash_Call struct { + *mock.Call +} + +// HeaderByHash is a helper method to define mock.On call +// - ctx context.Context +// - hash common.Hash +func (_e *EthClientMock_Expecter) HeaderByHash(ctx interface{}, hash interface{}) *EthClientMock_HeaderByHash_Call { + return &EthClientMock_HeaderByHash_Call{Call: _e.mock.On("HeaderByHash", ctx, hash)} +} + +func (_c *EthClientMock_HeaderByHash_Call) Run(run func(ctx context.Context, hash common.Hash)) *EthClientMock_HeaderByHash_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(common.Hash)) + }) + return _c +} + +func (_c *EthClientMock_HeaderByHash_Call) Return(_a0 *types.Header, _a1 error) *EthClientMock_HeaderByHash_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EthClientMock_HeaderByHash_Call) RunAndReturn(run func(context.Context, common.Hash) (*types.Header, error)) *EthClientMock_HeaderByHash_Call { + _c.Call.Return(run) + return _c +} + // HeaderByNumber provides a mock function with given fields: ctx, number func (_m *EthClientMock) HeaderByNumber(ctx context.Context, number *big.Int) (*types.Header, error) { ret := _m.Called(ctx, number) @@ -80,6 +117,35 @@ func (_m *EthClientMock) HeaderByNumber(ctx context.Context, number *big.Int) (* return r0, r1 } +// EthClientMock_HeaderByNumber_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HeaderByNumber' +type EthClientMock_HeaderByNumber_Call struct { + *mock.Call +} + +// HeaderByNumber is a helper method to define mock.On call +// - ctx context.Context +// - number *big.Int +func (_e *EthClientMock_Expecter) HeaderByNumber(ctx interface{}, number interface{}) *EthClientMock_HeaderByNumber_Call { + return &EthClientMock_HeaderByNumber_Call{Call: _e.mock.On("HeaderByNumber", ctx, number)} +} + +func (_c *EthClientMock_HeaderByNumber_Call) Run(run func(ctx context.Context, number *big.Int)) *EthClientMock_HeaderByNumber_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*big.Int)) + }) + return _c +} + +func (_c *EthClientMock_HeaderByNumber_Call) Return(_a0 *types.Header, _a1 error) *EthClientMock_HeaderByNumber_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EthClientMock_HeaderByNumber_Call) RunAndReturn(run func(context.Context, *big.Int) (*types.Header, error)) *EthClientMock_HeaderByNumber_Call { + _c.Call.Return(run) + return _c +} + // SubscribeNewHead provides a mock function with given fields: ctx, ch func (_m *EthClientMock) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error) { ret := _m.Called(ctx, ch) @@ -110,6 +176,35 @@ func (_m *EthClientMock) SubscribeNewHead(ctx context.Context, ch chan<- *types. return r0, r1 } +// EthClientMock_SubscribeNewHead_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SubscribeNewHead' +type EthClientMock_SubscribeNewHead_Call struct { + *mock.Call +} + +// SubscribeNewHead is a helper method to define mock.On call +// - ctx context.Context +// - ch chan<- *types.Header +func (_e *EthClientMock_Expecter) SubscribeNewHead(ctx interface{}, ch interface{}) *EthClientMock_SubscribeNewHead_Call { + return &EthClientMock_SubscribeNewHead_Call{Call: _e.mock.On("SubscribeNewHead", ctx, ch)} +} + +func (_c *EthClientMock_SubscribeNewHead_Call) Run(run func(ctx context.Context, ch chan<- *types.Header)) *EthClientMock_SubscribeNewHead_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(chan<- *types.Header)) + }) + return _c +} + +func (_c *EthClientMock_SubscribeNewHead_Call) Return(_a0 ethereum.Subscription, _a1 error) *EthClientMock_SubscribeNewHead_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EthClientMock_SubscribeNewHead_Call) RunAndReturn(run func(context.Context, chan<- *types.Header) (ethereum.Subscription, error)) *EthClientMock_SubscribeNewHead_Call { + _c.Call.Return(run) + return _c +} + // NewEthClientMock creates a new instance of EthClientMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewEthClientMock(t interface { diff --git a/sequencesender/mocks/mock_etherman.go b/sequencesender/mocks/mock_etherman.go index 539ef9a7..298d96c3 100644 --- a/sequencesender/mocks/mock_etherman.go +++ b/sequencesender/mocks/mock_etherman.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.0. DO NOT EDIT. +// Code generated by mockery. DO NOT EDIT. package mocks @@ -18,6 +18,14 @@ type EthermanMock struct { mock.Mock } +type EthermanMock_Expecter struct { + mock *mock.Mock +} + +func (_m *EthermanMock) EXPECT() *EthermanMock_Expecter { + return &EthermanMock_Expecter{mock: &_m.Mock} +} + // CurrentNonce provides a mock function with given fields: ctx, address func (_m *EthermanMock) CurrentNonce(ctx context.Context, address common.Address) (uint64, error) { ret := _m.Called(ctx, address) @@ -46,6 +54,35 @@ func (_m *EthermanMock) CurrentNonce(ctx context.Context, address common.Address return r0, r1 } +// EthermanMock_CurrentNonce_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CurrentNonce' +type EthermanMock_CurrentNonce_Call struct { + *mock.Call +} + +// CurrentNonce is a helper method to define mock.On call +// - ctx context.Context +// - address common.Address +func (_e *EthermanMock_Expecter) CurrentNonce(ctx interface{}, address interface{}) *EthermanMock_CurrentNonce_Call { + return &EthermanMock_CurrentNonce_Call{Call: _e.mock.On("CurrentNonce", ctx, address)} +} + +func (_c *EthermanMock_CurrentNonce_Call) Run(run func(ctx context.Context, address common.Address)) *EthermanMock_CurrentNonce_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(common.Address)) + }) + return _c +} + +func (_c *EthermanMock_CurrentNonce_Call) Return(_a0 uint64, _a1 error) *EthermanMock_CurrentNonce_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EthermanMock_CurrentNonce_Call) RunAndReturn(run func(context.Context, common.Address) (uint64, error)) *EthermanMock_CurrentNonce_Call { + _c.Call.Return(run) + return _c +} + // EstimateGas provides a mock function with given fields: ctx, from, to, value, data func (_m *EthermanMock) EstimateGas(ctx context.Context, from common.Address, to *common.Address, value *big.Int, data []byte) (uint64, error) { ret := _m.Called(ctx, from, to, value, data) @@ -74,7 +111,39 @@ func (_m *EthermanMock) EstimateGas(ctx context.Context, from common.Address, to return r0, r1 } -// GetLatestBatchNumber provides a mock function with given fields: +// EthermanMock_EstimateGas_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'EstimateGas' +type EthermanMock_EstimateGas_Call struct { + *mock.Call +} + +// EstimateGas is a helper method to define mock.On call +// - ctx context.Context +// - from common.Address +// - to *common.Address +// - value *big.Int +// - data []byte +func (_e *EthermanMock_Expecter) EstimateGas(ctx interface{}, from interface{}, to interface{}, value interface{}, data interface{}) *EthermanMock_EstimateGas_Call { + return &EthermanMock_EstimateGas_Call{Call: _e.mock.On("EstimateGas", ctx, from, to, value, data)} +} + +func (_c *EthermanMock_EstimateGas_Call) Run(run func(ctx context.Context, from common.Address, to *common.Address, value *big.Int, data []byte)) *EthermanMock_EstimateGas_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(common.Address), args[2].(*common.Address), args[3].(*big.Int), args[4].([]byte)) + }) + return _c +} + +func (_c *EthermanMock_EstimateGas_Call) Return(_a0 uint64, _a1 error) *EthermanMock_EstimateGas_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EthermanMock_EstimateGas_Call) RunAndReturn(run func(context.Context, common.Address, *common.Address, *big.Int, []byte) (uint64, error)) *EthermanMock_EstimateGas_Call { + _c.Call.Return(run) + return _c +} + +// GetLatestBatchNumber provides a mock function with no fields func (_m *EthermanMock) GetLatestBatchNumber() (uint64, error) { ret := _m.Called() @@ -102,6 +171,33 @@ func (_m *EthermanMock) GetLatestBatchNumber() (uint64, error) { return r0, r1 } +// EthermanMock_GetLatestBatchNumber_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetLatestBatchNumber' +type EthermanMock_GetLatestBatchNumber_Call struct { + *mock.Call +} + +// GetLatestBatchNumber is a helper method to define mock.On call +func (_e *EthermanMock_Expecter) GetLatestBatchNumber() *EthermanMock_GetLatestBatchNumber_Call { + return &EthermanMock_GetLatestBatchNumber_Call{Call: _e.mock.On("GetLatestBatchNumber")} +} + +func (_c *EthermanMock_GetLatestBatchNumber_Call) Run(run func()) *EthermanMock_GetLatestBatchNumber_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EthermanMock_GetLatestBatchNumber_Call) Return(_a0 uint64, _a1 error) *EthermanMock_GetLatestBatchNumber_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EthermanMock_GetLatestBatchNumber_Call) RunAndReturn(run func() (uint64, error)) *EthermanMock_GetLatestBatchNumber_Call { + _c.Call.Return(run) + return _c +} + // GetLatestBlockHeader provides a mock function with given fields: ctx func (_m *EthermanMock) GetLatestBlockHeader(ctx context.Context) (*types.Header, error) { ret := _m.Called(ctx) @@ -132,6 +228,34 @@ func (_m *EthermanMock) GetLatestBlockHeader(ctx context.Context) (*types.Header return r0, r1 } +// EthermanMock_GetLatestBlockHeader_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetLatestBlockHeader' +type EthermanMock_GetLatestBlockHeader_Call struct { + *mock.Call +} + +// GetLatestBlockHeader is a helper method to define mock.On call +// - ctx context.Context +func (_e *EthermanMock_Expecter) GetLatestBlockHeader(ctx interface{}) *EthermanMock_GetLatestBlockHeader_Call { + return &EthermanMock_GetLatestBlockHeader_Call{Call: _e.mock.On("GetLatestBlockHeader", ctx)} +} + +func (_c *EthermanMock_GetLatestBlockHeader_Call) Run(run func(ctx context.Context)) *EthermanMock_GetLatestBlockHeader_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *EthermanMock_GetLatestBlockHeader_Call) Return(_a0 *types.Header, _a1 error) *EthermanMock_GetLatestBlockHeader_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EthermanMock_GetLatestBlockHeader_Call) RunAndReturn(run func(context.Context) (*types.Header, error)) *EthermanMock_GetLatestBlockHeader_Call { + _c.Call.Return(run) + return _c +} + // NewEthermanMock creates a new instance of EthermanMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewEthermanMock(t interface { diff --git a/sequencesender/mocks/mock_ethtxmanager.go b/sequencesender/mocks/mock_ethtxmanager.go index 16de5be6..b8a58d0d 100644 --- a/sequencesender/mocks/mock_ethtxmanager.go +++ b/sequencesender/mocks/mock_ethtxmanager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.0. DO NOT EDIT. +// Code generated by mockery. DO NOT EDIT. package mocks @@ -20,6 +20,14 @@ type EthTxManagerMock struct { mock.Mock } +type EthTxManagerMock_Expecter struct { + mock *mock.Mock +} + +func (_m *EthTxManagerMock) EXPECT() *EthTxManagerMock_Expecter { + return &EthTxManagerMock_Expecter{mock: &_m.Mock} +} + // AddWithGas provides a mock function with given fields: ctx, to, value, data, gasOffset, sidecar, gas func (_m *EthTxManagerMock) AddWithGas(ctx context.Context, to *common.Address, value *big.Int, data []byte, gasOffset uint64, sidecar *types.BlobTxSidecar, gas uint64) (common.Hash, error) { ret := _m.Called(ctx, to, value, data, gasOffset, sidecar, gas) @@ -50,6 +58,40 @@ func (_m *EthTxManagerMock) AddWithGas(ctx context.Context, to *common.Address, return r0, r1 } +// EthTxManagerMock_AddWithGas_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AddWithGas' +type EthTxManagerMock_AddWithGas_Call struct { + *mock.Call +} + +// AddWithGas is a helper method to define mock.On call +// - ctx context.Context +// - to *common.Address +// - value *big.Int +// - data []byte +// - gasOffset uint64 +// - sidecar *types.BlobTxSidecar +// - gas uint64 +func (_e *EthTxManagerMock_Expecter) AddWithGas(ctx interface{}, to interface{}, value interface{}, data interface{}, gasOffset interface{}, sidecar interface{}, gas interface{}) *EthTxManagerMock_AddWithGas_Call { + return &EthTxManagerMock_AddWithGas_Call{Call: _e.mock.On("AddWithGas", ctx, to, value, data, gasOffset, sidecar, gas)} +} + +func (_c *EthTxManagerMock_AddWithGas_Call) Run(run func(ctx context.Context, to *common.Address, value *big.Int, data []byte, gasOffset uint64, sidecar *types.BlobTxSidecar, gas uint64)) *EthTxManagerMock_AddWithGas_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*common.Address), args[2].(*big.Int), args[3].([]byte), args[4].(uint64), args[5].(*types.BlobTxSidecar), args[6].(uint64)) + }) + return _c +} + +func (_c *EthTxManagerMock_AddWithGas_Call) Return(_a0 common.Hash, _a1 error) *EthTxManagerMock_AddWithGas_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EthTxManagerMock_AddWithGas_Call) RunAndReturn(run func(context.Context, *common.Address, *big.Int, []byte, uint64, *types.BlobTxSidecar, uint64) (common.Hash, error)) *EthTxManagerMock_AddWithGas_Call { + _c.Call.Return(run) + return _c +} + // Remove provides a mock function with given fields: ctx, hash func (_m *EthTxManagerMock) Remove(ctx context.Context, hash common.Hash) error { ret := _m.Called(ctx, hash) @@ -68,6 +110,35 @@ func (_m *EthTxManagerMock) Remove(ctx context.Context, hash common.Hash) error return r0 } +// EthTxManagerMock_Remove_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Remove' +type EthTxManagerMock_Remove_Call struct { + *mock.Call +} + +// Remove is a helper method to define mock.On call +// - ctx context.Context +// - hash common.Hash +func (_e *EthTxManagerMock_Expecter) Remove(ctx interface{}, hash interface{}) *EthTxManagerMock_Remove_Call { + return &EthTxManagerMock_Remove_Call{Call: _e.mock.On("Remove", ctx, hash)} +} + +func (_c *EthTxManagerMock_Remove_Call) Run(run func(ctx context.Context, hash common.Hash)) *EthTxManagerMock_Remove_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(common.Hash)) + }) + return _c +} + +func (_c *EthTxManagerMock_Remove_Call) Return(_a0 error) *EthTxManagerMock_Remove_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EthTxManagerMock_Remove_Call) RunAndReturn(run func(context.Context, common.Hash) error) *EthTxManagerMock_Remove_Call { + _c.Call.Return(run) + return _c +} + // Result provides a mock function with given fields: ctx, hash func (_m *EthTxManagerMock) Result(ctx context.Context, hash common.Hash) (zkevm_ethtx_managertypes.MonitoredTxResult, error) { ret := _m.Called(ctx, hash) @@ -96,6 +167,35 @@ func (_m *EthTxManagerMock) Result(ctx context.Context, hash common.Hash) (zkevm return r0, r1 } +// EthTxManagerMock_Result_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Result' +type EthTxManagerMock_Result_Call struct { + *mock.Call +} + +// Result is a helper method to define mock.On call +// - ctx context.Context +// - hash common.Hash +func (_e *EthTxManagerMock_Expecter) Result(ctx interface{}, hash interface{}) *EthTxManagerMock_Result_Call { + return &EthTxManagerMock_Result_Call{Call: _e.mock.On("Result", ctx, hash)} +} + +func (_c *EthTxManagerMock_Result_Call) Run(run func(ctx context.Context, hash common.Hash)) *EthTxManagerMock_Result_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(common.Hash)) + }) + return _c +} + +func (_c *EthTxManagerMock_Result_Call) Return(_a0 zkevm_ethtx_managertypes.MonitoredTxResult, _a1 error) *EthTxManagerMock_Result_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EthTxManagerMock_Result_Call) RunAndReturn(run func(context.Context, common.Hash) (zkevm_ethtx_managertypes.MonitoredTxResult, error)) *EthTxManagerMock_Result_Call { + _c.Call.Return(run) + return _c +} + // ResultsByStatus provides a mock function with given fields: ctx, status func (_m *EthTxManagerMock) ResultsByStatus(ctx context.Context, status []zkevm_ethtx_managertypes.MonitoredTxStatus) ([]zkevm_ethtx_managertypes.MonitoredTxResult, error) { ret := _m.Called(ctx, status) @@ -126,11 +226,67 @@ func (_m *EthTxManagerMock) ResultsByStatus(ctx context.Context, status []zkevm_ return r0, r1 } -// Start provides a mock function with given fields: +// EthTxManagerMock_ResultsByStatus_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ResultsByStatus' +type EthTxManagerMock_ResultsByStatus_Call struct { + *mock.Call +} + +// ResultsByStatus is a helper method to define mock.On call +// - ctx context.Context +// - status []zkevm_ethtx_managertypes.MonitoredTxStatus +func (_e *EthTxManagerMock_Expecter) ResultsByStatus(ctx interface{}, status interface{}) *EthTxManagerMock_ResultsByStatus_Call { + return &EthTxManagerMock_ResultsByStatus_Call{Call: _e.mock.On("ResultsByStatus", ctx, status)} +} + +func (_c *EthTxManagerMock_ResultsByStatus_Call) Run(run func(ctx context.Context, status []zkevm_ethtx_managertypes.MonitoredTxStatus)) *EthTxManagerMock_ResultsByStatus_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].([]zkevm_ethtx_managertypes.MonitoredTxStatus)) + }) + return _c +} + +func (_c *EthTxManagerMock_ResultsByStatus_Call) Return(_a0 []zkevm_ethtx_managertypes.MonitoredTxResult, _a1 error) *EthTxManagerMock_ResultsByStatus_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EthTxManagerMock_ResultsByStatus_Call) RunAndReturn(run func(context.Context, []zkevm_ethtx_managertypes.MonitoredTxStatus) ([]zkevm_ethtx_managertypes.MonitoredTxResult, error)) *EthTxManagerMock_ResultsByStatus_Call { + _c.Call.Return(run) + return _c +} + +// Start provides a mock function with no fields func (_m *EthTxManagerMock) Start() { _m.Called() } +// EthTxManagerMock_Start_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Start' +type EthTxManagerMock_Start_Call struct { + *mock.Call +} + +// Start is a helper method to define mock.On call +func (_e *EthTxManagerMock_Expecter) Start() *EthTxManagerMock_Start_Call { + return &EthTxManagerMock_Start_Call{Call: _e.mock.On("Start")} +} + +func (_c *EthTxManagerMock_Start_Call) Run(run func()) *EthTxManagerMock_Start_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *EthTxManagerMock_Start_Call) Return() *EthTxManagerMock_Start_Call { + _c.Call.Return() + return _c +} + +func (_c *EthTxManagerMock_Start_Call) RunAndReturn(run func()) *EthTxManagerMock_Start_Call { + _c.Run(run) + return _c +} + // NewEthTxManagerMock creates a new instance of EthTxManagerMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewEthTxManagerMock(t interface { diff --git a/sequencesender/mocks/mock_rpc.go b/sequencesender/mocks/mock_rpc.go index e06378a6..eef0188d 100644 --- a/sequencesender/mocks/mock_rpc.go +++ b/sequencesender/mocks/mock_rpc.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.39.0. DO NOT EDIT. +// Code generated by mockery. DO NOT EDIT. package mocks @@ -13,6 +13,14 @@ type RPCInterfaceMock struct { mock.Mock } +type RPCInterfaceMock_Expecter struct { + mock *mock.Mock +} + +func (_m *RPCInterfaceMock) EXPECT() *RPCInterfaceMock_Expecter { + return &RPCInterfaceMock_Expecter{mock: &_m.Mock} +} + // GetBatch provides a mock function with given fields: batchNumber func (_m *RPCInterfaceMock) GetBatch(batchNumber uint64) (*types.RPCBatch, error) { ret := _m.Called(batchNumber) @@ -43,6 +51,34 @@ func (_m *RPCInterfaceMock) GetBatch(batchNumber uint64) (*types.RPCBatch, error return r0, r1 } +// RPCInterfaceMock_GetBatch_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetBatch' +type RPCInterfaceMock_GetBatch_Call struct { + *mock.Call +} + +// GetBatch is a helper method to define mock.On call +// - batchNumber uint64 +func (_e *RPCInterfaceMock_Expecter) GetBatch(batchNumber interface{}) *RPCInterfaceMock_GetBatch_Call { + return &RPCInterfaceMock_GetBatch_Call{Call: _e.mock.On("GetBatch", batchNumber)} +} + +func (_c *RPCInterfaceMock_GetBatch_Call) Run(run func(batchNumber uint64)) *RPCInterfaceMock_GetBatch_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(uint64)) + }) + return _c +} + +func (_c *RPCInterfaceMock_GetBatch_Call) Return(_a0 *types.RPCBatch, _a1 error) *RPCInterfaceMock_GetBatch_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *RPCInterfaceMock_GetBatch_Call) RunAndReturn(run func(uint64) (*types.RPCBatch, error)) *RPCInterfaceMock_GetBatch_Call { + _c.Call.Return(run) + return _c +} + // GetWitness provides a mock function with given fields: batchNumber, fullWitness func (_m *RPCInterfaceMock) GetWitness(batchNumber uint64, fullWitness bool) ([]byte, error) { ret := _m.Called(batchNumber, fullWitness) @@ -73,6 +109,35 @@ func (_m *RPCInterfaceMock) GetWitness(batchNumber uint64, fullWitness bool) ([] return r0, r1 } +// RPCInterfaceMock_GetWitness_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWitness' +type RPCInterfaceMock_GetWitness_Call struct { + *mock.Call +} + +// GetWitness is a helper method to define mock.On call +// - batchNumber uint64 +// - fullWitness bool +func (_e *RPCInterfaceMock_Expecter) GetWitness(batchNumber interface{}, fullWitness interface{}) *RPCInterfaceMock_GetWitness_Call { + return &RPCInterfaceMock_GetWitness_Call{Call: _e.mock.On("GetWitness", batchNumber, fullWitness)} +} + +func (_c *RPCInterfaceMock_GetWitness_Call) Run(run func(batchNumber uint64, fullWitness bool)) *RPCInterfaceMock_GetWitness_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(uint64), args[1].(bool)) + }) + return _c +} + +func (_c *RPCInterfaceMock_GetWitness_Call) Return(_a0 []byte, _a1 error) *RPCInterfaceMock_GetWitness_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *RPCInterfaceMock_GetWitness_Call) RunAndReturn(run func(uint64, bool) ([]byte, error)) *RPCInterfaceMock_GetWitness_Call { + _c.Call.Return(run) + return _c +} + // NewRPCInterfaceMock creates a new instance of RPCInterfaceMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewRPCInterfaceMock(t interface { diff --git a/sequencesender/txbuilder/mocks_txbuilder/global_exit_root_banana_contractor.go b/sequencesender/txbuilder/mocks_txbuilder/global_exit_root_banana_contractor.go index 93dadeef..86fd4366 100644 --- a/sequencesender/txbuilder/mocks_txbuilder/global_exit_root_banana_contractor.go +++ b/sequencesender/txbuilder/mocks_txbuilder/global_exit_root_banana_contractor.go @@ -79,7 +79,7 @@ func (_c *GlobalExitRootBananaContractor_L1InfoRootMap_Call) RunAndReturn(run fu return _c } -// String provides a mock function with given fields: +// String provides a mock function with no fields func (_m *GlobalExitRootBananaContractor) String() string { ret := _m.Called() diff --git a/sequencesender/txbuilder/mocks_txbuilder/global_exit_root_banana_zkevm_contractor.go b/sequencesender/txbuilder/mocks_txbuilder/global_exit_root_banana_zkevm_contractor.go index f7aed125..57c6c157 100644 --- a/sequencesender/txbuilder/mocks_txbuilder/global_exit_root_banana_zkevm_contractor.go +++ b/sequencesender/txbuilder/mocks_txbuilder/global_exit_root_banana_zkevm_contractor.go @@ -79,7 +79,7 @@ func (_c *GlobalExitRootBananaZKEVMContractor_L1InfoRootMap_Call) RunAndReturn(r return _c } -// String provides a mock function with given fields: +// String provides a mock function with no fields func (_m *GlobalExitRootBananaZKEVMContractor) String() string { ret := _m.Called() diff --git a/sequencesender/txbuilder/mocks_txbuilder/tx_builder.go b/sequencesender/txbuilder/mocks_txbuilder/tx_builder.go index 846437db..32ab8ab4 100644 --- a/sequencesender/txbuilder/mocks_txbuilder/tx_builder.go +++ b/sequencesender/txbuilder/mocks_txbuilder/tx_builder.go @@ -307,7 +307,7 @@ func (_c *TxBuilder_SetCondNewSeq_Call) RunAndReturn(run func(txbuilder.CondNewS return _c } -// String provides a mock function with given fields: +// String provides a mock function with no fields func (_m *TxBuilder) String() string { ret := _m.Called() diff --git a/sync/mock_downloader_test.go b/sync/mock_downloader_test.go index 45a53b84..662f49f7 100644 --- a/sync/mock_downloader_test.go +++ b/sync/mock_downloader_test.go @@ -53,7 +53,7 @@ func (_c *EVMDownloaderMock_Download_Call) Return() *EVMDownloaderMock_Download_ } func (_c *EVMDownloaderMock_Download_Call) RunAndReturn(run func(context.Context, uint64, chan EVMBlock)) *EVMDownloaderMock_Download_Call { - _c.Call.Return(run) + _c.Run(run) return _c } diff --git a/test/Makefile b/test/Makefile index 8ae85ba9..31e72a7d 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,27 +1,27 @@ .PHONY: generate-mocks -generate-mocks: generate-mocks-bridgesync generate-mocks-reorgdetector generate-mocks-sequencesender \ - generate-mocks-da generate-mocks-l1infotreesync generate-mocks-helpers \ - generate-mocks-sync generate-mocks-l1infotreesync generate-mocks-aggregator \ - generate-mocks-aggsender generate-mocks-agglayer generate-mocks-bridgesync - generate-mocks-sync generate-mocks-l1infotreesync generate-mocks-aggregator \ - generate-mocks-aggsender generate-mocks-agglayer generate-mocks-bridgesync +generate-mocks: generate-mocks-bridgesync generate-mocks-reorgdetector \ + generate-mocks-sequencesender generate-mocks-da \ + generate-mocks-l1infotreesync generate-mocks-helpers \ + generate-mocks-sync generate-mocks-aggregator \ + generate-mocks-aggsender generate-mocks-agglayer .PHONY: generate-mocks-bridgesync generate-mocks-bridgesync: ## Generates mocks for bridgesync, using mockery tool - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=EthClienter --dir=../bridgesync --output=../bridgesync --outpkg=bridgesync --inpackage --structname=L2Mock --filename=mock_l2_test.go + rm -Rf ../bridgesync/mocks + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../bridgesync --output ../bridgesync/mocks --outpkg mocks_bridgesync ${COMMON_MOCKERY_PARAMS} .PHONY: generate-mocks-reorgdetector generate-mocks-reorgdetector: ## Generates mocks for reorgdetector, using mockery tool - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=EthClient --dir=../reorgdetector --output=../reorgdetector --outpkg=reorgdetector --inpackage --structname=EthClientMock --filename=mock_eth_client.go + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=EthClient --dir=../reorgdetector --output=../reorgdetector --outpkg=reorgdetector --inpackage --structname=EthClientMock --filename=mock_eth_client.go ${COMMON_MOCKERY_PARAMS} COMMON_MOCKERY_PARAMS=--disable-version-string --with-expecter --exported .PHONY: generate-mocks-sequencesender generate-mocks-sequencesender: ## Generates mocks for sequencesender, using mockery tool rm -Rf ../sequencesender/txbuilder/mocks_txbuilder export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../sequencesender/txbuilder --output ../sequencesender/txbuilder/mocks_txbuilder --outpkg mocks_txbuilder ${COMMON_MOCKERY_PARAMS} - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=EthTxManager --dir=../sequencesender --output=../sequencesender/mocks --outpkg=mocks --structname=EthTxManagerMock --filename=mock_ethtxmanager.go - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Etherman --dir=../sequencesender --output=../sequencesender/mocks --outpkg=mocks --structname=EthermanMock --filename=mock_etherman.go - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=RPCInterface --dir=../sequencesender --output=../sequencesender/mocks --outpkg=mocks --structname=RPCInterfaceMock --filename=mock_rpc.go + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=EthTxManager --dir=../sequencesender --output=../sequencesender/mocks --outpkg=mocks --structname=EthTxManagerMock --filename=mock_ethtxmanager.go ${COMMON_MOCKERY_PARAMS} + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Etherman --dir=../sequencesender --output=../sequencesender/mocks --outpkg=mocks --structname=EthermanMock --filename=mock_etherman.go ${COMMON_MOCKERY_PARAMS} + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=RPCInterface --dir=../sequencesender --output=../sequencesender/mocks --outpkg=mocks --structname=RPCInterfaceMock --filename=mock_rpc.go ${COMMON_MOCKERY_PARAMS} .PHONY: generate-mocks-da generate-mocks-da: ## Generates mocks for dataavailability, using mockery tool @@ -37,11 +37,15 @@ generate-mocks-rpc: ## Generates mocks for rpc, using mockery tool generate-mocks-l1infotreesync: ## Generates mocks for l1infotreesync, using mockery tool rm -Rf ../l1infotreesync/mocks export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../l1infotreesync --output ../l1infotreesync/mocks --outpkg mocks_l1infotreesync ${COMMON_MOCKERY_PARAMS} - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ReorgDetector --dir=../sync --output=../l1infotreesync/mocks --outpkg=mocks_l1infotreesync --structname=ReorgDetectorMock --filename=mock_reorgdetector.go + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ReorgDetector --dir=../sync --output=../l1infotreesync/mocks --outpkg=mocks_l1infotreesync --structname=ReorgDetectorMock --filename=mock_reorgdetector.go ${COMMON_MOCKERY_PARAMS} +.PHONY: generate-mocks-helpers +generate-mocks-helpers: ## Generates mocks for helpers, using mockery tool + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=EthTxManager --dir=../aggoracle/chaingersender --output=./helpers --outpkg=helpers --structname=EthTxManagerMock --filename=mock_ethtxmanager.go ${COMMON_MOCKERY_PARAMS} + .PHONY: generate-mocks-aggoracle -generate-mocks-helpers: ## Generates mocks for helpers , using mockery tool - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=EthTxManager --dir=../aggoracle/chaingersender --output=./helpers --outpkg=helpers --structname=EthTxManagerMock --filename=mock_ethtxmanager.go +generate-mocks-aggoracle: ## Generates mocks for aggoracle, using mockery tool + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --dir ../aggoracle/chaingersender --output ../aggoracle/chaingersender/mocks --outpkg mocks ${COMMON_MOCKERY_PARAMS} .PHONY: generate-mocks-sync generate-mocks-sync: ## Generates mocks for sync, using mockery tool @@ -53,14 +57,14 @@ generate-mocks-sync: ## Generates mocks for sync, using mockery tool .PHONY: generate-mocks-aggregator generate-mocks-aggregator: ## Generates mocks for aggregator, using mockery tool - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ProverInterface --dir=../aggregator --output=../aggregator/mocks --outpkg=mocks --structname=ProverInterfaceMock --filename=mock_prover.go - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Etherman --dir=../aggregator --output=../aggregator/mocks --outpkg=mocks --structname=EthermanMock --filename=mock_etherman.go - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=StorageInterface --dir=../aggregator --output=../aggregator/mocks --outpkg=mocks --structname=StorageInterfaceMock --filename=mock_storage.go - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Synchronizer --srcpkg=github.com/0xPolygonHermez/zkevm-synchronizer-l1/synchronizer --output=../aggregator/mocks --outpkg=mocks --structname=SynchronizerInterfaceMock --filename=mock_synchronizer.go - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=EthTxManagerClient --dir=../aggregator --output=../aggregator/mocks --outpkg=mocks --structname=EthTxManagerClientMock --filename=mock_eth_tx_manager.go - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Txer --dir=../db --output=../aggregator/mocks --outpkg=mocks --structname=TxerMock --filename=mock_txer.go - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=RPCInterface --dir=../aggregator --output=../aggregator/mocks --outpkg=mocks --structname=RPCInterfaceMock --filename=mock_rpc.go - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=AggregatorService_ChannelServer --dir=../aggregator/prover --output=../aggregator/prover/mocks --outpkg=mocks --structname=ChannelMock --filename=mock_channel.go + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ProverInterface --dir=../aggregator --output=../aggregator/mocks --outpkg=mocks --structname=ProverInterfaceMock --filename=mock_prover.go ${COMMON_MOCKERY_PARAMS} + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Etherman --dir=../aggregator --output=../aggregator/mocks --outpkg=mocks --structname=EthermanMock --filename=mock_etherman.go ${COMMON_MOCKERY_PARAMS} + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=StorageInterface --dir=../aggregator --output=../aggregator/mocks --outpkg=mocks --structname=StorageInterfaceMock --filename=mock_storage.go ${COMMON_MOCKERY_PARAMS} + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Synchronizer --srcpkg=github.com/0xPolygonHermez/zkevm-synchronizer-l1/synchronizer --output=../aggregator/mocks --outpkg=mocks --structname=SynchronizerInterfaceMock --filename=mock_synchronizer.go ${COMMON_MOCKERY_PARAMS} + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=EthTxManagerClient --dir=../aggregator --output=../aggregator/mocks --outpkg=mocks --structname=EthTxManagerClientMock --filename=mock_eth_tx_manager.go ${COMMON_MOCKERY_PARAMS} + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Txer --dir=../db --output=../aggregator/mocks --outpkg=mocks --structname=TxerMock --filename=mock_txer.go ${COMMON_MOCKERY_PARAMS} + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=RPCInterface --dir=../aggregator --output=../aggregator/mocks --outpkg=mocks --structname=RPCInterfaceMock --filename=mock_rpc.go ${COMMON_MOCKERY_PARAMS} + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=AggregatorService_ChannelServer --dir=../aggregator/prover --output=../aggregator/prover/mocks --outpkg=mocks --structname=ChannelMock --filename=mock_channel.go ${COMMON_MOCKERY_PARAMS} .PHONY: generate-mocks-aggsender @@ -70,13 +74,7 @@ generate-mocks-aggsender: ## Generates mocks for aggsender, using mockery tool .PHONY: generate-mocks-agglayer generate-mocks-agglayer: ## Generates mocks for agglayer, using mockery tool - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=AgglayerClientInterface --dir=../agglayer --output=../agglayer --outpkg=agglayer --inpackage --structname=AgglayerClientMock --filename=mock_agglayer_client.go ${COMMON_MOCKERY_PARAMS} - -.PHONY: generate-mocks-bridgesync -generate-mocks-bridgesync: ## Generates mocks for bridgesync, using mockery tool - rm -Rf ../bridgesync/mocks - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../bridgesync --output ../bridgesync/mocks --outpkg mocks_bridgesync ${COMMON_MOCKERY_PARAMS} - + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=AgglayerClientInterface --dir=../agglayer --output=../agglayer --outpkg=agglayer --inpackage --structname=AgglayerClientMock --filename=mock_agglayer_client.go ${COMMON_MOCKERY_PARAMS} .PHONY: test-e2e-fork9-validium test-e2e-fork9-validium: stop diff --git a/test/helpers/mock_ethtxmanager.go b/test/helpers/mock_ethtxmanager.go index adb21f26..ac10be2a 100644 --- a/test/helpers/mock_ethtxmanager.go +++ b/test/helpers/mock_ethtxmanager.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.45.0. DO NOT EDIT. +// Code generated by mockery. DO NOT EDIT. package helpers @@ -9,11 +9,11 @@ import ( context "context" - ethtxtypes "github.com/0xPolygon/zkevm-ethtx-manager/types" - mock "github.com/stretchr/testify/mock" types "github.com/ethereum/go-ethereum/core/types" + + zkevm_ethtx_managertypes "github.com/0xPolygon/zkevm-ethtx-manager/types" ) // EthTxManagerMock is an autogenerated mock type for the EthTxManager type @@ -21,6 +21,14 @@ type EthTxManagerMock struct { mock.Mock } +type EthTxManagerMock_Expecter struct { + mock *mock.Mock +} + +func (_m *EthTxManagerMock) EXPECT() *EthTxManagerMock_Expecter { + return &EthTxManagerMock_Expecter{mock: &_m.Mock} +} + // Add provides a mock function with given fields: ctx, to, value, data, gasOffset, sidecar func (_m *EthTxManagerMock) Add(ctx context.Context, to *common.Address, value *big.Int, data []byte, gasOffset uint64, sidecar *types.BlobTxSidecar) (common.Hash, error) { ret := _m.Called(ctx, to, value, data, gasOffset, sidecar) @@ -51,6 +59,39 @@ func (_m *EthTxManagerMock) Add(ctx context.Context, to *common.Address, value * return r0, r1 } +// EthTxManagerMock_Add_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Add' +type EthTxManagerMock_Add_Call struct { + *mock.Call +} + +// Add is a helper method to define mock.On call +// - ctx context.Context +// - to *common.Address +// - value *big.Int +// - data []byte +// - gasOffset uint64 +// - sidecar *types.BlobTxSidecar +func (_e *EthTxManagerMock_Expecter) Add(ctx interface{}, to interface{}, value interface{}, data interface{}, gasOffset interface{}, sidecar interface{}) *EthTxManagerMock_Add_Call { + return &EthTxManagerMock_Add_Call{Call: _e.mock.On("Add", ctx, to, value, data, gasOffset, sidecar)} +} + +func (_c *EthTxManagerMock_Add_Call) Run(run func(ctx context.Context, to *common.Address, value *big.Int, data []byte, gasOffset uint64, sidecar *types.BlobTxSidecar)) *EthTxManagerMock_Add_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*common.Address), args[2].(*big.Int), args[3].([]byte), args[4].(uint64), args[5].(*types.BlobTxSidecar)) + }) + return _c +} + +func (_c *EthTxManagerMock_Add_Call) Return(_a0 common.Hash, _a1 error) *EthTxManagerMock_Add_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EthTxManagerMock_Add_Call) RunAndReturn(run func(context.Context, *common.Address, *big.Int, []byte, uint64, *types.BlobTxSidecar) (common.Hash, error)) *EthTxManagerMock_Add_Call { + _c.Call.Return(run) + return _c +} + // Remove provides a mock function with given fields: ctx, id func (_m *EthTxManagerMock) Remove(ctx context.Context, id common.Hash) error { ret := _m.Called(ctx, id) @@ -69,23 +110,52 @@ func (_m *EthTxManagerMock) Remove(ctx context.Context, id common.Hash) error { return r0 } +// EthTxManagerMock_Remove_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Remove' +type EthTxManagerMock_Remove_Call struct { + *mock.Call +} + +// Remove is a helper method to define mock.On call +// - ctx context.Context +// - id common.Hash +func (_e *EthTxManagerMock_Expecter) Remove(ctx interface{}, id interface{}) *EthTxManagerMock_Remove_Call { + return &EthTxManagerMock_Remove_Call{Call: _e.mock.On("Remove", ctx, id)} +} + +func (_c *EthTxManagerMock_Remove_Call) Run(run func(ctx context.Context, id common.Hash)) *EthTxManagerMock_Remove_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(common.Hash)) + }) + return _c +} + +func (_c *EthTxManagerMock_Remove_Call) Return(_a0 error) *EthTxManagerMock_Remove_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EthTxManagerMock_Remove_Call) RunAndReturn(run func(context.Context, common.Hash) error) *EthTxManagerMock_Remove_Call { + _c.Call.Return(run) + return _c +} + // Result provides a mock function with given fields: ctx, id -func (_m *EthTxManagerMock) Result(ctx context.Context, id common.Hash) (ethtxtypes.MonitoredTxResult, error) { +func (_m *EthTxManagerMock) Result(ctx context.Context, id common.Hash) (zkevm_ethtx_managertypes.MonitoredTxResult, error) { ret := _m.Called(ctx, id) if len(ret) == 0 { panic("no return value specified for Result") } - var r0 ethtxtypes.MonitoredTxResult + var r0 zkevm_ethtx_managertypes.MonitoredTxResult var r1 error - if rf, ok := ret.Get(0).(func(context.Context, common.Hash) (ethtxtypes.MonitoredTxResult, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, common.Hash) (zkevm_ethtx_managertypes.MonitoredTxResult, error)); ok { return rf(ctx, id) } - if rf, ok := ret.Get(0).(func(context.Context, common.Hash) ethtxtypes.MonitoredTxResult); ok { + if rf, ok := ret.Get(0).(func(context.Context, common.Hash) zkevm_ethtx_managertypes.MonitoredTxResult); ok { r0 = rf(ctx, id) } else { - r0 = ret.Get(0).(ethtxtypes.MonitoredTxResult) + r0 = ret.Get(0).(zkevm_ethtx_managertypes.MonitoredTxResult) } if rf, ok := ret.Get(1).(func(context.Context, common.Hash) error); ok { @@ -97,28 +167,57 @@ func (_m *EthTxManagerMock) Result(ctx context.Context, id common.Hash) (ethtxty return r0, r1 } +// EthTxManagerMock_Result_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Result' +type EthTxManagerMock_Result_Call struct { + *mock.Call +} + +// Result is a helper method to define mock.On call +// - ctx context.Context +// - id common.Hash +func (_e *EthTxManagerMock_Expecter) Result(ctx interface{}, id interface{}) *EthTxManagerMock_Result_Call { + return &EthTxManagerMock_Result_Call{Call: _e.mock.On("Result", ctx, id)} +} + +func (_c *EthTxManagerMock_Result_Call) Run(run func(ctx context.Context, id common.Hash)) *EthTxManagerMock_Result_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(common.Hash)) + }) + return _c +} + +func (_c *EthTxManagerMock_Result_Call) Return(_a0 zkevm_ethtx_managertypes.MonitoredTxResult, _a1 error) *EthTxManagerMock_Result_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EthTxManagerMock_Result_Call) RunAndReturn(run func(context.Context, common.Hash) (zkevm_ethtx_managertypes.MonitoredTxResult, error)) *EthTxManagerMock_Result_Call { + _c.Call.Return(run) + return _c +} + // ResultsByStatus provides a mock function with given fields: ctx, statuses -func (_m *EthTxManagerMock) ResultsByStatus(ctx context.Context, statuses []ethtxtypes.MonitoredTxStatus) ([]ethtxtypes.MonitoredTxResult, error) { +func (_m *EthTxManagerMock) ResultsByStatus(ctx context.Context, statuses []zkevm_ethtx_managertypes.MonitoredTxStatus) ([]zkevm_ethtx_managertypes.MonitoredTxResult, error) { ret := _m.Called(ctx, statuses) if len(ret) == 0 { panic("no return value specified for ResultsByStatus") } - var r0 []ethtxtypes.MonitoredTxResult + var r0 []zkevm_ethtx_managertypes.MonitoredTxResult var r1 error - if rf, ok := ret.Get(0).(func(context.Context, []ethtxtypes.MonitoredTxStatus) ([]ethtxtypes.MonitoredTxResult, error)); ok { + if rf, ok := ret.Get(0).(func(context.Context, []zkevm_ethtx_managertypes.MonitoredTxStatus) ([]zkevm_ethtx_managertypes.MonitoredTxResult, error)); ok { return rf(ctx, statuses) } - if rf, ok := ret.Get(0).(func(context.Context, []ethtxtypes.MonitoredTxStatus) []ethtxtypes.MonitoredTxResult); ok { + if rf, ok := ret.Get(0).(func(context.Context, []zkevm_ethtx_managertypes.MonitoredTxStatus) []zkevm_ethtx_managertypes.MonitoredTxResult); ok { r0 = rf(ctx, statuses) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]ethtxtypes.MonitoredTxResult) + r0 = ret.Get(0).([]zkevm_ethtx_managertypes.MonitoredTxResult) } } - if rf, ok := ret.Get(1).(func(context.Context, []ethtxtypes.MonitoredTxStatus) error); ok { + if rf, ok := ret.Get(1).(func(context.Context, []zkevm_ethtx_managertypes.MonitoredTxStatus) error); ok { r1 = rf(ctx, statuses) } else { r1 = ret.Error(1) @@ -127,6 +226,35 @@ func (_m *EthTxManagerMock) ResultsByStatus(ctx context.Context, statuses []etht return r0, r1 } +// EthTxManagerMock_ResultsByStatus_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ResultsByStatus' +type EthTxManagerMock_ResultsByStatus_Call struct { + *mock.Call +} + +// ResultsByStatus is a helper method to define mock.On call +// - ctx context.Context +// - statuses []zkevm_ethtx_managertypes.MonitoredTxStatus +func (_e *EthTxManagerMock_Expecter) ResultsByStatus(ctx interface{}, statuses interface{}) *EthTxManagerMock_ResultsByStatus_Call { + return &EthTxManagerMock_ResultsByStatus_Call{Call: _e.mock.On("ResultsByStatus", ctx, statuses)} +} + +func (_c *EthTxManagerMock_ResultsByStatus_Call) Run(run func(ctx context.Context, statuses []zkevm_ethtx_managertypes.MonitoredTxStatus)) *EthTxManagerMock_ResultsByStatus_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].([]zkevm_ethtx_managertypes.MonitoredTxStatus)) + }) + return _c +} + +func (_c *EthTxManagerMock_ResultsByStatus_Call) Return(_a0 []zkevm_ethtx_managertypes.MonitoredTxResult, _a1 error) *EthTxManagerMock_ResultsByStatus_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EthTxManagerMock_ResultsByStatus_Call) RunAndReturn(run func(context.Context, []zkevm_ethtx_managertypes.MonitoredTxStatus) ([]zkevm_ethtx_managertypes.MonitoredTxResult, error)) *EthTxManagerMock_ResultsByStatus_Call { + _c.Call.Return(run) + return _c +} + // NewEthTxManagerMock creates a new instance of EthTxManagerMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. // The first argument is typically a *testing.T value. func NewEthTxManagerMock(t interface { From 1d5a1414816e53210d83d831ab23f16d92f9fa83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Fri, 20 Dec 2024 13:16:38 +0100 Subject: [PATCH 18/21] test: chaingersender ut --- aggoracle/chaingersender/evm.go | 49 ++--- aggoracle/chaingersender/evm_test.go | 112 +++++++++++ aggoracle/mocks/mock_ethtxmanager.go | 270 +++++++++++++++++++++++++++ test/Makefile | 3 +- 4 files changed, 411 insertions(+), 23 deletions(-) create mode 100644 aggoracle/chaingersender/evm_test.go create mode 100644 aggoracle/mocks/mock_ethtxmanager.go diff --git a/aggoracle/chaingersender/evm.go b/aggoracle/chaingersender/evm.go index fe5e221d..0965178d 100644 --- a/aggoracle/chaingersender/evm.go +++ b/aggoracle/chaingersender/evm.go @@ -118,29 +118,34 @@ func (c *EVMChainGERSender) InjectGER(ctx context.Context, ger common.Hash) erro } for { - <-ticker.C - - c.logger.Debugf("waiting for tx %s to be mined", id.Hex()) - res, err := c.ethTxMan.Result(ctx, id) - if err != nil { - c.logger.Errorf("failed to check the transaction %s status: %s", id.Hex(), err) - continue - } - - switch res.Status { - case ethtxtypes.MonitoredTxStatusCreated, - ethtxtypes.MonitoredTxStatusSent: - continue - case ethtxtypes.MonitoredTxStatusFailed: - return fmt.Errorf("inject GER tx %s failed", id.Hex()) - case ethtxtypes.MonitoredTxStatusMined, - ethtxtypes.MonitoredTxStatusSafe, - ethtxtypes.MonitoredTxStatusFinalized: - c.logger.Debugf("inject GER tx %s was successfully mined at block %d", id.Hex(), res.MinedAtBlockNumber) - + select { + case <-ctx.Done(): + c.logger.Infof("context cancelled") return nil - default: - c.logger.Error("unexpected tx status:", res.Status) + + case <-ticker.C: + c.logger.Debugf("waiting for tx %s to be mined", id.Hex()) + res, err := c.ethTxMan.Result(ctx, id) + if err != nil { + c.logger.Errorf("failed to check the transaction %s status: %s", id.Hex(), err) + return err + } + + switch res.Status { + case ethtxtypes.MonitoredTxStatusCreated, + ethtxtypes.MonitoredTxStatusSent: + continue + case ethtxtypes.MonitoredTxStatusFailed: + return fmt.Errorf("inject GER tx %s failed", id.Hex()) + case ethtxtypes.MonitoredTxStatusMined, + ethtxtypes.MonitoredTxStatusSafe, + ethtxtypes.MonitoredTxStatusFinalized: + c.logger.Debugf("inject GER tx %s was successfully mined at block %d", id.Hex(), res.MinedAtBlockNumber) + + return nil + default: + c.logger.Error("unexpected tx status:", res.Status) + } } } } diff --git a/aggoracle/chaingersender/evm_test.go b/aggoracle/chaingersender/evm_test.go new file mode 100644 index 00000000..db5d7a62 --- /dev/null +++ b/aggoracle/chaingersender/evm_test.go @@ -0,0 +1,112 @@ +package chaingersender + +import ( + "context" + "errors" + "math/big" + "strings" + "testing" + "time" + + "github.com/0xPolygon/cdk/aggoracle/mocks" + "github.com/0xPolygon/cdk/log" + "github.com/0xPolygon/zkevm-ethtx-manager/types" + "github.com/ethereum/go-ethereum/accounts/abi" + "github.com/ethereum/go-ethereum/common" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" +) + +func TestEVMChainGERSender_InjectGER(t *testing.T) { + insertGERFuncABI := `[{ + "inputs": [ + { + "internalType": "bytes32", + "name": "_newRoot", + "type": "bytes32" + } + ], + "name": "insertGlobalExitRoot", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }]` + l2GERManagerAddr := common.HexToAddress("0x123") + l2GERManagerAbi, err := abi.JSON(strings.NewReader(insertGERFuncABI)) + require.NoError(t, err) + + gasOffset := uint64(1000) + + ger := common.HexToHash("0x456") + txID := common.HexToHash("0x789") + + tests := []struct { + name string + addReturnTxID common.Hash + addReturnErr error + resultReturn types.MonitoredTxResult + resultReturnErr error + expectedErr string + }{ + { + name: "successful injection", + addReturnTxID: txID, + addReturnErr: nil, + resultReturn: types.MonitoredTxResult{Status: types.MonitoredTxStatusMined, MinedAtBlockNumber: big.NewInt(123)}, + resultReturnErr: nil, + expectedErr: "", + }, + { + name: "injection fails due to transaction failure", + addReturnTxID: txID, + addReturnErr: nil, + resultReturn: types.MonitoredTxResult{Status: types.MonitoredTxStatusFailed}, + resultReturnErr: nil, + expectedErr: "inject GER tx", + }, + { + name: "injection fails due to Add method error", + addReturnTxID: common.Hash{}, + addReturnErr: errors.New("add error"), + resultReturn: types.MonitoredTxResult{}, + resultReturnErr: nil, + expectedErr: "add error", + }, + { + name: "injection fails due to Result method error", + addReturnTxID: txID, + addReturnErr: nil, + resultReturn: types.MonitoredTxResult{}, + resultReturnErr: errors.New("result error"), + expectedErr: "result error", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + ctx, cancelFn := context.WithTimeout(context.Background(), time.Millisecond*500) + defer cancelFn() + + ethTxMan := new(mocks.EthTxManagerMock) + ethTxMan.On("Add", ctx, &l2GERManagerAddr, common.Big0, mock.Anything, gasOffset, mock.Anything).Return(tt.addReturnTxID, tt.addReturnErr) + ethTxMan.On("Result", ctx, tt.addReturnTxID).Return(tt.resultReturn, tt.resultReturnErr) + + sender := &EVMChainGERSender{ + logger: log.GetDefaultLogger(), + l2GERManagerAddr: l2GERManagerAddr, + l2GERManagerAbi: &l2GERManagerAbi, + ethTxMan: ethTxMan, + gasOffset: gasOffset, + waitPeriodMonitorTx: time.Millisecond * 10, + } + + err := sender.InjectGER(ctx, ger) + if tt.expectedErr == "" { + require.NoError(t, err) + } else { + require.Error(t, err) + require.Contains(t, err.Error(), tt.expectedErr) + } + }) + } +} diff --git a/aggoracle/mocks/mock_ethtxmanager.go b/aggoracle/mocks/mock_ethtxmanager.go new file mode 100644 index 00000000..b011f568 --- /dev/null +++ b/aggoracle/mocks/mock_ethtxmanager.go @@ -0,0 +1,270 @@ +// Code generated by mockery. DO NOT EDIT. + +package mocks + +import ( + big "math/big" + + common "github.com/ethereum/go-ethereum/common" + + context "context" + + mock "github.com/stretchr/testify/mock" + + types "github.com/ethereum/go-ethereum/core/types" + + zkevm_ethtx_managertypes "github.com/0xPolygon/zkevm-ethtx-manager/types" +) + +// EthTxManagerMock is an autogenerated mock type for the EthTxManager type +type EthTxManagerMock struct { + mock.Mock +} + +type EthTxManagerMock_Expecter struct { + mock *mock.Mock +} + +func (_m *EthTxManagerMock) EXPECT() *EthTxManagerMock_Expecter { + return &EthTxManagerMock_Expecter{mock: &_m.Mock} +} + +// Add provides a mock function with given fields: ctx, to, value, data, gasOffset, sidecar +func (_m *EthTxManagerMock) Add(ctx context.Context, to *common.Address, value *big.Int, data []byte, gasOffset uint64, sidecar *types.BlobTxSidecar) (common.Hash, error) { + ret := _m.Called(ctx, to, value, data, gasOffset, sidecar) + + if len(ret) == 0 { + panic("no return value specified for Add") + } + + var r0 common.Hash + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *common.Address, *big.Int, []byte, uint64, *types.BlobTxSidecar) (common.Hash, error)); ok { + return rf(ctx, to, value, data, gasOffset, sidecar) + } + if rf, ok := ret.Get(0).(func(context.Context, *common.Address, *big.Int, []byte, uint64, *types.BlobTxSidecar) common.Hash); ok { + r0 = rf(ctx, to, value, data, gasOffset, sidecar) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(common.Hash) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *common.Address, *big.Int, []byte, uint64, *types.BlobTxSidecar) error); ok { + r1 = rf(ctx, to, value, data, gasOffset, sidecar) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// EthTxManagerMock_Add_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Add' +type EthTxManagerMock_Add_Call struct { + *mock.Call +} + +// Add is a helper method to define mock.On call +// - ctx context.Context +// - to *common.Address +// - value *big.Int +// - data []byte +// - gasOffset uint64 +// - sidecar *types.BlobTxSidecar +func (_e *EthTxManagerMock_Expecter) Add(ctx interface{}, to interface{}, value interface{}, data interface{}, gasOffset interface{}, sidecar interface{}) *EthTxManagerMock_Add_Call { + return &EthTxManagerMock_Add_Call{Call: _e.mock.On("Add", ctx, to, value, data, gasOffset, sidecar)} +} + +func (_c *EthTxManagerMock_Add_Call) Run(run func(ctx context.Context, to *common.Address, value *big.Int, data []byte, gasOffset uint64, sidecar *types.BlobTxSidecar)) *EthTxManagerMock_Add_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*common.Address), args[2].(*big.Int), args[3].([]byte), args[4].(uint64), args[5].(*types.BlobTxSidecar)) + }) + return _c +} + +func (_c *EthTxManagerMock_Add_Call) Return(_a0 common.Hash, _a1 error) *EthTxManagerMock_Add_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EthTxManagerMock_Add_Call) RunAndReturn(run func(context.Context, *common.Address, *big.Int, []byte, uint64, *types.BlobTxSidecar) (common.Hash, error)) *EthTxManagerMock_Add_Call { + _c.Call.Return(run) + return _c +} + +// Remove provides a mock function with given fields: ctx, id +func (_m *EthTxManagerMock) Remove(ctx context.Context, id common.Hash) error { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for Remove") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, common.Hash) error); ok { + r0 = rf(ctx, id) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// EthTxManagerMock_Remove_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Remove' +type EthTxManagerMock_Remove_Call struct { + *mock.Call +} + +// Remove is a helper method to define mock.On call +// - ctx context.Context +// - id common.Hash +func (_e *EthTxManagerMock_Expecter) Remove(ctx interface{}, id interface{}) *EthTxManagerMock_Remove_Call { + return &EthTxManagerMock_Remove_Call{Call: _e.mock.On("Remove", ctx, id)} +} + +func (_c *EthTxManagerMock_Remove_Call) Run(run func(ctx context.Context, id common.Hash)) *EthTxManagerMock_Remove_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(common.Hash)) + }) + return _c +} + +func (_c *EthTxManagerMock_Remove_Call) Return(_a0 error) *EthTxManagerMock_Remove_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *EthTxManagerMock_Remove_Call) RunAndReturn(run func(context.Context, common.Hash) error) *EthTxManagerMock_Remove_Call { + _c.Call.Return(run) + return _c +} + +// Result provides a mock function with given fields: ctx, id +func (_m *EthTxManagerMock) Result(ctx context.Context, id common.Hash) (zkevm_ethtx_managertypes.MonitoredTxResult, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for Result") + } + + var r0 zkevm_ethtx_managertypes.MonitoredTxResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, common.Hash) (zkevm_ethtx_managertypes.MonitoredTxResult, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, common.Hash) zkevm_ethtx_managertypes.MonitoredTxResult); ok { + r0 = rf(ctx, id) + } else { + r0 = ret.Get(0).(zkevm_ethtx_managertypes.MonitoredTxResult) + } + + if rf, ok := ret.Get(1).(func(context.Context, common.Hash) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// EthTxManagerMock_Result_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Result' +type EthTxManagerMock_Result_Call struct { + *mock.Call +} + +// Result is a helper method to define mock.On call +// - ctx context.Context +// - id common.Hash +func (_e *EthTxManagerMock_Expecter) Result(ctx interface{}, id interface{}) *EthTxManagerMock_Result_Call { + return &EthTxManagerMock_Result_Call{Call: _e.mock.On("Result", ctx, id)} +} + +func (_c *EthTxManagerMock_Result_Call) Run(run func(ctx context.Context, id common.Hash)) *EthTxManagerMock_Result_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(common.Hash)) + }) + return _c +} + +func (_c *EthTxManagerMock_Result_Call) Return(_a0 zkevm_ethtx_managertypes.MonitoredTxResult, _a1 error) *EthTxManagerMock_Result_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EthTxManagerMock_Result_Call) RunAndReturn(run func(context.Context, common.Hash) (zkevm_ethtx_managertypes.MonitoredTxResult, error)) *EthTxManagerMock_Result_Call { + _c.Call.Return(run) + return _c +} + +// ResultsByStatus provides a mock function with given fields: ctx, statuses +func (_m *EthTxManagerMock) ResultsByStatus(ctx context.Context, statuses []zkevm_ethtx_managertypes.MonitoredTxStatus) ([]zkevm_ethtx_managertypes.MonitoredTxResult, error) { + ret := _m.Called(ctx, statuses) + + if len(ret) == 0 { + panic("no return value specified for ResultsByStatus") + } + + var r0 []zkevm_ethtx_managertypes.MonitoredTxResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, []zkevm_ethtx_managertypes.MonitoredTxStatus) ([]zkevm_ethtx_managertypes.MonitoredTxResult, error)); ok { + return rf(ctx, statuses) + } + if rf, ok := ret.Get(0).(func(context.Context, []zkevm_ethtx_managertypes.MonitoredTxStatus) []zkevm_ethtx_managertypes.MonitoredTxResult); ok { + r0 = rf(ctx, statuses) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]zkevm_ethtx_managertypes.MonitoredTxResult) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, []zkevm_ethtx_managertypes.MonitoredTxStatus) error); ok { + r1 = rf(ctx, statuses) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// EthTxManagerMock_ResultsByStatus_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ResultsByStatus' +type EthTxManagerMock_ResultsByStatus_Call struct { + *mock.Call +} + +// ResultsByStatus is a helper method to define mock.On call +// - ctx context.Context +// - statuses []zkevm_ethtx_managertypes.MonitoredTxStatus +func (_e *EthTxManagerMock_Expecter) ResultsByStatus(ctx interface{}, statuses interface{}) *EthTxManagerMock_ResultsByStatus_Call { + return &EthTxManagerMock_ResultsByStatus_Call{Call: _e.mock.On("ResultsByStatus", ctx, statuses)} +} + +func (_c *EthTxManagerMock_ResultsByStatus_Call) Run(run func(ctx context.Context, statuses []zkevm_ethtx_managertypes.MonitoredTxStatus)) *EthTxManagerMock_ResultsByStatus_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].([]zkevm_ethtx_managertypes.MonitoredTxStatus)) + }) + return _c +} + +func (_c *EthTxManagerMock_ResultsByStatus_Call) Return(_a0 []zkevm_ethtx_managertypes.MonitoredTxResult, _a1 error) *EthTxManagerMock_ResultsByStatus_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *EthTxManagerMock_ResultsByStatus_Call) RunAndReturn(run func(context.Context, []zkevm_ethtx_managertypes.MonitoredTxStatus) ([]zkevm_ethtx_managertypes.MonitoredTxResult, error)) *EthTxManagerMock_ResultsByStatus_Call { + _c.Call.Return(run) + return _c +} + +// NewEthTxManagerMock creates a new instance of EthTxManagerMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewEthTxManagerMock(t interface { + mock.TestingT + Cleanup(func()) +}) *EthTxManagerMock { + mock := &EthTxManagerMock{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/test/Makefile b/test/Makefile index 31e72a7d..3ed29a24 100644 --- a/test/Makefile +++ b/test/Makefile @@ -45,7 +45,8 @@ generate-mocks-helpers: ## Generates mocks for helpers, using mockery tool .PHONY: generate-mocks-aggoracle generate-mocks-aggoracle: ## Generates mocks for aggoracle, using mockery tool - export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --dir ../aggoracle/chaingersender --output ../aggoracle/chaingersender/mocks --outpkg mocks ${COMMON_MOCKERY_PARAMS} + rm -Rf ../aggoracle/mocks + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=EthTxManager --dir ../aggoracle/chaingersender --output ../aggoracle/mocks --outpkg mocks --structname=EthTxManagerMock --filename=mock_ethtxmanager.go ${COMMON_MOCKERY_PARAMS} .PHONY: generate-mocks-sync generate-mocks-sync: ## Generates mocks for sync, using mockery tool From de60d6f22bc06aa21d415cc68c230998d5154d84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Fri, 20 Dec 2024 13:35:28 +0100 Subject: [PATCH 19/21] test: IsGERInjected unit test --- aggoracle/chaingersender/evm.go | 6 +- aggoracle/chaingersender/evm_test.go | 66 +++++++++++++++++-- aggoracle/mocks/mock_l2germanager.go | 97 ++++++++++++++++++++++++++++ test/Makefile | 1 + 4 files changed, 164 insertions(+), 6 deletions(-) create mode 100644 aggoracle/mocks/mock_l2germanager.go diff --git a/aggoracle/chaingersender/evm.go b/aggoracle/chaingersender/evm.go index 0965178d..adfb1950 100644 --- a/aggoracle/chaingersender/evm.go +++ b/aggoracle/chaingersender/evm.go @@ -43,6 +43,10 @@ type EthTxManager interface { ) (common.Hash, error) } +type L2GERManager interface { + GlobalExitRootMap(opts *bind.CallOpts, ger [common.HashLength]byte) (*big.Int, error) +} + type EVMConfig struct { GlobalExitRootL2Addr common.Address `mapstructure:"GlobalExitRootL2"` URLRPCL2 string `mapstructure:"URLRPCL2"` @@ -55,7 +59,7 @@ type EVMConfig struct { type EVMChainGERSender struct { logger *log.Logger - l2GERManager *globalexitrootmanagerl2sovereignchain.Globalexitrootmanagerl2sovereignchain + l2GERManager L2GERManager l2GERManagerAddr common.Address l2GERManagerAbi *abi.ABI diff --git a/aggoracle/chaingersender/evm_test.go b/aggoracle/chaingersender/evm_test.go index db5d7a62..ad1cb5af 100644 --- a/aggoracle/chaingersender/evm_test.go +++ b/aggoracle/chaingersender/evm_test.go @@ -35,8 +35,6 @@ func TestEVMChainGERSender_InjectGER(t *testing.T) { l2GERManagerAbi, err := abi.JSON(strings.NewReader(insertGERFuncABI)) require.NoError(t, err) - gasOffset := uint64(1000) - ger := common.HexToHash("0x456") txID := common.HexToHash("0x789") @@ -88,15 +86,18 @@ func TestEVMChainGERSender_InjectGER(t *testing.T) { defer cancelFn() ethTxMan := new(mocks.EthTxManagerMock) - ethTxMan.On("Add", ctx, &l2GERManagerAddr, common.Big0, mock.Anything, gasOffset, mock.Anything).Return(tt.addReturnTxID, tt.addReturnErr) - ethTxMan.On("Result", ctx, tt.addReturnTxID).Return(tt.resultReturn, tt.resultReturnErr) + ethTxMan. + On("Add", ctx, &l2GERManagerAddr, common.Big0, mock.Anything, mock.Anything, mock.Anything). + Return(tt.addReturnTxID, tt.addReturnErr) + ethTxMan. + On("Result", ctx, tt.addReturnTxID). + Return(tt.resultReturn, tt.resultReturnErr) sender := &EVMChainGERSender{ logger: log.GetDefaultLogger(), l2GERManagerAddr: l2GERManagerAddr, l2GERManagerAbi: &l2GERManagerAbi, ethTxMan: ethTxMan, - gasOffset: gasOffset, waitPeriodMonitorTx: time.Millisecond * 10, } @@ -110,3 +111,58 @@ func TestEVMChainGERSender_InjectGER(t *testing.T) { }) } } + +func TestEVMChainGERSender_IsGERInjected(t *testing.T) { + tests := []struct { + name string + mockReturn *big.Int + mockError error + expectedResult bool + expectedErrMsg string + }{ + { + name: "GER is injected", + mockReturn: big.NewInt(1), + mockError: nil, + expectedResult: true, + expectedErrMsg: "", + }, + { + name: "GER is not injected", + mockReturn: big.NewInt(0), + mockError: nil, + expectedResult: false, + expectedErrMsg: "", + }, + { + name: "Error checking GER injection", + mockReturn: nil, + mockError: errors.New("some error"), + expectedResult: false, + expectedErrMsg: "failed to check if global exit root is injected", + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + mockL2GERManager := new(mocks.L2GERManagerMock) + mockL2GERManager.On("GlobalExitRootMap", mock.Anything, mock.Anything). + Return(tt.mockReturn, tt.mockError) + + evmChainGERSender := &EVMChainGERSender{ + l2GERManager: mockL2GERManager, + } + + ger := common.HexToHash("0x12345") + result, err := evmChainGERSender.IsGERInjected(ger) + if tt.expectedErrMsg != "" { + require.ErrorContains(t, err, tt.expectedErrMsg) + } else { + require.NoError(t, err) + } + require.Equal(t, tt.expectedResult, result) + + mockL2GERManager.AssertExpectations(t) + }) + } +} diff --git a/aggoracle/mocks/mock_l2germanager.go b/aggoracle/mocks/mock_l2germanager.go new file mode 100644 index 00000000..a7ec0296 --- /dev/null +++ b/aggoracle/mocks/mock_l2germanager.go @@ -0,0 +1,97 @@ +// Code generated by mockery. DO NOT EDIT. + +package mocks + +import ( + big "math/big" + + bind "github.com/ethereum/go-ethereum/accounts/abi/bind" + + mock "github.com/stretchr/testify/mock" +) + +// L2GERManagerMock is an autogenerated mock type for the L2GERManager type +type L2GERManagerMock struct { + mock.Mock +} + +type L2GERManagerMock_Expecter struct { + mock *mock.Mock +} + +func (_m *L2GERManagerMock) EXPECT() *L2GERManagerMock_Expecter { + return &L2GERManagerMock_Expecter{mock: &_m.Mock} +} + +// GlobalExitRootMap provides a mock function with given fields: opts, ger +func (_m *L2GERManagerMock) GlobalExitRootMap(opts *bind.CallOpts, ger [32]byte) (*big.Int, error) { + ret := _m.Called(opts, ger) + + if len(ret) == 0 { + panic("no return value specified for GlobalExitRootMap") + } + + var r0 *big.Int + var r1 error + if rf, ok := ret.Get(0).(func(*bind.CallOpts, [32]byte) (*big.Int, error)); ok { + return rf(opts, ger) + } + if rf, ok := ret.Get(0).(func(*bind.CallOpts, [32]byte) *big.Int); ok { + r0 = rf(opts, ger) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*big.Int) + } + } + + if rf, ok := ret.Get(1).(func(*bind.CallOpts, [32]byte) error); ok { + r1 = rf(opts, ger) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// L2GERManagerMock_GlobalExitRootMap_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GlobalExitRootMap' +type L2GERManagerMock_GlobalExitRootMap_Call struct { + *mock.Call +} + +// GlobalExitRootMap is a helper method to define mock.On call +// - opts *bind.CallOpts +// - ger [32]byte +func (_e *L2GERManagerMock_Expecter) GlobalExitRootMap(opts interface{}, ger interface{}) *L2GERManagerMock_GlobalExitRootMap_Call { + return &L2GERManagerMock_GlobalExitRootMap_Call{Call: _e.mock.On("GlobalExitRootMap", opts, ger)} +} + +func (_c *L2GERManagerMock_GlobalExitRootMap_Call) Run(run func(opts *bind.CallOpts, ger [32]byte)) *L2GERManagerMock_GlobalExitRootMap_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*bind.CallOpts), args[1].([32]byte)) + }) + return _c +} + +func (_c *L2GERManagerMock_GlobalExitRootMap_Call) Return(_a0 *big.Int, _a1 error) *L2GERManagerMock_GlobalExitRootMap_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *L2GERManagerMock_GlobalExitRootMap_Call) RunAndReturn(run func(*bind.CallOpts, [32]byte) (*big.Int, error)) *L2GERManagerMock_GlobalExitRootMap_Call { + _c.Call.Return(run) + return _c +} + +// NewL2GERManagerMock creates a new instance of L2GERManagerMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewL2GERManagerMock(t interface { + mock.TestingT + Cleanup(func()) +}) *L2GERManagerMock { + mock := &L2GERManagerMock{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/test/Makefile b/test/Makefile index 3ed29a24..969debd2 100644 --- a/test/Makefile +++ b/test/Makefile @@ -47,6 +47,7 @@ generate-mocks-helpers: ## Generates mocks for helpers, using mockery tool generate-mocks-aggoracle: ## Generates mocks for aggoracle, using mockery tool rm -Rf ../aggoracle/mocks export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=EthTxManager --dir ../aggoracle/chaingersender --output ../aggoracle/mocks --outpkg mocks --structname=EthTxManagerMock --filename=mock_ethtxmanager.go ${COMMON_MOCKERY_PARAMS} + export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=L2GERManager --dir ../aggoracle/chaingersender --output ../aggoracle/mocks --outpkg mocks --structname=L2GERManagerMock --filename=mock_l2germanager.go ${COMMON_MOCKERY_PARAMS} .PHONY: generate-mocks-sync generate-mocks-sync: ## Generates mocks for sync, using mockery tool From b4949a0157dff8bd77cd3c713ddb750c29ac332b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Mon, 23 Dec 2024 11:27:02 +0100 Subject: [PATCH 20/21] remove removal of mock files --- test/Makefile | 7 ------- 1 file changed, 7 deletions(-) diff --git a/test/Makefile b/test/Makefile index 969debd2..2e81a453 100644 --- a/test/Makefile +++ b/test/Makefile @@ -7,7 +7,6 @@ generate-mocks: generate-mocks-bridgesync generate-mocks-reorgdetector \ .PHONY: generate-mocks-bridgesync generate-mocks-bridgesync: ## Generates mocks for bridgesync, using mockery tool - rm -Rf ../bridgesync/mocks export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../bridgesync --output ../bridgesync/mocks --outpkg mocks_bridgesync ${COMMON_MOCKERY_PARAMS} .PHONY: generate-mocks-reorgdetector @@ -17,7 +16,6 @@ generate-mocks-reorgdetector: ## Generates mocks for reorgdetector, using mocker COMMON_MOCKERY_PARAMS=--disable-version-string --with-expecter --exported .PHONY: generate-mocks-sequencesender generate-mocks-sequencesender: ## Generates mocks for sequencesender, using mockery tool - rm -Rf ../sequencesender/txbuilder/mocks_txbuilder export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../sequencesender/txbuilder --output ../sequencesender/txbuilder/mocks_txbuilder --outpkg mocks_txbuilder ${COMMON_MOCKERY_PARAMS} export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=EthTxManager --dir=../sequencesender --output=../sequencesender/mocks --outpkg=mocks --structname=EthTxManagerMock --filename=mock_ethtxmanager.go ${COMMON_MOCKERY_PARAMS} export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=Etherman --dir=../sequencesender --output=../sequencesender/mocks --outpkg=mocks --structname=EthermanMock --filename=mock_etherman.go ${COMMON_MOCKERY_PARAMS} @@ -25,17 +23,14 @@ generate-mocks-sequencesender: ## Generates mocks for sequencesender, using mock .PHONY: generate-mocks-da generate-mocks-da: ## Generates mocks for dataavailability, using mockery tool - rm -Rf ../dataavailability/mocks_da export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../dataavailability --output ../dataavailability/mocks_da --outpkg mocks_da ${COMMON_MOCKERY_PARAMS} .PHONY: generate-mocks-rpc generate-mocks-rpc: ## Generates mocks for rpc, using mockery tool - rm -Rf ../rpc/mocks export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../rpc --output ../rpc/mocks --outpkg mocks ${COMMON_MOCKERY_PARAMS} .PHONY: generate-mocks-l1infotreesync generate-mocks-l1infotreesync: ## Generates mocks for l1infotreesync, using mockery tool - rm -Rf ../l1infotreesync/mocks export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../l1infotreesync --output ../l1infotreesync/mocks --outpkg mocks_l1infotreesync ${COMMON_MOCKERY_PARAMS} export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=ReorgDetector --dir=../sync --output=../l1infotreesync/mocks --outpkg=mocks_l1infotreesync --structname=ReorgDetectorMock --filename=mock_reorgdetector.go ${COMMON_MOCKERY_PARAMS} @@ -45,7 +40,6 @@ generate-mocks-helpers: ## Generates mocks for helpers, using mockery tool .PHONY: generate-mocks-aggoracle generate-mocks-aggoracle: ## Generates mocks for aggoracle, using mockery tool - rm -Rf ../aggoracle/mocks export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=EthTxManager --dir ../aggoracle/chaingersender --output ../aggoracle/mocks --outpkg mocks --structname=EthTxManagerMock --filename=mock_ethtxmanager.go ${COMMON_MOCKERY_PARAMS} export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --name=L2GERManager --dir ../aggoracle/chaingersender --output ../aggoracle/mocks --outpkg mocks --structname=L2GERManagerMock --filename=mock_l2germanager.go ${COMMON_MOCKERY_PARAMS} @@ -71,7 +65,6 @@ generate-mocks-aggregator: ## Generates mocks for aggregator, using mockery tool .PHONY: generate-mocks-aggsender generate-mocks-aggsender: ## Generates mocks for aggsender, using mockery tool - rm -Rf ../aggsender/mocks export "GOROOT=$$(go env GOROOT)" && $$(go env GOPATH)/bin/mockery --all --case snake --dir ../aggsender --output ../aggsender/mocks --outpkg mocks ${COMMON_MOCKERY_PARAMS} .PHONY: generate-mocks-agglayer From 85bbb5b4f840b21a85e23fd7840983894ca2c25e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Mon, 23 Dec 2024 11:35:08 +0100 Subject: [PATCH 21/21] rename --- test/helpers/e2e.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/helpers/e2e.go b/test/helpers/e2e.go index fc6b1d4f..c7fb908e 100644 --- a/test/helpers/e2e.go +++ b/test/helpers/e2e.go @@ -272,9 +272,11 @@ func newSimulatedEVML2SovereignChain(t *testing.T) ( require.True(t, ok) const deployedContractsCount = 3 - l2BridgeAddr := crypto.CreateAddress(deployerAuth.From, deployedContractsCount) + l2BridgeProxyAddr := crypto.CreateAddress(deployerAuth.From, deployedContractsCount) - genesisAllocMap := map[common.Address]types.Account{l2BridgeAddr: {Balance: premineBalance}} + genesisAllocMap := map[common.Address]types.Account{ + l2BridgeProxyAddr: {Balance: premineBalance}, + } client, setup := NewSimulatedBackend(t, genesisAllocMap, deployerAuth) // Deploy L2 GER manager contract @@ -309,7 +311,7 @@ func newSimulatedEVML2SovereignChain(t *testing.T) ( err = setup.DeployBridge(client, gerProxyAddr, rollupID) require.NoError(t, err) - require.Equal(t, l2BridgeAddr, setup.BridgeProxyAddr) + require.Equal(t, l2BridgeProxyAddr, setup.BridgeProxyAddr) bridgeGERAddr, err := setup.BridgeProxyContract.GlobalExitRootManager(nil) require.NoError(t, err)