Skip to content

Commit

Permalink
added extra test
Browse files Browse the repository at this point in the history
  • Loading branch information
dan13ram committed Mar 25, 2024
1 parent 5625c34 commit 5e95f17
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 58 deletions.
117 changes: 59 additions & 58 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,92 +1,93 @@
CharacterAccountTest:testEquipAndUnequipViaMultiSendDelegateCall() (gas: 856430)
CharacterAccountTest:testEquipItemToCharacter() (gas: 869190)
CharacterAccountTest:testEquipViaMultiSendDelegateCall() (gas: 876672)
CharacterAccountTest:testUnequipItemToCharacter() (gas: 864025)
CharacterAccountTest:testEquipAndUnequipViaMultiSendDelegateCall() (gas: 856475)
CharacterAccountTest:testEquipItemToCharacter() (gas: 869213)
CharacterAccountTest:testEquipViaMultiSendDelegateCall() (gas: 876650)
CharacterAccountTest:testUnequipItemToCharacter() (gas: 864003)
CharacterAccountTest:test_Owner() (gas: 591129)
CharacterEligibilityAdaptorTest:testIsEligible() (gas: 53561)
CharacterEligibilityAdaptorTest:testSupportsInterface() (gas: 13427)
CharacterSheetsFactoryTest:testCreateAndInitialize() (gas: 3886107)
CharacterSheetsFactoryTest:testCreateAndInitializeWithZeroDao() (gas: 3681813)
CharacterSheetsFactoryTest:testCreateAndInitializeWithZeroDao() (gas: 3681791)
CharacterSheetsFactoryTest:testCreateCharacterEligibilityAdaptor() (gas: 112049)
CharacterSheetsFactoryTest:testCreateCharacterSheets() (gas: 110033)
CharacterSheetsFactoryTest:testCreateClassLevelAdaptor() (gas: 112667)
CharacterSheetsFactoryTest:testCreateClasses() (gas: 111841)
CharacterSheetsFactoryTest:testCreateClasses() (gas: 111906)
CharacterSheetsFactoryTest:testCreateExperience() (gas: 110086)
CharacterSheetsFactoryTest:testCreateItems() (gas: 111924)
CharacterSheetsFactoryTest:testDeployment() (gas: 13107)
CharacterSheetsFactoryTest:testDeploymentRevert() (gas: 16722)
CharacterSheetsFactoryTest:testDeploymentRevert() (gas: 16700)
CharacterSheetsFactoryTest:testInitializeContracts() (gas: 3839130)
CharacterSheetsFactoryTest:testUpdateImplementationAddressStorage() (gas: 21563)
CharacterSheetsTest:testChangeBaseUri() (gas: 71686)
CharacterSheetsTest:testChangeBaseUriRevertNotAdmin() (gas: 71586)
CharacterSheetsTest:testEquipItemToCharacter() (gas: 325279)
CharacterSheetsFactoryTest:testUpdateImplementationAddressStorage() (gas: 21541)
CharacterSheetsTest:testChangeBaseUri() (gas: 71664)
CharacterSheetsTest:testChangeBaseUriRevertNotAdmin() (gas: 71564)
CharacterSheetsTest:testEquipItemToCharacter() (gas: 325257)
CharacterSheetsTest:testEquipItemToCharacterReverts() (gas: 216798)
CharacterSheetsTest:testGetCharacterSheetByCharacterId() (gas: 23268)
CharacterSheetsTest:testGetCharacterSheetByCharacterId() (gas: 23246)
CharacterSheetsTest:testGetPlayerIdFromAccountAddress() (gas: 28011)
CharacterSheetsTest:testRemovePlayer() (gas: 947968)
CharacterSheetsTest:testRemovePlayer() (gas: 947946)
CharacterSheetsTest:testRenounceSheet() (gas: 73174)
CharacterSheetsTest:testRenounceSheetReverts() (gas: 72846)
CharacterSheetsTest:testRestoreSheetAfterRemove() (gas: 786137)
CharacterSheetsTest:testRenounceSheetReverts() (gas: 72911)
CharacterSheetsTest:testRestoreSheetAfterRemove() (gas: 786115)
CharacterSheetsTest:testRestoreSheetAfterRenounce() (gas: 722615)
CharacterSheetsTest:testRollCharacterSheet() (gas: 589612)
CharacterSheetsTest:testRollCharacterSheetFailNonMember() (gas: 61074)
CharacterSheetsTest:testRollCharacterSheetRevertAlreadyACharacter() (gas: 67837)
CharacterSheetsTest:testRollFailsForRenouncedSheet() (gas: 118620)
CharacterSheetsTest:testSafeTransferFrom() (gas: 466606)
CharacterSheetsTest:testSafeTransferFromBackAndForth() (gas: 250176)
CharacterSheetsTest:testTransferFrom() (gas: 459763)
CharacterSheetsTest:testUnequipItemFromCharacter() (gas: 308423)
CharacterSheetsTest:testRollCharacterSheet() (gas: 589678)
CharacterSheetsTest:testRollCharacterSheetFailNonMember() (gas: 61141)
CharacterSheetsTest:testRollCharacterSheetRevertAlreadyACharacter() (gas: 67815)
CharacterSheetsTest:testRollFailsForRenouncedSheet() (gas: 118687)
CharacterSheetsTest:testSafeTransferFrom() (gas: 466673)
CharacterSheetsTest:testSafeTransferFromBackAndForth() (gas: 250158)
CharacterSheetsTest:testTransferFrom() (gas: 459741)
CharacterSheetsTest:testUnequipItemFromCharacter() (gas: 308401)
CharacterSheetsTest:testUpdateCharacterMetadata() (gas: 98930)
CharacterSheetsTest:testUpdateContractImplementation() (gas: 5106259)
ClassLevelAdaptorTest:testFuzz_GetCurrentLevel(uint256) (runs: 256, μ: 37072, ~: 34133)
CharacterSheetsTest:testUpdateContractImplementation() (gas: 5106237)
ClassLevelAdaptorTest:testFuzz_GetCurrentLevel(uint256) (runs: 256, μ: 36616, ~: 31620)
ClassLevelAdaptorTest:testSupportsInterface() (gas: 13427)
ClassesTest:testAssignClass() (gas: 281886)
ClassesTest:testAssignClass() (gas: 281864)
ClassesTest:testClaimClass() (gas: 156784)
ClassesTest:testClassExp() (gas: 256831)
ClassesTest:testCreateClass() (gas: 134641)
ClassesTest:testFuzz_BalanceOf(uint256) (runs: 256, μ: 297170, ~: 306346)
ClassesTest:testRenounceClass() (gas: 240925)
ClassesTest:testFuzz_BalanceOf(uint256) (runs: 256, μ: 296663, ~: 306324)
ClassesTest:testRenounceClass() (gas: 240903)
ClassesTest:testRevokeClass() (gas: 213123)
ClassesTest:testTransferClass() (gas: 761708)
ExperienceTest:testBurnExp() (gas: 195465)
ExperienceTest:testBurnExp() (gas: 195443)
ExperienceTest:testDropExp() (gas: 251916)
ExperienceTest:testExperienceDeployment() (gas: 18130)
ExperienceTest:testExperienceDeployment() (gas: 18173)
HatsAdaptorTest:testAddGameMaster() (gas: 147549)
HatsAdaptorTest:testHatsAdaptorDeployment() (gas: 116841)
HatsAdaptorTest:testIsCharacter() (gas: 83700)
HatsAdaptorTest:testIsGameMaster() (gas: 63928)
HatsAdaptorTest:testIsPlayer() (gas: 86868)
HatsAdaptorTest:testMintCharacterHat() (gas: 213244)
HatsAdaptorTest:testHatsAdaptorDeployment() (gas: 116819)
HatsAdaptorTest:testIsCharacter() (gas: 83743)
HatsAdaptorTest:testIsGameMaster() (gas: 63906)
HatsAdaptorTest:testIsPlayer() (gas: 86846)
HatsAdaptorTest:testMintCharacterHat() (gas: 213222)
HatsAdaptorTest:testMintPlayerHat() (gas: 697854)
HatsAdaptorTest:test_CheckCharacterHatEligibility() (gas: 93109)
HatsAdaptorTest:test_addValidGame() (gas: 233)
ItemsTest:testClaimItem() (gas: 873498)
ItemsTest:testClaimItemRevert() (gas: 1261443)
ItemsTest:testComplexRequirementsClaimRevert() (gas: 1265462)
ItemsTest:testComplexRequirementsClaimRevertWithTooMuchExp() (gas: 1286183)
ItemsTest:testComplexRequirementsClaimWithItem1() (gas: 1329261)
ItemsTest:testComplexRequirementsClaimWithItem1ForShallowNot() (gas: 1283298)
ItemsTest:testComplexRequirementsClaimWithItem2() (gas: 1335622)
ItemsTest:testCraftItem() (gas: 683930)
ItemsTest:testCraftItemRevert() (gas: 437358)
HatsAdaptorTest:test_CheckCharacterHatEligibility() (gas: 93087)
HatsAdaptorTest:test_addValidGame() (gas: 211)
ItemsTest:testClaimItem() (gas: 873504)
ItemsTest:testClaimItemRevert() (gas: 1261449)
ItemsTest:testComplexRequirementsClaimRevert() (gas: 1265474)
ItemsTest:testComplexRequirementsClaimRevertWithTooMuchExp() (gas: 1286201)
ItemsTest:testComplexRequirementsClaimWithItem1() (gas: 1329268)
ItemsTest:testComplexRequirementsClaimWithItem1ForShallowNot() (gas: 1283305)
ItemsTest:testComplexRequirementsClaimWithItem2() (gas: 1335640)
ItemsTest:testCraftItem() (gas: 683947)
ItemsTest:testCraftItemRevert() (gas: 437336)
ItemsTest:testCreateClaimableItem() (gas: 77675)
ItemsTest:testCreateCraftableItem() (gas: 69533)
ItemsTest:testCreateItemTypeRevert() (gas: 63959)
ItemsTest:testDeleteItem() (gas: 212152)
ItemsTest:testDismantleItems() (gas: 1130468)
ItemsTest:testDropLoot() (gas: 1234531)
ItemsTest:testCreateItemTypeRevert() (gas: 63965)
ItemsTest:testDeleteItem() (gas: 212157)
ItemsTest:testDismantleItems() (gas: 1130480)
ItemsTest:testDropLoot() (gas: 1234537)
ItemsTest:testDropLootRevert() (gas: 234539)
ItemsTest:testInvalidTreeAnd() (gas: 629531)
ItemsTest:testInvalidTreeNot() (gas: 845270)
ItemsTest:testInvalidTreeOr() (gas: 862636)
ItemsTest:testInvalidTreeAnd() (gas: 629537)
ItemsTest:testInvalidTreeNot() (gas: 845276)
ItemsTest:testInvalidTreeOr() (gas: 862642)
ItemsTest:testSimpleRequirementsClaimWithItem1() (gas: 622082)
ItemsTest:testURI() (gas: 20937)
ItemsTest:testUpdateClaimableItemRequirements() (gas: 346689)
ItemsTest:testUpdateCraftableItemRequirements() (gas: 202158)
Test_AdminEligibilityModule:testAddNewAdmin() (gas: 165759)
Test_AdminEligibilityModule:testRemoveAdmin() (gas: 154411)
Test_ElderEligibilityModule:testAddClassToElderModule() (gas: 465435)
Test_AdminEligibilityModule:testRemoveAdmin() (gas: 154477)
Test_ElderEligibilityModule:testAddClassToElderModule() (gas: 465413)
Test_ElderEligibilityModule:testCharacterSheetsLevelEligibilityModule() (gas: 659816)
Test_ElderEligibilityModule:testElderModuleNoCharacter() (gas: 471970)
Test_GameMasterEligibilityModule:testAddNewGameMaster() (gas: 206830)
Test_GameMasterEligibilityModule:testNewModuleSetup() (gas: 135543)
Test_GameMasterEligibilityModule:testRemoveGameMaster() (gas: 192954)
Test_GameMasterEligibilityModule:testAddNewGameMaster() (gas: 206808)
Test_GameMasterEligibilityModule:testNewModuleSetup() (gas: 135588)
Test_GameMasterEligibilityModule:testRemoveGameMaster() (gas: 192932)
32 changes: 32 additions & 0 deletions test/Items.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -943,4 +943,36 @@ contract ItemsTest is SetUp {
vm.expectRevert(Errors.CraftItemError.selector);
deployments.items.setCraftRequirements(itemsData.itemIdCraftable, requiredAssets2);
}

function testSimpleRequirementsClaimWithItem1() public {
uint256 claimableItemId = createSimpleClaimableItem();

vm.startPrank(accounts.gameMaster);
{
address[] memory players = new address[](1);
players[0] = accounts.character1;
uint256[][] memory itemIds = new uint256[][](1);
itemIds[0] = new uint256[](1);
itemIds[0][0] = claimableItemId - 1;
uint256[][] memory amounts = new uint256[][](1);
amounts[0] = new uint256[](1);
amounts[0][0] = 100;

deployments.items.dropLoot(players, itemIds, amounts);
}
vm.stopPrank();

assertEq(deployments.items.balanceOf(accounts.character1, claimableItemId - 1), 100, "item not dropped");
assertEq(deployments.items.balanceOf(accounts.character1, claimableItemId), 0, "item already claimed");

vm.startPrank(accounts.character1);
{
bytes32[] memory proof = new bytes32[](0);

deployments.items.obtainItems(claimableItemId, 1, proof);
}

vm.stopPrank();
assertEq(deployments.items.balanceOf(accounts.character1, claimableItemId), 1, "item not claimed");
}
}
24 changes: 24 additions & 0 deletions test/setup/SetUp.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,30 @@ contract SetUp is Test, Accounts, TestStructs {
);
}

function createSimpleClaimableItem() public returns (uint256) {
vm.startPrank(accounts.gameMaster);

uint256 _itemId1 =
deployments.items.createItemType(createNewItem(false, false, bytes32(0), 1, createEmptyRequiredAssets()));

RequirementNode memory item = RequirementNode({
operator: 0,
asset: Asset(Category.ERC1155, address(deployments.items), _itemId1, 100),
children: new RequirementNode[](0)
});

bytes memory requiredAssets = RequirementsTree.encode(item);

console2.logBytes(requiredAssets);

uint256 claimableItemId =
deployments.items.createItemType(createNewItem(false, false, bytes32(0), 1, requiredAssets));

vm.stopPrank();

return claimableItemId;
}

function createComplexClaimableItem() public returns (uint256) {
vm.startPrank(accounts.gameMaster);

Expand Down

0 comments on commit 5e95f17

Please sign in to comment.