Skip to content

Commit d42741b

Browse files
committed
feat: added TaskAssigned event to Linguo
1 parent 68cb9bc commit d42741b

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

contracts/standard/arbitration/Linguo.sol

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@ contract Linguo is Arbitrable {
8080
*/
8181
event TaskCreated(uint indexed _taskID, address indexed _requester, uint _timestamp);
8282

83+
/** @dev To be emitted when a translator assigns the task to himself.
84+
* @param _taskID The ID of the newly created task.
85+
* @param _translator The address that assigned to the task.
86+
* @param _price The task price at the moment it was assigned.
87+
* @param _timestamp When the task was assigned.
88+
*/
89+
event TaskAssigned(uint indexed _taskID, address indexed _translator, uint _price, uint _timestamp);
90+
8391
/** @dev To be emitted when a translation is submitted.
8492
* @param _taskID The ID of the respective task.
8593
* @param _translator The address that performed the translation.
@@ -250,6 +258,8 @@ contract Linguo is Arbitrable {
250258

251259
remainder = msg.value - deposit;
252260
msg.sender.send(remainder);
261+
262+
emit TaskAssigned(_taskID, msg.sender, price, now);
253263
}
254264

255265
/** @dev Submits translated text for a specific task.

test/linguo.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,20 @@ contract('Linguo', function(accounts) {
223223
)
224224
})
225225

226+
it('Should emit TaskAssigned event after assigning to the task', async () => {
227+
const requiredDeposit = (await linguo.getDepositValue(0)).toNumber()
228+
const assignTx = await linguo.assignTask(0, {
229+
from: translator,
230+
value: requiredDeposit + 1e17
231+
})
232+
233+
assert.equal(
234+
assignTx.logs[0].event,
235+
'TaskAssigned',
236+
'The TaskAssigned event was not emitted'
237+
)
238+
})
239+
226240
it('Should reimburse requester leftover price after assigning the task and set correct values', async () => {
227241
const oldBalance = await web3.eth.getBalance(requester)
228242

0 commit comments

Comments
 (0)