Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion contracts/standard/arbitration/Linguo.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* @auditors: []
* @bounties: []
* @deployments: []
* @tools: [MythX]
*/

/* solium-disable security/no-block-members */
Expand Down Expand Up @@ -315,8 +316,9 @@ contract Linguo is Arbitrable {

/** @dev Challenges the translation of a specific task. Requires challenger's deposit.
* @param _taskID The ID of the task.
* @param _evidence A link to evidence using its URI. Ignored if not provided.
*/
function challengeTranslation(uint _taskID) external payable {
function challengeTranslation(uint _taskID, string _evidence) external payable {
Task storage task = tasks[_taskID];

uint arbitrationCost = arbitrator.arbitrationCost(arbitratorExtraData);
Expand All @@ -339,6 +341,10 @@ contract Linguo is Arbitrable {

emit Dispute(arbitrator, task.disputeID, _taskID, _taskID);
emit TranslationChallenged(_taskID, msg.sender, now);

if (bytes(_evidence).length > 0)
emit Evidence(arbitrator, _taskID, msg.sender, _evidence);

}

/** @dev Takes up to the total amount required to fund a side of an appeal. Reimburses the rest. Creates an appeal if all sides are fully funded.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"openzeppelin-test-helpers": "^0.4.3",
"pify": "^4.0.1",
"standard-version": "^4.4.0",
"truffle": "^4.1.13"
"truffle": "4.1.16"
},
"dependencies": {
"@kleros/kleros": "^0.1.2",
Expand Down
66 changes: 50 additions & 16 deletions test/linguo.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ contract('Linguo', function(accounts) {
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
const challengerDeposit =
(await linguo.getChallengeValue(0)).toNumber() + 1000
await linguo.challengeTranslation(0, {
await linguo.challengeTranslation(0, '', {
from: challenger,
value: challengerDeposit
})
Expand All @@ -461,17 +461,51 @@ contract('Linguo', function(accounts) {
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
const challengerDeposit =
(await linguo.getChallengeValue(0)).toNumber() + 1000
const challengeTx = await linguo.challengeTranslation(0, {
from: challenger,
value: challengerDeposit
})
const challengeTx = await linguo.challengeTranslation(
0,
'ChallengeEvidence',
{
from: challenger,
value: challengerDeposit
}
)

assert.equal(
challengeTx.logs[1].event,
'TranslationChallenged',
'TranslationChallenged event was not emitted'
)

assert.equal(
challengeTx.logs[2].event,
'Evidence',
'Evidence event was not emitted'
)

assert.equal(
challengeTx.logs[2].args._arbitrator,
arbitrator.address,
'The Evidence event has wrong arbitrator'
)

assert.equal(
challengeTx.logs[2].args._evidenceGroupID.toNumber(),
0,
'The Evidence event has wrong evidenceGroupID'
)

assert.equal(
challengeTx.logs[2].args._party,
challenger,
'The Evidence event has wrong party address'
)

assert.equal(
challengeTx.logs[2].args._evidence,
'ChallengeEvidence',
'The Evidence event has wrong evidence string'
)

// get task info again because of updated values
task = await linguo.tasks(0)
const taskInfo = await linguo.getTaskParties(0)
Expand Down Expand Up @@ -519,7 +553,7 @@ contract('Linguo', function(accounts) {
const challengerDeposit =
arbitrationFee + (challengeMultiplier * price) / MULTIPLIER_DIVISOR + 1000
await expectThrow(
linguo.challengeTranslation(0, {
linguo.challengeTranslation(0, '', {
from: challenger,
value: challengerDeposit
})
Expand All @@ -540,7 +574,7 @@ contract('Linguo', function(accounts) {
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
const challengerDeposit =
(await linguo.getChallengeValue(0)).toNumber() + 1000
await linguo.challengeTranslation(0, {
await linguo.challengeTranslation(0, '', {
from: challenger,
value: challengerDeposit
})
Expand Down Expand Up @@ -597,7 +631,7 @@ contract('Linguo', function(accounts) {
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
const challengerDeposit =
(await linguo.getChallengeValue(0)).toNumber() + 1000
await linguo.challengeTranslation(0, {
await linguo.challengeTranslation(0, '', {
from: challenger,
value: challengerDeposit
})
Expand Down Expand Up @@ -654,7 +688,7 @@ contract('Linguo', function(accounts) {
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
const challengerDeposit =
(await linguo.getChallengeValue(0)).toNumber() + 1000
await linguo.challengeTranslation(0, {
await linguo.challengeTranslation(0, '', {
from: challenger,
value: challengerDeposit
})
Expand Down Expand Up @@ -707,7 +741,7 @@ contract('Linguo', function(accounts) {
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
const challengerDeposit =
(await linguo.getChallengeValue(0)).toNumber() + 1000
await linguo.challengeTranslation(0, {
await linguo.challengeTranslation(0, '', {
from: challenger,
value: challengerDeposit
})
Expand Down Expand Up @@ -824,7 +858,7 @@ contract('Linguo', function(accounts) {
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
const challengerDeposit =
(await linguo.getChallengeValue(0)).toNumber() + 1000
await linguo.challengeTranslation(0, {
await linguo.challengeTranslation(0, '', {
from: challenger,
value: challengerDeposit
})
Expand All @@ -850,7 +884,7 @@ contract('Linguo', function(accounts) {
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
const challengerDeposit =
(await linguo.getChallengeValue(0)).toNumber() + 1000
await linguo.challengeTranslation(0, {
await linguo.challengeTranslation(0, '', {
from: challenger,
value: challengerDeposit
})
Expand Down Expand Up @@ -878,7 +912,7 @@ contract('Linguo', function(accounts) {
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
const challengerDeposit =
(await linguo.getChallengeValue(0)).toNumber() + 1000
await linguo.challengeTranslation(0, {
await linguo.challengeTranslation(0, '', {
from: challenger,
value: challengerDeposit
})
Expand Down Expand Up @@ -943,7 +977,7 @@ contract('Linguo', function(accounts) {
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
const challengerDeposit =
(await linguo.getChallengeValue(0)).toNumber() + 1000
await linguo.challengeTranslation(0, {
await linguo.challengeTranslation(0, '', {
from: challenger,
value: challengerDeposit
})
Expand Down Expand Up @@ -1044,7 +1078,7 @@ contract('Linguo', function(accounts) {
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
const challengerDeposit =
(await linguo.getChallengeValue(0)).toNumber() + 1000
await linguo.challengeTranslation(0, {
await linguo.challengeTranslation(0, '', {
from: challenger,
value: challengerDeposit
})
Expand Down Expand Up @@ -1127,7 +1161,7 @@ contract('Linguo', function(accounts) {
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
const challengerDeposit =
(await linguo.getChallengeValue(0)).toNumber() + 1000
await linguo.challengeTranslation(0, {
await linguo.challengeTranslation(0, '', {
from: challenger,
value: challengerDeposit
})
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7027,10 +7027,10 @@ sol-explore@1.6.1:
resolved "https://registry.yarnpkg.com/sol-explore/-/sol-explore-1.6.1.tgz#b59f073c69fe332560d5a10c32ba8ca7f2986cfb"
integrity sha1-tZ8HPGn+MyVg1aEMMrqMp/KYbPs=

solc@0.4.24:
version "0.4.24"
resolved "https://registry.yarnpkg.com/solc/-/solc-0.4.24.tgz#354f14b269b38cbaa82a47d1ff151723502b954e"
integrity sha512-2xd7Cf1HeVwrIb6Bu1cwY2/TaLRodrppCq3l7rhLimFQgmxptXhTC3+/wesVLpB09F1A2kZgvbMOgH7wvhFnBQ==
solc@0.4.26:
version "0.4.26"
resolved "https://registry.yarnpkg.com/solc/-/solc-0.4.26.tgz#5390a62a99f40806b86258c737c1cf653cc35cb5"
integrity sha512-o+c6FpkiHd+HPjmjEVpQgH7fqZ14tJpXhho+/bQXlXbliLIS/xjXb42Vxh+qQY1WCSTMQ0+a5vR9vi0MfhU6mA==
dependencies:
fs-extra "^0.30.0"
memorystream "^0.3.1"
Expand Down Expand Up @@ -7741,14 +7741,14 @@ truffle-interface-adapter@^0.2.5:
lodash "^4.17.13"
web3 "1.2.1"

truffle@^4.1.13:
version "4.1.14"
resolved "https://registry.yarnpkg.com/truffle/-/truffle-4.1.14.tgz#8d2c298e29abf9b1e486e44ff9faca6d34bb9030"
integrity sha512-e7tTLvKP3bN9dE7MagfWyFjy4ZgoEGbeujECy1me1ENBzbj/aO/+45gs72qsL3+3IkCNNcWNOJjjrm8BYZZNNg==
truffle@4.1.16:
version "4.1.16"
resolved "https://registry.yarnpkg.com/truffle/-/truffle-4.1.16.tgz#5cc160dcbbbcff6078e80ce328873d83247b084e"
integrity sha512-Ew0YSyy2802wqqe1Ko4kxo1FMffM+l9uEUXJ+GScwAAXFXwKWRC++eEa9pIIQdHcEj0rJo0jXhp65vS/LOcNwA==
dependencies:
mocha "^4.1.0"
original-require "1.0.1"
solc "0.4.24"
solc "0.4.26"

tslib@^1.9.0:
version "1.9.3"
Expand Down