Skip to content

Comments

Adding more tests scenarios for battle model#157

Merged
coxmars merged 1 commit intoAkatsukiLabs:mainfrom
Gerson2102:battle-testing-model
Jun 29, 2025
Merged

Adding more tests scenarios for battle model#157
coxmars merged 1 commit intoAkatsukiLabs:mainfrom
Gerson2102:battle-testing-model

Conversation

@Gerson2102
Copy link
Contributor

Pull Request Overview

📝 Summary

More tests cases for Battle model.

Related Issues

Type of Change

Mark with an x all the checkboxes that apply (like [x]).

  • 📝 Documentation (updates to README, docs, or comments)
  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • 👌 Enhancement (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)

🔧 Tests Results

Based on the current battle.cairo file, here are the test cases implemented:

Battle State Management:

  • test_end() - Verifies battle ending sets correct winner and status
  • test_is_active() / test_is_finished() - Tests initial battle state checks
  • test_is_finished_after_end() - Confirms status changes after battle completion
  • test_battle_status_transitions() - Tests full status flow (Waiting → Finished)

Turn Management:

  • test_switch_turn() - Basic turn switching functionality
  • test_switch_turn_multiple_times() - Multiple consecutive turn switches
  • test_switch_turn_alternates_correctly() - Proper player alternation logic

Edge Cases & Data Integrity:

  • test_battle_with_zero_addresses() - Handles zero contract addresses
  • test_battle_consistency_after_operations() - Ensures immutable fields stay unchanged after operations

Coverage: 9 active tests covering battle lifecycle, turn management, status validation, and data consistency. One timestamp test remains commented out.

Test Coverage

  • Unit Tests
  • Integration Tests
  • Manual Testing

Evidence

image

@Gerson2102
Copy link
Contributor Author

For the update_timestamp() function I did not find a way of changing its value. And I found this related to cheat the block timestamp for testing using snforge_std. But I think we can't use starknet-foundry in Dojo games. Let me know if I'm wrong :)

@coxmars
Copy link
Contributor

coxmars commented Jun 29, 2025

For the update_timestamp() function I did not find a way of changing its value. And I found this related to cheat the block timestamp for testing using snforge_std. But I think we can't use starknet-foundry in Dojo games. Let me know if I'm wrong :)

Got it, no problem. Thanks for the help it looks good 🫡

@coxmars coxmars merged commit 9c0b80c into AkatsukiLabs:main Jun 29, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

📝 Enhance Battle Model Unit Tests with Additional Edge Cases

2 participants