Skip to content

Commit 903b752

Browse files
authored
Merge pull request #318 from unknownunknown1/master
feat(Linguo): add evidence to challenge
2 parents 7a4dd82 + 60e0fad commit 903b752

File tree

4 files changed

+67
-27
lines changed

4 files changed

+67
-27
lines changed

contracts/standard/arbitration/Linguo.sol

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @auditors: []
55
* @bounties: []
66
* @deployments: []
7+
* @tools: [MythX]
78
*/
89

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

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

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

340342
emit Dispute(arbitrator, task.disputeID, _taskID, _taskID);
341343
emit TranslationChallenged(_taskID, msg.sender, now);
344+
345+
if (bytes(_evidence).length > 0)
346+
emit Evidence(arbitrator, _taskID, msg.sender, _evidence);
347+
342348
}
343349

344350
/** @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.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"openzeppelin-test-helpers": "^0.4.3",
5151
"pify": "^4.0.1",
5252
"standard-version": "^4.4.0",
53-
"truffle": "^4.1.13"
53+
"truffle": "4.1.16"
5454
},
5555
"dependencies": {
5656
"@kleros/kleros": "^0.1.2",

test/linguo.js

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ contract('Linguo', function(accounts) {
439439
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
440440
const challengerDeposit =
441441
(await linguo.getChallengeValue(0)).toNumber() + 1000
442-
await linguo.challengeTranslation(0, {
442+
await linguo.challengeTranslation(0, '', {
443443
from: challenger,
444444
value: challengerDeposit
445445
})
@@ -461,17 +461,51 @@ contract('Linguo', function(accounts) {
461461
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
462462
const challengerDeposit =
463463
(await linguo.getChallengeValue(0)).toNumber() + 1000
464-
const challengeTx = await linguo.challengeTranslation(0, {
465-
from: challenger,
466-
value: challengerDeposit
467-
})
464+
const challengeTx = await linguo.challengeTranslation(
465+
0,
466+
'ChallengeEvidence',
467+
{
468+
from: challenger,
469+
value: challengerDeposit
470+
}
471+
)
468472

469473
assert.equal(
470474
challengeTx.logs[1].event,
471475
'TranslationChallenged',
472476
'TranslationChallenged event was not emitted'
473477
)
474478

479+
assert.equal(
480+
challengeTx.logs[2].event,
481+
'Evidence',
482+
'Evidence event was not emitted'
483+
)
484+
485+
assert.equal(
486+
challengeTx.logs[2].args._arbitrator,
487+
arbitrator.address,
488+
'The Evidence event has wrong arbitrator'
489+
)
490+
491+
assert.equal(
492+
challengeTx.logs[2].args._evidenceGroupID.toNumber(),
493+
0,
494+
'The Evidence event has wrong evidenceGroupID'
495+
)
496+
497+
assert.equal(
498+
challengeTx.logs[2].args._party,
499+
challenger,
500+
'The Evidence event has wrong party address'
501+
)
502+
503+
assert.equal(
504+
challengeTx.logs[2].args._evidence,
505+
'ChallengeEvidence',
506+
'The Evidence event has wrong evidence string'
507+
)
508+
475509
// get task info again because of updated values
476510
task = await linguo.tasks(0)
477511
const taskInfo = await linguo.getTaskParties(0)
@@ -519,7 +553,7 @@ contract('Linguo', function(accounts) {
519553
const challengerDeposit =
520554
arbitrationFee + (challengeMultiplier * price) / MULTIPLIER_DIVISOR + 1000
521555
await expectThrow(
522-
linguo.challengeTranslation(0, {
556+
linguo.challengeTranslation(0, '', {
523557
from: challenger,
524558
value: challengerDeposit
525559
})
@@ -540,7 +574,7 @@ contract('Linguo', function(accounts) {
540574
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
541575
const challengerDeposit =
542576
(await linguo.getChallengeValue(0)).toNumber() + 1000
543-
await linguo.challengeTranslation(0, {
577+
await linguo.challengeTranslation(0, '', {
544578
from: challenger,
545579
value: challengerDeposit
546580
})
@@ -597,7 +631,7 @@ contract('Linguo', function(accounts) {
597631
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
598632
const challengerDeposit =
599633
(await linguo.getChallengeValue(0)).toNumber() + 1000
600-
await linguo.challengeTranslation(0, {
634+
await linguo.challengeTranslation(0, '', {
601635
from: challenger,
602636
value: challengerDeposit
603637
})
@@ -654,7 +688,7 @@ contract('Linguo', function(accounts) {
654688
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
655689
const challengerDeposit =
656690
(await linguo.getChallengeValue(0)).toNumber() + 1000
657-
await linguo.challengeTranslation(0, {
691+
await linguo.challengeTranslation(0, '', {
658692
from: challenger,
659693
value: challengerDeposit
660694
})
@@ -707,7 +741,7 @@ contract('Linguo', function(accounts) {
707741
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
708742
const challengerDeposit =
709743
(await linguo.getChallengeValue(0)).toNumber() + 1000
710-
await linguo.challengeTranslation(0, {
744+
await linguo.challengeTranslation(0, '', {
711745
from: challenger,
712746
value: challengerDeposit
713747
})
@@ -824,7 +858,7 @@ contract('Linguo', function(accounts) {
824858
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
825859
const challengerDeposit =
826860
(await linguo.getChallengeValue(0)).toNumber() + 1000
827-
await linguo.challengeTranslation(0, {
861+
await linguo.challengeTranslation(0, '', {
828862
from: challenger,
829863
value: challengerDeposit
830864
})
@@ -850,7 +884,7 @@ contract('Linguo', function(accounts) {
850884
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
851885
const challengerDeposit =
852886
(await linguo.getChallengeValue(0)).toNumber() + 1000
853-
await linguo.challengeTranslation(0, {
887+
await linguo.challengeTranslation(0, '', {
854888
from: challenger,
855889
value: challengerDeposit
856890
})
@@ -878,7 +912,7 @@ contract('Linguo', function(accounts) {
878912
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
879913
const challengerDeposit =
880914
(await linguo.getChallengeValue(0)).toNumber() + 1000
881-
await linguo.challengeTranslation(0, {
915+
await linguo.challengeTranslation(0, '', {
882916
from: challenger,
883917
value: challengerDeposit
884918
})
@@ -943,7 +977,7 @@ contract('Linguo', function(accounts) {
943977
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
944978
const challengerDeposit =
945979
(await linguo.getChallengeValue(0)).toNumber() + 1000
946-
await linguo.challengeTranslation(0, {
980+
await linguo.challengeTranslation(0, '', {
947981
from: challenger,
948982
value: challengerDeposit
949983
})
@@ -1044,7 +1078,7 @@ contract('Linguo', function(accounts) {
10441078
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
10451079
const challengerDeposit =
10461080
(await linguo.getChallengeValue(0)).toNumber() + 1000
1047-
await linguo.challengeTranslation(0, {
1081+
await linguo.challengeTranslation(0, '', {
10481082
from: challenger,
10491083
value: challengerDeposit
10501084
})
@@ -1127,7 +1161,7 @@ contract('Linguo', function(accounts) {
11271161
// add a small amount because javascript can have small deviations up to several hundreds when operating with large numbers
11281162
const challengerDeposit =
11291163
(await linguo.getChallengeValue(0)).toNumber() + 1000
1130-
await linguo.challengeTranslation(0, {
1164+
await linguo.challengeTranslation(0, '', {
11311165
from: challenger,
11321166
value: challengerDeposit
11331167
})

yarn.lock

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7027,10 +7027,10 @@ sol-explore@1.6.1:
70277027
resolved "https://registry.yarnpkg.com/sol-explore/-/sol-explore-1.6.1.tgz#b59f073c69fe332560d5a10c32ba8ca7f2986cfb"
70287028
integrity sha1-tZ8HPGn+MyVg1aEMMrqMp/KYbPs=
70297029

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

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

77537753
tslib@^1.9.0:
77547754
version "1.9.3"

0 commit comments

Comments
 (0)