From 60e0fad79f1b11667ab16b98d9c6df99df142540 Mon Sep 17 00:00:00 2001 From: unknownunknown1 Date: Fri, 8 May 2020 02:01:50 +1000 Subject: [PATCH] feat(Linguo): add evidence to challenge --- contracts/standard/arbitration/Linguo.sol | 8 ++- package.json | 2 +- test/linguo.js | 66 +++++++++++++++++------ yarn.lock | 18 +++---- 4 files changed, 67 insertions(+), 27 deletions(-) diff --git a/contracts/standard/arbitration/Linguo.sol b/contracts/standard/arbitration/Linguo.sol index f066444e..ed2ee077 100644 --- a/contracts/standard/arbitration/Linguo.sol +++ b/contracts/standard/arbitration/Linguo.sol @@ -4,6 +4,7 @@ * @auditors: [] * @bounties: [] * @deployments: [] + * @tools: [MythX] */ /* solium-disable security/no-block-members */ @@ -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); @@ -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. diff --git a/package.json b/package.json index 04f72c49..f1f5f782 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/linguo.js b/test/linguo.js index a0b15f3d..adf6e86f 100644 --- a/test/linguo.js +++ b/test/linguo.js @@ -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 }) @@ -461,10 +461,14 @@ 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, @@ -472,6 +476,36 @@ contract('Linguo', function(accounts) { '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) @@ -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 }) @@ -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 }) @@ -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 }) @@ -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 }) @@ -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 }) @@ -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 }) @@ -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 }) @@ -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 }) @@ -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 }) @@ -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 }) @@ -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 }) diff --git a/yarn.lock b/yarn.lock index c036b7f0..f0ca3bbb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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"