Files
zeekayandHanzo Dev 8c2e9e3d6f Add Foundry exploit tests for all 30 levels
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]>
2026-09-23 02:23:08 -07:00

33 lines
1.0 KiB
Solidity

// SPDX-License-Identifier: MIT
pragma solidity 0.8.37;
import {LuxTest} from "../Base.t.sol";
import {KingFactory} from "../../src/levels/KingFactory.sol";
import {King} from "../../src/levels/King.sol";
import {KingAttack} from "../../src/attacks/KingAttack.sol";
contract KingLevel is LuxTest {
KingFactory factory;
address player = makeAddr("player");
function setUp() public {
_deployCore();
factory = new KingFactory();
_register(factory);
}
function test_solve() public {
address instance = _create(factory, player, 0.001 ether);
_assertUnsolved(instance, player);
// Become king from a contract with no payable fallback: the game can no
// longer dethrone us because paying the king reverts.
KingAttack attack = new KingAttack();
vm.deal(address(this), 1 ether);
attack.doYourThing{value: 0.001 ether}(instance);
assertEq(King(payable(instance))._king(), address(attack));
_assertSolved(factory, instance, player);
}
}