Commit 13f553d
authored
fix(l2): race conditions in ERC20 integration tests (#6138)
**Motivation**
The L2 integration test workflow failed in [this
run](https://github.com/lambdaclass/ethrex/actions/runs/21723329010/job/62659573593)
with `l2_balance == 0` instead of the expected `100`. This may be caused
by two possible race conditions.
**Description**
**Fix 1: Nonce race condition in `create_deploy`**
(`crates/l2/sdk/src/sdk.rs`)
The contract address was computed from a nonce fetched *after* sending
the deploy transaction. If the transaction was mined before the nonce
query returned, `get_nonce` would return N+1 instead of N, resulting in
an incorrect contract address. The test would then use the wrong address
for the ERC20 deposit, causing the bridge's `mintERC20` to silently fail
(it uses `call()` and falls back to `_withdraw` instead of reverting).
Fix: Use `receipt.tx_info.contract_address` from the transaction receipt
instead of computing it from the nonce.
**Fix 2: Compile race condition in integration tests**
(`test/tests/l2/integration_tests.rs`)
Both ERC20 tests compile `L2ERC20.sol` to the same output file
(`solc_out/TestTokenL2.bin`). When running concurrently via `JoinSet`,
one test could read partially written bytecode from the other test's
compilation.
Fix: Each test now compiles to its own output directory
(`test_erc20_roundtrip/` and `test_erc20_mismatch/`).
**Checklist**
- [ ] Updated `STORE_SCHEMA_VERSION` (crates/storage/lib.rs) if the PR
includes breaking changes to the `Store` requiring a re-sync.1 parent f9eea3b commit 13f553d
2 files changed
Lines changed: 10 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
444 | 444 | | |
445 | 445 | | |
446 | 446 | | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
| 447 | + | |
457 | 448 | | |
458 | | - | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
459 | 452 | | |
460 | 453 | | |
461 | 454 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
562 | 562 | | |
563 | 563 | | |
564 | 564 | | |
| 565 | + | |
565 | 566 | | |
566 | 567 | | |
567 | 568 | | |
| |||
570 | 571 | | |
571 | 572 | | |
572 | 573 | | |
573 | | - | |
| 574 | + | |
574 | 575 | | |
575 | 576 | | |
576 | 577 | | |
| |||
579 | 580 | | |
580 | 581 | | |
581 | 582 | | |
582 | | - | |
| 583 | + | |
583 | 584 | | |
584 | 585 | | |
585 | 586 | | |
| |||
783 | 784 | | |
784 | 785 | | |
785 | 786 | | |
| 787 | + | |
786 | 788 | | |
787 | 789 | | |
788 | 790 | | |
| |||
791 | 793 | | |
792 | 794 | | |
793 | 795 | | |
794 | | - | |
| 796 | + | |
795 | 797 | | |
796 | 798 | | |
797 | 799 | | |
| |||
800 | 802 | | |
801 | 803 | | |
802 | 804 | | |
803 | | - | |
| 805 | + | |
804 | 806 | | |
805 | 807 | | |
806 | 808 | | |
| |||
0 commit comments