[Tests] ISSUE-0017: Battle branch coverage fuzz + monsterSlot fix - #29
Conversation
… fix New: test/BattleFuzz.t.sol (10 tests incl. 10k fuzz): - AliceFasterWins: aFirst branch (alice.spd > bob.spd) - BobFasterWins: bFirst branch - BothAlreadyDeadHitsDrawBranch: loop never runs, draw via else branch - SuperEffectiveDamage: 1.5x Fire > Nature - ResistedDamage: 0.5x Water < Electric - OneShotKill: damage > def.hp path, turns==0 - DrawDoesNotCallRecordBattle: !draw gate on recordBattle - NonDrawCallsRecordBattle: recordBattle path + XP/streak updates - DeterminismOverState: two challenges between same pair - testFuzz_BattleOutputAlwaysValid: 10k fuzz over (hp, atk, def, spd) Coverage: 85% -> 90% lines, 62% -> 68% branches. Bug fix in MonsterNFT.sol: - monsterSlot(tokenId) was returning keccak256(abi.encode(tokenId, 0)) but _monsters is at slot 9 (after ERC721 + Ownable + ReentrancyGuard state). Fixed by introducing _MONSTERS_SLOT constant + test updated to assert the correct slot. Discovered while writing the BattleFuzz test (initial attempts to seed monster storage via vm.store returned all-zeros because the wrong slot was being written). Closes #27 (ISSUE-0017).
…inal 5) Pollinations batch complete for all 12 species! 48/48 hero images generated. Species: 1. EmberFox (Fire, Common) - 4 stages 2. MagmaTurtle (Fire, Common) - 4 stages 3. FlameBird (Fire, Rare) - 4 stages 4. AquaPup (Water, Common) - 4 stages 5. BubbleFish (Water, Common) - 4 stages 6. OceanDragon (Water, Legendary) - 4 stages 7. LeafRabbit (Nature, Common) - 4 stages 8. MossGolem (Nature, Common) - 4 stages 9. ForestDeer (Nature, Rare) - 4 stages 10. VoltCat (Electric,Common) - 4 stages 11. SparkMouse (Electric,Common) - 4 stages 12. ThunderWolf (Electric,Rare) - 4 stages manifest.json committed with seed + byte size for every output.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (20)
📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThe PR corrects ChangesContract storage and battle validation
Monster asset manifest
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related issues
Possibly related PRs
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Adversarial review — APPROVEbug-hunter: 10 new tests + 10k fuzz. All pass. The architecture-reviewer: Tests use security-reviewer: No new attack surface. Tests use Self-merge note: single-maintainer context. |
Closes
#27 (ISSUE-0017).
Change Summary
contracts/test/BattleFuzz.t.solcovering the_resolvedecision tree and_attackformula paths. Includes a 10k fuzz.MonsterNFT.monsterSlot()returned the wrong storage slot._monstersis at slot 9 (after OZ inheritance), not slot 0. Discovered while writing the fuzz test.Coverage
Self-merge note
Single-maintainer context.
Reviewers
Summary by CodeRabbit
Bug Fixes
New Features