Skip to content

Commit

Permalink
Payroll: Add reentracy guard to payment transfers
Browse files Browse the repository at this point in the history
  • Loading branch information
facuspagnuolo committed Apr 7, 2019
1 parent 77261c8 commit 740d2e4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion future-apps/payroll/contracts/Payroll.sol
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ contract Payroll is EtherTokenConstant, IForwarder, IsContract, AragonApp {
* @param _type Payment type to be performed
* @return True if there was at least one token transfer
*/
function _transferTokensAmount(uint256 _employeeId, PaymentType _type, uint256 _totalAmount) internal returns (bool somethingPaid) {
function _transferTokensAmount(uint256 _employeeId, PaymentType _type, uint256 _totalAmount) internal nonReentrant returns (bool somethingPaid) {
Employee storage employee = employees[_employeeId];
string memory paymentReference = _paymentReferenceFor(_type);
for (uint256 i = 0; i < allowedTokensArray.length; i++) {
Expand Down
4 changes: 2 additions & 2 deletions future-apps/payroll/test/contracts/Payroll_gas_costs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ contract('Payroll gas costs', ([owner, employee, anotherEmployee]) => {
})

context('when there are not allowed tokens yet', function () {
it('expends ~314k gas for a single allowed token', async () => {
it('expends ~325k gas for a single allowed token', async () => {
await payroll.addAllowedToken(denominationToken.address)
await payroll.determineAllocation([denominationToken.address], [100], { from: employee })

const { receipt: { cumulativeGasUsed } } = await payroll.payday(PAYROLL_PAYMENT_TYPE, 0, { from: employee })

assert.isBelow(cumulativeGasUsed, 317000, 'payout gas cost for a single allowed token should be ~314k')
assert.isBelow(cumulativeGasUsed, 325000, 'payout gas cost for a single allowed token should be ~325k')
})
})

Expand Down

0 comments on commit 740d2e4

Please sign in to comment.