Skip to main content

Run Bridge Tests

This guide will show you how to run end-to-end (e2e) bridge tests against a Kurtosis devnet.

note

The devnet deploys three bridges: the Plasma bridge (DepositManager, WithdrawManager, predicates), the PoS bridge (RootChainManager, ChildChainManager, pos-portal predicates) and fx-portal (FxRoot, FxChild, state and ERC20/ERC721/ERC1155 tunnels). The bridge test suites cover each independently.

info

This guide assumes you have a running devnet, if that's not the case, you can head to the Getting Started section.

Clone the Test Suite​

First, clone the 0xPolygon/pos-e2e repository. Bridge tests are located in tests/bridge.

git clone https://github.com/0xPolygon/pos-e2e.git
cd pos-e2e

Run Bats Tests​

info

We rely on bats, a bash testing framework to run most of our e2e tests. The next steps assume you have it installed.

Then run the L1-to-L2 bridge test to validate that Heimdall and Bor can process bridge events and trigger state synchronizations.

bats --filter-tags pos,bridge --recursive tests/

After the tests complete, you should see output similar to:

tests/bridge/fx.bats
✓ send a message from L1 to L2 via fx-portal state tunnel
✓ fx-portal L1 state stays pending on L2 until the state sync is committed
✓ force a state sync through FxRoot without going through a root tunnel
✓ bridge ERC20 from L1 to L2 via fx-portal
✓ bridge ERC721 from L1 to L2 via fx-portal
✓ bridge ERC1155 from L1 to L2 via fx-portal

tests/bridge/plasma.bats
✓ bridge POL from L1 to L2 via plasma bridge
✓ bridge MATIC from L1 to L2 via plasma bridge
✓ bridge ETH from L1 to L2 via plasma bridge
✓ bridge ERC20 from L1 to L2 via plasma bridge
✓ bridge ERC721 from L1 to L2 via plasma bridge

tests/bridge/pos.bats
✓ bridge ETH from L1 to L2 via pos bridge
✓ bridge ERC20 from L1 to L2 via pos bridge
✓ bridge ERC721 from L1 to L2 via pos bridge
✓ bridge ERC1155 from L1 to L2 via pos bridge

15 tests, 0 failures

Once the deposits have landed on L2, run the L2-to-L1 withdraw tests to exercise the exit flow (burn on L2, wait for a checkpoint on L1, build an exit proof, claim).

bats --filter-tags pos,withdraw --recursive tests/
warning

Withdraw tests take several minutes per case — each needs a fresh L1 checkpoint to cover the burn block before the exit proof can be built. Plasma withdraws also wait an additional HALF_EXIT_PERIOD after queuing.

After the tests complete, you should see output similar to:

tests/bridge/fx.bats
✓ send a message from L2 to L1 via fx-portal state tunnel
✓ withdraw ERC20 from L2 to L1 via fx-portal
✓ withdraw ERC721 from L2 to L1 via fx-portal
✓ withdraw ERC1155 from L2 to L1 via fx-portal

tests/bridge/plasma.bats
✓ withdraw native tokens from L2 to L1 via plasma bridge
✓ withdraw MaticWeth from L2 to L1 via plasma bridge
✓ withdraw ERC20 from L2 to L1 via plasma bridge
✓ withdraw ERC721 from L2 to L1 via plasma bridge

tests/bridge/pos.bats
✓ withdraw ETH from L2 to L1 via pos bridge
✓ withdraw ERC20 from L2 to L1 via pos bridge
✓ withdraw ERC721 from L2 to L1 via pos bridge
✓ withdraw ERC1155 from L2 to L1 via pos bridge

12 tests, 0 failures

If any tests fail, check the logs in your Kurtosis enclave for more details.