Skip to content

Commit

Permalink
prep delete for "pyro" test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
plotchy committed Jul 22, 2024
1 parent 801de39 commit 84c861b
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions crates/pyrometer/tests/test_data/delete.sol
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,71 @@ contract ComplexDelete {
function clearAllEducationHistory(uint256 userId) public {
delete users[userId].educationHistory;
}

}

contract UseComplexDelete {
ComplexDelete t;

constructor() {
t = new ComplexDelete();
}

function useIt() public {
// Add users
t.addUser(1, "Alice", "[email protected]", "1234567890");
t.addUser(2, "Bob", "[email protected]", "0987654321");

// Add addresses
t.addUserAddress(1, "123 Main St", "New York", "USA", 10001);
t.addUserAddress(1, "456 Elm St", "Los Angeles", "USA", 90001);
t.addUserAddress(2, "789 Oak St", "Chicago", "USA", 60601);

// Add employment history
t.addEmploymentHistory(1, "TechCorp", "Developer", 1609459200, 1640995200);
t.addEmploymentHistory(1, "WebSoft", "Senior Developer", 1641081600, 0);
t.addEmploymentHistory(2, "DataFirm", "Analyst", 1577836800, 0);

// Add education history
t.addEducationHistory(1, "Tech University", "BSc Computer Science", 2020);
t.addEducationHistory(2, "Data College", "MSc Data Science", 2019);

// Set preferences
t.setUserPreference(1, "receiveNewsletter", true);
t.setUserPreference(1, "darkMode", false);
t.setUserPreference(2, "receiveNewsletter", false);

// Test deletions and updates

// Delete an address
t.deleteUserAddress(1, 0);

// Delete employment history
t.deleteEmploymentHistory(1, 0);

// Delete education history
t.deleteEducationHistory(2, 0);

// Delete user preference
t.deleteUserPreference(1, "darkMode");

// Update contact info
t.updateContactInfo(2, "[email protected]", "1122334455");

// Clear all addresses for a user
t.clearAllUserAddresses(1);

// Clear all employment history for a user
t.clearAllEmploymentHistory(2);

// Clear all education history for a user
t.clearAllEducationHistory(1);

// Delete an entire user
t.deleteUser(1);

// Add a new user to test after deletions
t.addUser(3, "Charlie", "[email protected]", "5556667777");
t.addUserAddress(3, "321 Pine St", "San Francisco", "USA", 94101);
}
}

0 comments on commit 84c861b

Please sign in to comment.