From 229eb59982103219ab8f9a77a14dc688b45c04fd Mon Sep 17 00:00:00 2001 From: gzeon Date: Wed, 17 Jan 2024 22:28:56 +0800 Subject: [PATCH] test: fix --- src/bridge/ISequencerInbox.sol | 9 ++-- test/contract/sequencerInbox.spec.4844.ts | 62 +++++++++++++---------- 2 files changed, 39 insertions(+), 32 deletions(-) diff --git a/src/bridge/ISequencerInbox.sol b/src/bridge/ISequencerInbox.sol index aa7b42cdd..6535cdc4a 100644 --- a/src/bridge/ISequencerInbox.sol +++ b/src/bridge/ISequencerInbox.sol @@ -90,14 +90,15 @@ interface ISequencerInbox is IDelayedMessageProvider { uint64 creationBlock; } + /// @dev returns 4 uint256 to be compatible with older version function maxTimeVariation() external view returns ( - uint256, - uint256, - uint256, - uint256 + uint256 delayBlocks, + uint256 futureBlocks, + uint256 delaySeconds, + uint256 futureSeconds ); function dasKeySetInfo(bytes32) external view returns (bool, uint64); diff --git a/test/contract/sequencerInbox.spec.4844.ts b/test/contract/sequencerInbox.spec.4844.ts index 655321131..7885e372a 100644 --- a/test/contract/sequencerInbox.spec.4844.ts +++ b/test/contract/sequencerInbox.spec.4844.ts @@ -272,6 +272,16 @@ describe('SequencerInbox', async () => { await rollupOwner.getAddress() ) + const dataHashReader = await Toolkit4844.deployDataHashReader(fundingWallet) + const blobBasefeeReader = await Toolkit4844.deployBlobBasefeeReader(fundingWallet) + const sequencerInboxFac = (await ethers.getContractFactory( + 'SequencerInbox' + )) as SequencerInbox__factory + const seqInboxTemplate = await sequencerInboxFac.deploy( + 117964, + dataHashReader.address, + blobBasefeeReader.address + ) const inboxFac = new Inbox__factory(deployer) const inboxTemplate = await inboxFac.deploy(117964) @@ -289,7 +299,11 @@ describe('SequencerInbox', async () => { adminAddr, '0x' ) - + const sequencerInboxProxy = await transparentUpgradeableProxyFac.deploy( + seqInboxTemplate.address, + adminAddr, + '0x' + ) const inboxProxy = await transparentUpgradeableProxyFac.deploy( inboxTemplate.address, adminAddr, @@ -297,32 +311,22 @@ describe('SequencerInbox', async () => { ) await bridgeProxy.deployed() await inboxProxy.deployed() - const dataHashReader = await Toolkit4844.deployDataHashReader(fundingWallet) - const blobBasefeeReader = await Toolkit4844.deployBlobBasefeeReader( - fundingWallet - ) + await sequencerInboxProxy.deployed() const bridge = await bridgeFac.attach(bridgeProxy.address).connect(user) const bridgeAdmin = await bridgeFac .attach(bridgeProxy.address) .connect(rollupOwner) + const sequencerInbox = await sequencerInboxFac + .attach(sequencerInboxProxy.address) + .connect(user) await (await bridgeAdmin.initialize(rollupMock.address)).wait() - - const sequencerInboxFac = new SequencerInbox__factory(deployer) - const sequencerInbox = await sequencerInboxFac.deploy( - bridge.address, - { - delayBlocks: maxDelayBlocks, - futureBlocks: 10, - delaySeconds: maxDelayTime, - futureSeconds: 3000, - }, - 117964, - dataHashReader.address, - blobBasefeeReader.address, - { gasLimit: 15000000 } - ) - await sequencerInbox.deployed() + await sequencerInbox.initialize(bridgeProxy.address, { + delayBlocks: maxDelayBlocks, + delaySeconds: maxDelayTime, + futureBlocks: 10, + futureSeconds: 3000, + }) const inbox = await inboxFac.attach(inboxProxy.address).connect(user) @@ -381,7 +385,9 @@ describe('SequencerInbox', async () => { const subMessageCount = await bridge.sequencerReportedSubMessageCount() const batchSendTx = await sequencerInbox .connect(batchPoster) - .functions.addSequencerL2BatchFromOrigin( + .functions[ + 'addSequencerL2BatchFromOrigin(uint256,bytes,uint256,address,uint256,uint256)' + ]( await bridge.sequencerMessageCount(), '0x0042', await bridge.delayedMessageCount(), @@ -542,15 +548,15 @@ describe('SequencerInbox', async () => { const maxTimeVariation = await sequencerInbox.maxTimeVariation() return { minBlocks: - blockNumber > maxTimeVariation.delayBlocks.toNumber() - ? blockNumber - maxTimeVariation.delayBlocks.toNumber() + blockNumber > maxTimeVariation[0].toNumber() + ? blockNumber - maxTimeVariation[0].toNumber() : 0, - maxBlock: blockNumber + maxTimeVariation.futureBlocks.toNumber(), + maxBlock: blockNumber + maxTimeVariation[1].toNumber(), minTimestamp: - blockTimestamp > maxTimeVariation.delaySeconds.toNumber() - ? blockTimestamp - maxTimeVariation.delaySeconds.toNumber() + blockTimestamp > maxTimeVariation[2].toNumber() + ? blockTimestamp - maxTimeVariation[2].toNumber() : 0, - maxTimestamp: blockTimestamp + maxTimeVariation.futureSeconds.toNumber(), + maxTimestamp: blockTimestamp + maxTimeVariation[3].toNumber(), } }