# Real LaunchToken and DonationVault integration - Commit tested `5e16ce53748597be091771df9beae3d54b9310cf`. - Forge `1.9.0` (build commit `6056c5845d34205a83cf7108042adb137325c9df`). - Solc `0.8.26`, as pinned in `foundry.toml` and confirmed by both compilations. The scratch test deployed `LaunchToken` and passed its address to `DonationVault`. The report and the temporary test are the only authored files. No tracked files changed. All requested checks ran locally. ## Commands in execution order An em dash indicates a command that did not run tests. The first Python wrapper captured exit codes for its seven subprocesses. The second shell invocation wrote the scratch test and propagated the Forge test exit status. | Command | Exit | Passed | Failed | Skipped | Outcome | | --- | ---: | ---: | ---: | ---: | --- | | `python3 -` (baseline command wrapper) | 0 | — | — | — | Ran the next seven commands in order. | | `git rev-parse HEAD` | 0 | — | — | — | Matched the expected commit. | | `git status --short` | 0 | — | — | — | Clean at the start. | | `forge --version` | 0 | — | — | — | Forge 1.9.0. | | `cat foundry.toml src/LaunchToken.sol src/DonationVault.sol` | 0 | — | — | — | Read the compiler pin and contract interfaces. | | `rg --files test` | 0 | — | — | — | Found the two existing suites. | | `forge build --offline` | 0 | — | — | — | Compiled four files with Solc 0.8.26. | | `forge test --offline` | 0 | 24 | 0 | 0 | 16 vault tests and 8 token tests passed. | | `python3 -` (scratch file writer) | 0 | — | — | — | Wrote `test/scratch/RealTokenVault.t.sol`. | | `forge test --offline --match-path test/scratch/RealTokenVault.t.sol --fuzz-runs 256` | 0 | 10 | 0 | 0 | Compiled the scratch test with Solc 0.8.26 and ran it. | | `python3 -` (report writer and validation wrapper) | 0 | — | — | — | Checked Git status, then verified the report size, source block and final line. | | `git status --short --untracked-files=all` | 0 | — | — | — | Confirmed no tracked changes before writing the report. | The shell printed the scratch write and test statuses with `printf` (both exited 0). The build emitted three lint warnings in `src/DonationVault.sol`. Forge reported `reentrancy-no-eth` at line 119 for the token call and `reentrancy-events` at lines 71 and 85 for the `Donated` and `Claimed` events. The build succeeded. ## Cases | Case | Result | Observed behavior | | --- | --- | --- | | A | Pass | The name was `test`, the symbol was `testAdam`, and decimals were 18. The deployer held the full supply of `1e27` base units. The vault referenced that token. | | B | Pass | After approval, donation returned ID 1, increased the vault balance, credited the donor, recorded the unclaimed gift, increased outstanding obligations, and emitted `Donated` with the expected fields. | | C | Pass | With zero or insufficient allowance, the token raises `ERC20InsufficientAllowance(address,uint256,uint256)` and the vault surfaces `TransferFailed()`. Both tests checked the vault error and verified that balances, allowance, gift state, points and outstanding obligations were unchanged. | | D | Pass | The second wallet received the whole gift, the claim flag was set, and outstanding obligations fell to zero. Donor points were preserved and claimer points stayed at zero. Donor self-claim reverted with `SelfClaim(1)` and repeat claim reverted with `AlreadyClaimed(1)`. | | E | Pass | A direct transfer reached the vault without creating a gift, increasing the gift count, crediting points or increasing outstanding obligations. | | F | Pass | Both 1 base unit and the whole supply were donated and claimed as single gifts in separate tests. | | G | Pass | Two donors created gifts with sequential IDs. Donor points matched their cumulative donations, and the vault covered outstanding obligations after every step. The donate-then-claim fuzz test passed 256 runs over amounts mapped to the inclusive range from 1 base unit to the full supply. | ## Scratch test source Save this as `test/scratch/RealTokenVault.t.sol` and run the matching Forge command above. ```solidity // SPDX-License-Identifier: MIT pragma solidity 0.8.26; import {LaunchToken} from "../../src/LaunchToken.sol"; import {DonationVault} from "../../src/DonationVault.sol"; interface Vm { function prank(address sender) external; function expectEmit(bool topic1, bool topic2, bool topic3, bool data, address emitter) external; function expectRevert(bytes calldata revertData) external; } contract RealTokenVaultTest { Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code"))))); uint256 private constant SUPPLY = 1e27; address private constant BOB = address(0xB0B); address private constant CAROL = address(0xCA401); LaunchToken private token; DonationVault private vault; event Donated(uint256 indexed giftId, address indexed donor, uint256 amount); function setUp() external { token = new LaunchToken(); vault = new DonationVault(address(token)); } function testAIdentity() external view { require(keccak256(bytes(token.name())) == keccak256("test"), "name"); require(keccak256(bytes(token.symbol())) == keccak256("testAdam"), "symbol"); require(token.decimals() == 18, "decimals"); require(token.totalSupply() == SUPPLY, "supply"); require(token.balanceOf(address(this)) == SUPPLY, "deployer allocation"); require(address(vault.token()) == address(token), "vault token"); } function testBApproveAndDonate() external { uint256 amount = 12 ether; uint256 balanceBefore = token.balanceOf(address(vault)); require(token.approve(address(vault), amount), "approve"); vm.expectEmit(true, true, false, true, address(vault)); emit Donated(1, address(this), amount); require(vault.donate(amount) == 1, "first gift ID"); require(token.balanceOf(address(vault)) == balanceBefore + amount, "vault balance"); require(vault.points(address(this)) == amount, "donor points"); (address donor, uint256 received, bool claimed) = vault.getGift(1); require(donor == address(this) && received == amount && !claimed, "gift record"); require(vault.totalOutstanding() == amount, "outstanding"); } function testCNoAllowance() external { assertRejectedDonation(0); } function testCInsufficientAllowance() external { require(token.approve(address(vault), 1), "approve"); assertRejectedDonation(1); } function assertRejectedDonation(uint256 allowance) private { vm.expectRevert(abi.encodeWithSelector(DonationVault.TransferFailed.selector)); vault.donate(2); require(token.balanceOf(address(this)) == SUPPLY, "donor balance changed"); require(token.balanceOf(address(vault)) == 0, "vault balance changed"); require(token.allowance(address(this), address(vault)) == allowance, "allowance changed"); require(vault.giftCount() == 0, "gift created"); (address donor, uint256 amount, bool claimed) = vault.getGift(1); require(donor == address(0) && amount == 0 && !claimed, "gift record changed"); require(vault.points(address(this)) == 0, "points changed"); require(vault.totalOutstanding() == 0, "outstanding changed"); } function testDClaimAndRejectInvalidClaims() external { uint256 amount = 13 ether; require(token.approve(address(vault), amount), "approve"); uint256 id = vault.donate(amount); vm.expectRevert(abi.encodeWithSelector(DonationVault.SelfClaim.selector, id)); vault.claim(id); require(!vault.isClaimed(id) && vault.totalOutstanding() == amount, "self-claim changed gift"); assertClaim(id, amount); vm.expectRevert(abi.encodeWithSelector(DonationVault.AlreadyClaimed.selector, id)); vm.prank(BOB); vault.claim(id); require(token.balanceOf(BOB) == amount, "repeat claim changed balance"); } function testEDirectTransfer() external { uint256 giftCountBefore = vault.giftCount(); require(token.transfer(address(vault), 1 ether), "transfer"); require(token.balanceOf(address(vault)) == 1 ether, "vault balance"); require(vault.giftCount() == giftCountBefore, "gift count changed"); (address donor, uint256 amount, bool claimed) = vault.getGift(giftCountBefore + 1); require(donor == address(0) && amount == 0 && !claimed, "gift created"); require(vault.points(address(this)) == 0, "points changed"); require(vault.totalOutstanding() == 0, "outstanding changed"); } function testFOneBaseUnit() external { donateAndClaim(1); } function testFEntireSupply() external { donateAndClaim(SUPPLY); } function testGSeveralDonorsAndGifts() external { require(token.transfer(BOB, 9), "fund Bob"); assertFunded(0); require(token.approve(address(vault), 10), "approve"); assertFunded(0); require(vault.donate(3) == 1, "gift ID 1"); assertFunded(3); vm.prank(BOB); require(token.approve(address(vault), 9), "Bob approve"); assertFunded(3); vm.prank(BOB); require(vault.donate(9) == 2, "gift ID 2"); assertFunded(12); require(vault.donate(7) == 3, "gift ID 3"); assertFunded(19); require(vault.giftCount() == 3, "gift count"); vm.prank(CAROL); require(vault.claim(2) == 9, "gift 2 payout"); assertFunded(10); vm.prank(BOB); require(vault.claim(1) == 3, "gift 1 payout"); assertFunded(7); vm.prank(CAROL); require(vault.claim(3) == 7, "gift 3 payout"); assertFunded(0); require(vault.points(address(this)) == 10, "deployer points"); require(vault.points(BOB) == 9, "Bob points"); require(vault.points(CAROL) == 0, "Carol points"); require(token.balanceOf(BOB) == 3 && token.balanceOf(CAROL) == 16, "claim balances"); } function testFuzzGDonateThenClaim(uint256 input) external { donateAndClaim(1 + input % SUPPLY); } function donateAndClaim(uint256 amount) private { require(token.approve(address(vault), amount), "approve"); uint256 id = vault.donate(amount); require(id == 1, "gift ID"); require(token.balanceOf(address(this)) == SUPPLY - amount, "donor balance"); require(token.balanceOf(address(vault)) == amount, "vault balance after donation"); assertFunded(amount); assertClaim(id, amount); } function assertClaim(uint256 id, uint256 amount) private { vm.prank(BOB); require(vault.claim(id) == amount, "claim return"); require(token.balanceOf(BOB) == amount, "claimer balance"); require(vault.isClaimed(id), "claim flag"); require(token.balanceOf(address(vault)) == 0, "vault balance after claim"); assertFunded(0); require(vault.points(address(this)) == amount, "donor points after claim"); require(vault.points(BOB) == 0, "claimer points"); } function assertFunded(uint256 expectedOutstanding) private view { uint256 outstanding = vault.totalOutstanding(); require(outstanding == expectedOutstanding, "unexpected outstanding"); require(token.balanceOf(address(vault)) >= outstanding, "underfunded vault"); } } ``` integration: pass