Skip to content

Commit ff0a4d8

Browse files
committed
Added Escrow.Accept test && ownership check in JobValidator
1 parent cab4ff6 commit ff0a4d8

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

contracts/market/JobValidator.sol

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,19 @@ contract JobValidator is JobStandard {
4141

4242
/**
4343
* @dev Confirm job result
44+
* Is optional, even if not called by the payer at the expiration time
45+
* funds will be available for to payee
4446
*/
4547
function accept() public {
46-
validator = msg.sender;
48+
require(msg.sender == payer);
4749
Accepted();
4850
}
4951

5052
/**
5153
* @dev Reject job result
5254
*/
5355
function reject() public {
54-
require(msg.sender==validator);
56+
require(msg.sender == payer);
5557
isRejected = true;
5658
Rejected();
5759
}

test/TestEscrow.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,21 @@ contract('Escrow', function ([payee, payer, validator]) {
6868
await assertFail(async () => await this.escrow.withdraw({ from: payee }), 'should have thrown before')
6969
})
7070

71+
72+
it('WITHDRAWAL - allowed if payer accept before timelock', async () => {
73+
const jobDescriptor = "0x01"
74+
const jobResult = "0x202"
75+
await this.token.approve(this.escrow.address, amount, { from: payer })
76+
await this.escrow.deposit(amount, jobDescriptor, { from: payer })
77+
await this.escrow.setResult(jobResult, { from: payee })
78+
const result = await this.escrow.accept({from: payer})
79+
80+
const found = result.logs.find(e => e.event === 'Accepted')
81+
assert.strictEqual(found.event, 'Accepted', 'Accepted event not fired')
82+
})
83+
84+
85+
7186
it('WITHDRAWAL - allowed after timelock', async () => {
7287
const jobDescriptor = "0x01"
7388
const jobResult = "0x202"

0 commit comments

Comments
 (0)