Skip to content

Commit

Permalink
test(protocol): integration tests for isMessageFailed (taikoxyz#13072)
Browse files Browse the repository at this point in the history
Co-authored-by: jeff <[email protected]>
Co-authored-by: Jeffery Walsh <[email protected]>
Co-authored-by: David <[email protected]>
Co-authored-by: Daniel Wang <[email protected]>
  • Loading branch information
5 people authored Feb 23, 2023
1 parent f39e65d commit 8908d8d
Show file tree
Hide file tree
Showing 16 changed files with 394 additions and 77 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/protocol.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ jobs:
working-directory: ./packages/protocol
run: pnpm test:tokenomics

- name: protocol - Bridge Tests
working-directory: ./packages/protocol
run: pnpm test:bridge

- name: protocol - Test Coverage
working-directory: ./packages/protocol
run: pnpm test:coverage
Expand Down
1 change: 1 addition & 0 deletions packages/protocol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"test:coverage": "pnpm coverage",
"generate:genesis": "ts-node ./utils/generate_genesis/main.ts",
"test:genesis": "./test/genesis/generate_genesis.test.sh",
"test:bridge": "TEST_TYPE=integrationbridge ./test/test_integration.sh",
"test:integration": "TEST_TYPE=integration ./test/test_integration.sh",
"test:tokenomics": "TEST_TYPE=tokenomics ./test/test_integration.sh",
"test:all": "pnpm run test && pnpm run test:integration && pnpm run test:tokenomics && pnpm run test:genesis",
Expand Down
54 changes: 43 additions & 11 deletions packages/protocol/test/L1/TaikoL1.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ import {
commitBlock,
generateCommitHash,
} from "../utils/commit";
import { encodeEvidence } from "../utils/encoding";
import {
readShouldRevertWithCustomError,
txShouldRevertWithCustomError,
} from "../utils/errors";
import Evidence from "../utils/evidence";
import { initIntegrationFixture } from "../utils/fixture";
import halt from "../utils/halt";
import { onNewL2Block } from "../utils/onNewL2Block";
import { buildProposeBlockInputs } from "../utils/propose";
import Proposer from "../utils/proposer";
import { buildProveBlockInputs, proveBlock } from "../utils/prove";
import Prover from "../utils/prover";
import { getBlockHeader } from "../utils/rpc";
import { seedTko, sendTinyEtherToZeroAddress } from "../utils/seed";
import {
commitProposeProveAndVerify,
sleepUntilBlockIsVerifiable,
verifyBlocks,
} from "../utils/verify";
import {
txShouldRevertWithCustomError,
readShouldRevertWithCustomError,
} from "../utils/errors";
import { getBlockHeader } from "../utils/rpc";
import Evidence from "../utils/evidence";
import { encodeEvidence } from "../utils/encoding";

describe("integration:TaikoL1", function () {
let taikoL1: TaikoL1;
Expand Down Expand Up @@ -240,7 +240,7 @@ describe("integration:TaikoL1", function () {
id: 1,
l1Height: 0,
l1Hash: ethers.constants.HashZero,
beneficiary: block.miner,
beneficiary: commit.beneficiary,
txListHash: commit.txListHash,
mixHash: ethers.constants.HashZero,
extraData: block.extraData,
Expand Down Expand Up @@ -274,7 +274,7 @@ describe("integration:TaikoL1", function () {
id: 0,
l1Height: 0,
l1Hash: ethers.constants.HashZero,
beneficiary: block.miner,
beneficiary: commit.beneficiary,
txListHash: commit.txListHash,
mixHash: ethers.constants.HashZero,
extraData: block.extraData,
Expand Down Expand Up @@ -304,7 +304,7 @@ describe("integration:TaikoL1", function () {
id: 0,
l1Height: 0,
l1Hash: ethers.constants.HashZero,
beneficiary: block.miner,
beneficiary: commit.beneficiary,
txListHash: commit.txListHash,
mixHash: ethers.constants.HashZero,
extraData: ethers.utils.hexlify(ethers.utils.randomBytes(33)), // invalid extradata
Expand Down Expand Up @@ -374,8 +374,40 @@ describe("integration:TaikoL1", function () {

// now expect another proposed block to be invalid since all slots are full and none have
// been proven.
const { commitConfirmations } = await taikoL1.getConfig();
const block = await l2Provider.getBlock("latest");
const { tx: commitBlockTx, commit } = await commitBlock(
taikoL1.connect(l1Signer),
block,
0
);
const commitReceipt = await commitBlockTx.wait(1);

for (let i = 0; i < commitConfirmations.toNumber() + 5; i++) {
await sendTinyEtherToZeroAddress(l1Signer);
}

const meta: BlockMetadata = {
id: 0,
l1Height: 0,
l1Hash: ethers.constants.HashZero,
beneficiary: commit.beneficiary,
txListHash: commit.txListHash,
mixHash: ethers.constants.HashZero,
extraData: ethers.utils.hexlify(ethers.utils.randomBytes(32)),
gasLimit: block.gasLimit,
timestamp: 0,
commitSlot: 0,
commitHeight: commitReceipt.blockNumber,
};

await txShouldRevertWithCustomError(
commitAndProposeLatestBlock(taikoL1, l1Signer, l2Provider),
(
await taikoL1.proposeBlock(
buildProposeBlockInputs(block, meta),
{ gasLimit: 500000 }
)
).wait(),
l1Provider,
"L1_TOO_MANY()"
);
Expand Down
Loading

0 comments on commit 8908d8d

Please sign in to comment.