Mystery Box

First Flight #25
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Invalid

To run the testAddReward function, it is necessary to add the owner and change the reward’s ID in the rewardsPoll

The testAddReward function is not working correctly because the addReward function can only be invoked by the owner. Additionally, during the initialization of the smart contract in the constructor, four items are pushed to the rewardPool. As a result, the Diamond Coin item has a different ID than the one declared in the test.

function testAddReward() public {
// @audit add this to change role to owner
vm.prank(owner);
mysteryBox.addReward("Diamond Coin", 2 ether);
MysteryBox.Reward[] memory rewards = mysteryBox.getRewardPool();
assertEq(rewards.length, 5);
// @audit It is necessary to change the ID because during initialization the constructor sets 4 slots for a default values.
assertEq(rewards[4].name, "Diamond Coin");
assertEq(rewards[4].value, 2 ether);
}
Updates

Appeal created

inallhonesty Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Out of scope

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.

Give us feedback!