Skip to content

Commit

Permalink
fix(create-dispute): add missing -1
Browse files Browse the repository at this point in the history
  • Loading branch information
0xferit committed Oct 17, 2018
1 parent 4c7d368 commit c337a7d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
4 changes: 2 additions & 2 deletions contracts/standard/proxy/ArbitratorVersioningProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ contract ArbitratorVersioningProxy is Arbitrator, Arbitrable, VersioningProxy {

DisputeStruct[] public disputes;

mapping(uint => uint) externalDisputeIDToLocalDisputeID;
mapping(uint => uint) public externalDisputeIDToLocalDisputeID;

/* Constructor */

Expand All @@ -50,7 +50,7 @@ contract ArbitratorVersioningProxy is Arbitrator, Arbitrable, VersioningProxy {
arbitrator: Arbitrator(implementation),
choices: _choices
})
);
) -1;

externalDisputeIDToLocalDisputeID[externalDisputeID] = _localDisputeID;
}
Expand Down
26 changes: 19 additions & 7 deletions test/arbitrator-versioning-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ contract('ArbitrableVersioningProxy', function(accounts) {
assert.equal(currentImplementation, previousImplementation)
})

it('should create a dispute', async function() {
it('should create a dispute and map ids correctly', async function() {
const CHOICES = 217 // Arbitrary

await proxy.createDispute(CHOICES, 'EXTRA_DATA', { value: 10000000 })
Expand All @@ -133,7 +133,19 @@ contract('ArbitrableVersioningProxy', function(accounts) {

const arbitrator = AppealableArbitrator.at(IMPLEMENTATION_ADDRESS)

assert.equal((await arbitrator.disputes(0))[1].toNumber(), CHOICES)
const EXTERNAL_DISPUTE_ID = 0
const LOCAL_DISPUTE_ID = 0

assert.equal(
(await arbitrator.disputes(LOCAL_DISPUTE_ID))[1].toNumber(),
CHOICES
)
assert.equal(
(await proxy.externalDisputeIDToLocalDisputeID(
EXTERNAL_DISPUTE_ID
)).toNumber(),
LOCAL_DISPUTE_ID
)
})

it('should retrieve appeal cost', async function() {
Expand All @@ -156,15 +168,15 @@ contract('ArbitrableVersioningProxy', function(accounts) {
})

it('appeal should transfer the dispute when called the first time', async function() {
const CHOICES = Math.ceil(Math.random() * 100);
const CHOICES = Math.ceil(Math.random() * 100)

await proxy.createDispute(CHOICES, "EXTRA_DATA", { value: 1000000 })
await proxy.createDispute(CHOICES, 'EXTRA_DATA', { value: 1000000 })

let implementationAddress = await proxy.implementation()
let arbitrator = AppealableArbitrator.at(implementationAddress)

const DISPUTE_ID = 0 // First dispute has the ID 0
const RULING = Math.floor(Math.random() * CHOICES);
const RULING = Math.floor(Math.random() * CHOICES)

await arbitrator.giveRuling(DISPUTE_ID, RULING)

Expand All @@ -175,9 +187,9 @@ contract('ArbitrableVersioningProxy', function(accounts) {
0,
{ from: accounts[8] }
)
await proxy.publish("NEXT_TAG", newVersion.address, { from: GOVERNOR })
await proxy.publish('NEXT_TAG', newVersion.address, { from: GOVERNOR })

await proxy.appeal(DISPUTE_ID, "EXTRA_DATA", {
await proxy.appeal(DISPUTE_ID, 'EXTRA_DATA', {
gas: 1000000,
value: 100000000
})
Expand Down

0 comments on commit c337a7d

Please sign in to comment.