In this assignment, you are required to write some test cases for the stateful smart contract. This contract is based on the previous assignment.
Write positive test cases to ensure that the smart contract works in the intended way and negative test cases to ensure transactions are rejected if they do fail the logic checks within the contract.
Complete the code in test/success_tests.js
. Write test cases to cover these scenarios,
- Initial monster health is same as the value specified during deployment.
- Initial max damage is set to 0.
- Initial player damage is set to 0.
- Max damage and monster health is updated.
- Player damage is updated
- Highest player damage address is recorded.
- MVP player receives the reward.
Complete the code in test/negative_tests.js
. Write test cases to cover these scenarios,
- Initialize monster with < 5 Health fails.
- Attacking a monster with 0 health fails.
- Reward player when monster is alive.
- Reward player fails when address is accounts is different from global state.
- Reward player fails when called by non-creator
Feel free to include additional test cases if necessary.
run algokit bootstrap poetry
within this folder
run yarn install
- Copy
.env.example
to.env
- Update Algorand Sandbox credentials in
.env
file - Update accounts in
.env
file
run poetry shell
- run
python game_approval.py
- run
python game_clearstate.py
- run
yarn run mocha tests/success_tests.js
- run
yarn run mocha tests/negative_tests.js