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]>
35 lines
1.1 KiB
Solidity
35 lines
1.1 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
pragma solidity 0.8.37;
|
|
|
|
import {LuxTest} from "../Base.t.sol";
|
|
import {NaughtCoinFactory} from "../../src/levels/NaughtCoinFactory.sol";
|
|
import {NaughtCoin} from "../../src/levels/NaughtCoin.sol";
|
|
import {NaughtCoinAttack} from "../../src/attacks/NaughtCoinAttack.sol";
|
|
|
|
contract NaughtCoinLevel is LuxTest {
|
|
NaughtCoinFactory factory;
|
|
address player = makeAddr("player");
|
|
|
|
function setUp() public {
|
|
_deployCore();
|
|
factory = new NaughtCoinFactory();
|
|
_register(factory);
|
|
}
|
|
|
|
function test_solve() public {
|
|
address instance = _create(factory, player, 0);
|
|
uint256 bal = NaughtCoin(instance).balanceOf(player);
|
|
assertGt(bal, 0);
|
|
_assertUnsolved(instance, player);
|
|
|
|
// The timelock only guards transfer(), not transferFrom().
|
|
NaughtCoinAttack attack = new NaughtCoinAttack();
|
|
vm.prank(player, player);
|
|
NaughtCoin(instance).approve(address(attack), bal);
|
|
attack.attack(instance, player);
|
|
|
|
assertEq(NaughtCoin(instance).balanceOf(player), 0);
|
|
_assertSolved(factory, instance, player);
|
|
}
|
|
}
|