Skip to content

Commit

Permalink
fix: make mult arbitrable evidence standard compliant
Browse files Browse the repository at this point in the history
  • Loading branch information
satello committed Sep 7, 2018
1 parent 2e9b964 commit 3a7cffa
Show file tree
Hide file tree
Showing 3 changed files with 495 additions and 45 deletions.
10 changes: 5 additions & 5 deletions contracts/standard/arbitration/MultipleArbitrableTransaction.sol
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ contract MultipleArbitrableTransaction {
event Ruling(uint indexed _transactionId, Arbitrator indexed _arbitrator, uint indexed _disputeID, uint _ruling);

/** @dev To be emmited when meta-evidence is submitted.
* @param _transactionId The index of the transaction.
* @param _metaEvidenceID Unique identifier of meta-evidence. Should be the transactionId.
* @param _evidence A link to the meta-evidence JSON.
*/
event MetaEvidence(uint indexed _transactionId, string _evidence);
event MetaEvidence(uint indexed _metaEvidenceID, string _evidence);

/** @dev To be emmited when a dispute is created to link the correct meta-evidence to the disputeID.
* @param _arbitrator The arbitrator of the contract.
* @param _disputeID ID of the dispute in the Arbitrator contract.
* @param _transactionId The index of the transaction.
* @param _metaEvidenceID Unique identifier of meta-evidence. Should be the transactionId.
*/
event Dispute(Arbitrator indexed _arbitrator, uint indexed _disputeID, uint _transactionId);
event Dispute(Arbitrator indexed _arbitrator, uint indexed _disputeID, uint _metaEvidenceID);

/** @dev To be raised when evidence are submitted. Should point to the ressource (evidences are not to be stored on chain due to gas considerations).
* @param _arbitrator The arbitrator of the contract.
Expand Down Expand Up @@ -342,7 +342,7 @@ contract MultipleArbitrableTransaction {
for (uint i = 0; i < transactions.length; i++)
if (transactions[i].seller == _address || transactions[i].buyer == _address)
transactionIDsBigArr[count++] = i;

transactionIDs = new uint[](count);
for (uint j = 0; j < count; j++) transactionIDs[j] = transactionIDsBigArr[j];
}
Expand Down
50 changes: 25 additions & 25 deletions test/multipleArbitrableTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ contract("MultipleArbitrableTransaction", function(accounts) {
}
);

let arbitrableTransactionId = lastTransaction.args._transactionId.toNumber();
let arbitrableTransactionId = lastTransaction.args._metaEvidenceID.toNumber();
let payerBalanceBeforeReimbursment = web3.eth.getBalance(payer);
await multipleContract.reimburse(arbitrableTransactionId, 1000, {
from: payee
Expand Down Expand Up @@ -93,7 +93,7 @@ contract("MultipleArbitrableTransaction", function(accounts) {
}
);

let arbitrableTransactionId = lastTransaction.args._transactionId.toNumber();
let arbitrableTransactionId = lastTransaction.args._metaEvidenceID.toNumber();

let payerBalanceBeforeReimbursment = web3.eth.getBalance(payer);
await multipleContract.reimburse(arbitrableTransactionId, 1000, {
Expand Down Expand Up @@ -137,7 +137,7 @@ contract("MultipleArbitrableTransaction", function(accounts) {
}
);

let arbitrableTransactionId = lastTransaction.args._transactionId.toNumber();
let arbitrableTransactionId = lastTransaction.args._metaEvidenceID.toNumber();

assert.equal(
web3.eth.getBalance(multipleContract.address),
Expand Down Expand Up @@ -175,7 +175,7 @@ contract("MultipleArbitrableTransaction", function(accounts) {
}
);

let arbitrableTransactionId = lastTransaction.args._transactionId.toNumber();
let arbitrableTransactionId = lastTransaction.args._metaEvidenceID.toNumber();

increaseTime(timeout + 1);
let tx = await multipleContract.withdraw(arbitrableTransactionId, {
Expand Down Expand Up @@ -207,7 +207,7 @@ contract("MultipleArbitrableTransaction", function(accounts) {
);
}
);
let arbitrableTransactionId = lastTransaction.args._transactionId.toNumber();
let arbitrableTransactionId = lastTransaction.args._metaEvidenceID.toNumber();
await expectThrow(
multipleContract.withdraw(arbitrableTransactionId, { from: payer })
);
Expand All @@ -231,7 +231,7 @@ contract("MultipleArbitrableTransaction", function(accounts) {
);
}
);
let arbitrableTransactionId = lastTransaction.args._transactionId.toNumber();
let arbitrableTransactionId = lastTransaction.args._metaEvidenceID.toNumber();

let payerBalanceBeforeReimbursment = web3.eth.getBalance(payer);
await multipleContract.reimburse(arbitrableTransactionId, 507, {
Expand Down Expand Up @@ -274,7 +274,7 @@ contract("MultipleArbitrableTransaction", function(accounts) {
);
}
);
let arbitrableTransactionId = lastTransaction.args._transactionId.toNumber();
let arbitrableTransactionId = lastTransaction.args._metaEvidenceID.toNumber();

let payerBalanceBeforeReimbursment = web3.eth.getBalance(payer);
await multipleContract.reimburse(arbitrableTransactionId, 1000, {
Expand Down Expand Up @@ -317,7 +317,7 @@ contract("MultipleArbitrableTransaction", function(accounts) {
);
}
);
let arbitrableTransactionId = lastTransaction.args._transactionId.toNumber();
let arbitrableTransactionId = lastTransaction.args._metaEvidenceID.toNumber();

await expectThrow(
multipleContract.reimburse(arbitrableTransactionId, 1003, { from: payee })
Expand All @@ -342,7 +342,7 @@ contract("MultipleArbitrableTransaction", function(accounts) {
);
}
);
let arbitrableTransactionId = lastTransaction.args._transactionId.toNumber();
let arbitrableTransactionId = lastTransaction.args._metaEvidenceID.toNumber();

await expectThrow(
multipleContract.reimburse(arbitrableTransactionId, 1000, { from: payer })
Expand Down Expand Up @@ -373,7 +373,7 @@ contract("MultipleArbitrableTransaction", function(accounts) {
);
}
);
let arbitrableTransactionId = lastTransaction.args._transactionId.toNumber();
let arbitrableTransactionId = lastTransaction.args._metaEvidenceID.toNumber();

await multipleContract.payArbitrationFeeBySeller(arbitrableTransactionId, {
from: payee,
Expand Down Expand Up @@ -415,7 +415,7 @@ contract("MultipleArbitrableTransaction", function(accounts) {
);
}
);
let arbitrableTransactionId = lastTransaction.args._transactionId.toNumber();
let arbitrableTransactionId = lastTransaction.args._metaEvidenceID.toNumber();

await multipleContract.payArbitrationFeeByBuyer(arbitrableTransactionId, {
from: payer,
Expand Down Expand Up @@ -457,7 +457,7 @@ contract("MultipleArbitrableTransaction", function(accounts) {
);
}
);
let arbitrableTransactionId = lastTransaction.args._transactionId.toNumber();
let arbitrableTransactionId = lastTransaction.args._metaEvidenceID.toNumber();

await multipleContract.payArbitrationFeeByBuyer(arbitrableTransactionId, {
from: payer,
Expand Down Expand Up @@ -507,7 +507,7 @@ contract("MultipleArbitrableTransaction", function(accounts) {
);
}
);
let arbitrableTransactionId = lastTransaction.args._transactionId.toNumber();
let arbitrableTransactionId = lastTransaction.args._metaEvidenceID.toNumber();

await multipleContract.payArbitrationFeeByBuyer(arbitrableTransactionId, {
from: payer,
Expand Down Expand Up @@ -554,7 +554,7 @@ contract("MultipleArbitrableTransaction", function(accounts) {
);
}
);
let arbitrableTransactionId = lastTransaction.args._transactionId.toNumber();
let arbitrableTransactionId = lastTransaction.args._metaEvidenceID.toNumber();

await expectThrow(
multipleContract.timeOutByBuyer(arbitrableTransactionId, {
Expand Down Expand Up @@ -598,7 +598,7 @@ contract("MultipleArbitrableTransaction", function(accounts) {
);
}
);
let arbitrableTransactionId = lastTransaction.args._transactionId.toNumber();
let arbitrableTransactionId = lastTransaction.args._metaEvidenceID.toNumber();

await multipleContract.payArbitrationFeeBySeller(arbitrableTransactionId, {
from: payee,
Expand Down Expand Up @@ -645,7 +645,7 @@ contract("MultipleArbitrableTransaction", function(accounts) {
);
}
);
let arbitrableTransactionId = lastTransaction.args._transactionId.toNumber();
let arbitrableTransactionId = lastTransaction.args._metaEvidenceID.toNumber();

await expectThrow(
multipleContract.timeOutBySeller(arbitrableTransactionId, {
Expand Down Expand Up @@ -690,7 +690,7 @@ contract("MultipleArbitrableTransaction", function(accounts) {
);
}
);
let arbitrableTransactionId = lastTransaction.args._transactionId.toNumber();
let arbitrableTransactionId = lastTransaction.args._metaEvidenceID.toNumber();

await multipleContract.payArbitrationFeeByBuyer(arbitrableTransactionId, {
from: payer,
Expand Down Expand Up @@ -734,7 +734,7 @@ contract("MultipleArbitrableTransaction", function(accounts) {
);
}
);
let arbitrableTransactionId = lastTransaction.args._transactionId.toNumber();
let arbitrableTransactionId = lastTransaction.args._metaEvidenceID.toNumber();

await multipleContract.payArbitrationFeeByBuyer(arbitrableTransactionId, {
from: payer,
Expand Down Expand Up @@ -778,7 +778,7 @@ contract("MultipleArbitrableTransaction", function(accounts) {
);
}
);
let arbitrableTransactionId = lastTransaction.args._transactionId.toNumber();
let arbitrableTransactionId = lastTransaction.args._metaEvidenceID.toNumber();

await multipleContract.payArbitrationFeeByBuyer(arbitrableTransactionId, {
from: payer,
Expand Down Expand Up @@ -810,7 +810,7 @@ contract("MultipleArbitrableTransaction", function(accounts) {
let currentResolve;
let lastTransactionEvent = -1;
const handler = metaEvidenceEvent.watch((error, result) => {
const eventTransaction = result.args._transactionId.toNumber();
const eventTransaction = result.args._metaEvidenceID.toNumber();
if (eventTransaction > lastTransactionEvent) {
lastTransactionEvent = eventTransaction;
currentResolve(result);
Expand All @@ -832,7 +832,7 @@ contract("MultipleArbitrableTransaction", function(accounts) {

const lastTransaction = await transaction1Promise;

let arbitrableTransactionId1 = lastTransaction.args._transactionId.toNumber();
let arbitrableTransactionId1 = lastTransaction.args._metaEvidenceID.toNumber();

const transaction2Promise = new Promise(resolve => {
currentResolve = resolve;
Expand All @@ -849,7 +849,7 @@ contract("MultipleArbitrableTransaction", function(accounts) {

const lastTransaction2 = await transaction2Promise;

let arbitrableTransactionId2 = lastTransaction2.args._transactionId.toNumber();
let arbitrableTransactionId2 = lastTransaction2.args._metaEvidenceID.toNumber();

metaEvidenceEvent.stopWatching();

Expand Down Expand Up @@ -912,7 +912,7 @@ contract("MultipleArbitrableTransaction", function(accounts) {
let currentResolve;
let lastTransactionEvent = -1;
const handler = metaEvidenceEvent.watch((error, result) => {
const eventTransaction = result.args._transactionId.toNumber();
const eventTransaction = result.args._metaEvidenceID.toNumber();
if (eventTransaction > lastTransactionEvent) {
lastTransactionEvent = eventTransaction;
currentResolve(result);
Expand All @@ -934,7 +934,7 @@ contract("MultipleArbitrableTransaction", function(accounts) {

const lastTransaction = await transaction1Promise;

let arbitrableTransactionId1 = lastTransaction.args._transactionId.toNumber();
let arbitrableTransactionId1 = lastTransaction.args._metaEvidenceID.toNumber();

const transaction2Promise = new Promise(resolve => {
currentResolve = resolve;
Expand All @@ -951,7 +951,7 @@ contract("MultipleArbitrableTransaction", function(accounts) {

const lastTransaction2 = await transaction2Promise;

let arbitrableTransactionId2 = lastTransaction2.args._transactionId.toNumber();
let arbitrableTransactionId2 = lastTransaction2.args._metaEvidenceID.toNumber();

metaEvidenceEvent.stopWatching();

Expand Down
Loading

0 comments on commit 3a7cffa

Please sign in to comment.