diff --git a/packages/protocol/test/L1/TaikoL1.integration.test.ts b/packages/protocol/test/L1/TaikoL1.integration.test.ts index 581d970b99a..7ada5c16fa4 100644 --- a/packages/protocol/test/L1/TaikoL1.integration.test.ts +++ b/packages/protocol/test/L1/TaikoL1.integration.test.ts @@ -17,11 +17,7 @@ import { buildProposeBlockInputs } from "../utils/propose"; import Proposer from "../utils/proposer"; import { buildProveBlockInputs, proveBlock } from "../utils/prove"; import Prover from "../utils/prover"; -import { - createAndSeedWallets, - seedTko, - sendTinyEtherToZeroAddress, -} from "../utils/seed"; +import { seedTko, sendTinyEtherToZeroAddress } from "../utils/seed"; import { commitProposeProveAndVerify, sleepUntilBlockIsVerifiable, @@ -188,57 +184,43 @@ describe("integration:TaikoL1", function () { }); it("returns empty after a block is verified", async function () { - const provers = (await createAndSeedWallets(2, l1Signer)).map( - (p: ethersLib.Wallet) => new Prover(taikoL1, l2Provider, p) - ); - - await seedTko(provers, tkoTokenL1.connect(l1Signer)); - - l2Provider.on("block", blockListener(chan, genesisHeight)); + await seedTko([prover], tkoTokenL1.connect(l1Signer)); + const blockNumber = genesisHeight + 1; /* eslint-disable-next-line */ - for await (const blockNumber of chan) { - if ( - blockNumber > - genesisHeight + config.maxNumBlocks.toNumber() - 1 - ) { - break; - } + const block = await l2Provider.getBlock(blockNumber); - const block = await l2Provider.getBlock(blockNumber); - - // commit and propose block, so our provers can prove it. - const { proposedEvent } = await proposer.commitThenProposeBlock( - block - ); + // commit and propose block, so our provers can prove it. + const { proposedEvent } = await proposer.commitThenProposeBlock( + block + ); - await provers[0].prove( - proposedEvent.args.id.toNumber(), - blockNumber, - proposedEvent.args.meta as any as BlockMetadata - ); + await prover.prove( + proposedEvent.args.id.toNumber(), + blockNumber, + proposedEvent.args.meta as any as BlockMetadata + ); - let forkChoice = await taikoL1.getForkChoice( - proposedEvent.args.id.toNumber(), - block.parentHash - ); - expect(forkChoice).not.to.be.undefined; - expect(forkChoice.provers.length).to.be.eq(1); + let forkChoice = await taikoL1.getForkChoice( + proposedEvent.args.id.toNumber(), + block.parentHash + ); + expect(forkChoice).not.to.be.undefined; + expect(forkChoice.provers.length).to.be.eq(1); - await sleepUntilBlockIsVerifiable( - taikoL1, - proposedEvent.args.id.toNumber(), - 0 - ); - const verifiedEvent = await verifyBlocks(taikoL1, 1); - expect(verifiedEvent).not.to.be.undefined; + await sleepUntilBlockIsVerifiable( + taikoL1, + proposedEvent.args.id.toNumber(), + 0 + ); + const verifiedEvent = await verifyBlocks(taikoL1, 1); + expect(verifiedEvent).not.to.be.undefined; - forkChoice = await taikoL1.getForkChoice( - proposedEvent.args.id.toNumber(), - block.parentHash - ); - expect(forkChoice.provers.length).to.be.eq(0); - } + forkChoice = await taikoL1.getForkChoice( + proposedEvent.args.id.toNumber(), + block.parentHash + ); + expect(forkChoice.provers.length).to.be.eq(0); }); }); diff --git a/packages/protocol/test/tokenomics/proofReward.test.ts b/packages/protocol/test/tokenomics/proofReward.test.ts index 4a34c34d9e0..e9fd36c06b9 100644 --- a/packages/protocol/test/tokenomics/proofReward.test.ts +++ b/packages/protocol/test/tokenomics/proofReward.test.ts @@ -225,64 +225,50 @@ describe("tokenomics: proofReward", function () { await seedTko(provers, tkoTokenL1.connect(l1Signer)); - l2Provider.on("block", blockListener(chan, genesisHeight)); + const blockNumber = genesisHeight + 1; - /* eslint-disable-next-line */ - for await (const blockNumber of chan) { - if ( - blockNumber > - genesisHeight + (config.maxNumBlocks.toNumber() - 1) - ) { - break; - } + const block = await l2Provider.getBlock(blockNumber); - const block = await l2Provider.getBlock(blockNumber); + // commit and propose block, so our provers can prove it. + const { proposedEvent } = await proposer.commitThenProposeBlock(block); - // commit and propose block, so our provers can prove it. - const { proposedEvent } = await proposer.commitThenProposeBlock( - block + // submit a proof for each prover + for (const prover of provers) { + await prover.prove( + proposedEvent.args.id.toNumber(), + blockNumber, + proposedEvent.args.meta as any as BlockMetadata ); + } - // submit a proof for each prover - for (const prover of provers) { - await prover.prove( - proposedEvent.args.id.toNumber(), - blockNumber, - proposedEvent.args.meta as any as BlockMetadata - ); - } + const forkChoice = await taikoL1.getForkChoice( + proposedEvent.args.id.toNumber(), + block.parentHash + ); + expect(forkChoice).not.to.be.undefined; + expect(forkChoice.provers.length).to.be.eq( + config.maxProofsPerForkChoice.toNumber() + ); - const forkChoice = await taikoL1.getForkChoice( - proposedEvent.args.id.toNumber(), - block.parentHash - ); - expect(forkChoice).not.to.be.undefined; - expect(forkChoice.provers.length).to.be.eq( - config.maxProofsPerForkChoice.toNumber() - ); + await sleepUntilBlockIsVerifiable( + taikoL1, + proposedEvent.args.id.toNumber(), + 0 + ); + await verifyBlocks(taikoL1, 1); + + // all provers had same initial TKO balance. + // each prover in order should have less balance than the previous. + for (let i = 0; i < forkChoice.provers.length; i++) { + if (i !== 0) { + const proverBalance = await tkoTokenL1.balanceOf( + forkChoice.provers[i] + ); + const previousProverBalance = await tkoTokenL1.balanceOf( + forkChoice.provers[i - 1] + ); - await sleepUntilBlockIsVerifiable( - taikoL1, - proposedEvent.args.id.toNumber(), - 0 - ); - await verifyBlocks(taikoL1, 1); - - // all provers had same initial TKO balance. - // each prover in order should have less balance than the previous. - for (let i = 0; i < forkChoice.provers.length; i++) { - if (i !== 0) { - const proverBalance = await tkoTokenL1.balanceOf( - forkChoice.provers[i] - ); - const previousProverBalance = await tkoTokenL1.balanceOf( - forkChoice.provers[i - 1] - ); - - expect(previousProverBalance.gt(proverBalance)).to.be.eq( - true - ); - } + expect(previousProverBalance.gt(proverBalance)).to.be.eq(true); } } });