-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: registerTask(s) return value * test: init registerTasks, creatContributions * refactor: contribution{'' => 'Id'}sInPeriod * test: taskFactory.createContributions pass test draft * test: draft TaskManager create, commit, give contributions * chore: compile * test: pass
- Loading branch information
1 parent
8ddfc75
commit 85414df
Showing
14 changed files
with
420 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
//SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
import "test/BaseTest.sol"; | ||
|
||
contract TaskFactoryCreateContributionsTest is BaseTest { | ||
|
||
// Generic contribution values | ||
bytes32 taskId; | ||
bytes32 descriptionId; | ||
uint256 role = 1; | ||
uint32 startDate; | ||
uint32 endDate; | ||
uint32 points = 6; | ||
uint128 quantity = 10; | ||
Contribution contribution; | ||
|
||
function setUp() public override { | ||
super.setUp(); | ||
|
||
// register alice as an admin | ||
vm.prank(hub.owner()); | ||
hub.addAdmin(alice); | ||
|
||
// init Contribution for testing | ||
taskId = taskRegistry.registerTask(Task({uri: "abcde"})); | ||
descriptionId = taskFactory.registerDescription(Description({uri: "fghij"})); | ||
|
||
startDate = uint32(block.timestamp); | ||
endDate = startDate + 7 days; | ||
contribution = Contribution({ | ||
taskId: taskId, | ||
descriptionId: descriptionId, | ||
role: role, | ||
startDate: startDate, | ||
endDate: endDate, | ||
points: points, | ||
quantity: quantity | ||
}); | ||
} | ||
|
||
function test_CreateContribution_succeeds() public { | ||
// pre-action asserts | ||
bytes32[] memory contributionIds = taskFactory.contributionIds(); | ||
assertEq(contributionIds.length, 0); | ||
|
||
uint32 currentPeriodId = taskFactory.currentPeriodId(); | ||
bytes32[] memory contributionIdsInPeriod = taskFactory.contributionIdsInPeriod(currentPeriodId); | ||
assertEq(contributionIdsInPeriod.length, 0); | ||
|
||
// action | ||
vm.prank(alice); | ||
bytes32 contributionId = taskFactory.createContribution(contribution); | ||
|
||
// post-action asserts | ||
assertTrue(contributionId != bytes32(0x0)); | ||
assertTrue(taskFactory.isContributionId(contributionId)); | ||
|
||
Contribution memory queriedContribution = taskFactory.getContributionById(contributionId); | ||
assertEq(queriedContribution.taskId, taskId); | ||
assertEq(queriedContribution.descriptionId, descriptionId); | ||
assertEq(queriedContribution.role, role); | ||
assertEq(queriedContribution.startDate, startDate); | ||
assertEq(queriedContribution.endDate, endDate); | ||
assertEq(queriedContribution.points, points); | ||
assertEq(queriedContribution.quantity, quantity); | ||
|
||
contributionIds = taskFactory.contributionIds(); | ||
assertEq(contributionIds.length, 1); | ||
assertEq(contributionIds[0], contributionId); | ||
|
||
contributionIdsInPeriod = taskFactory.contributionIdsInPeriod(currentPeriodId); | ||
assertEq(contributionIdsInPeriod.length, 1); | ||
assertEq(contributionIdsInPeriod[0], contributionId); | ||
} | ||
|
||
// TODO: revert cases | ||
} |
Oops, something went wrong.