Permalink
Browse files

Give the arbitrator contract the ability to collect its question fees

  • Loading branch information...
Edmund Edgar
Edmund Edgar committed Feb 24, 2018
1 parent 420fe61 commit 207278cecb4a99709dd7e6c1b601196ba11e676e
Showing with 55 additions and 3 deletions.
  1. +12 −0 truffle/contracts/Arbitrator.sol
  2. +43 −3 truffle/contracts/test.py
@@ -8,6 +8,7 @@ contract RealityCheckAPI {
function submitAnswerByArbitrator(bytes32 question_id, bytes32 answer, address answerer) public;
function notifyOfArbitrationRequest(bytes32 question_id, address requester) public;
function isFinalized(bytes32 question_id) public returns (bool);
function withdraw() public;
}

contract Arbitrator is Owned {
@@ -130,4 +131,15 @@ contract Arbitrator is Owned {
addr.transfer(this.balance);
}

function() payable {}

/// @notice Withdraw any accumulated question fees from the specified address into this contract
/// @param realitycheck The address of the Reality Check contract containing the fees
/// @dev Funds can then be liberated from this contract with our withdraw() function
function callWithdraw(address realitycheck)
onlyOwner
public {
RealityCheckAPI(realitycheck).withdraw();
}

}
@@ -872,6 +872,49 @@ def test_answer_question_gas(self):
#self.assertEqual(gas_used, 120000)
self.assertTrue(gas_used < 52000)

@unittest.skipIf(WORKING_ONLY, "Not under construction")
def test_question_fee_withdrawal(self):

start_bal = self.rc0.balanceOf(self.arb0.address)
self.arb0.setQuestionFee(self.rc0.address, 321)

question_id = self.rc0.askQuestion(
0,
"my question 3",
self.arb0.address,
10,
0,
value=1000,
sender=t.k4,
startgas=140000
)

question_id = self.rc0.askQuestion(
0,
"my question 4",
self.arb0.address,
10,
0,
value=2000,
sender=t.k5,
startgas=140000
)

end_bal = self.rc0.balanceOf(self.arb0.address)
self.assertEqual(end_bal - start_bal, (321*2))

start_arb_bal = self.s.get_balance(self.arb0.address)

self.c.mine()
self.s = self.c.head_state

self.arb0.callWithdraw(self.rc0.address, sender=t.k0)
end_arb_bal = self.s.get_balance(self.arb0.address)

self.assertEqual(end_arb_bal - start_arb_bal, 100 + (321*2))
self.assertEqual(self.rc0.balanceOf(self.arb0.address), 0)


@unittest.skipIf(WORKING_ONLY, "Not under construction")
def test_question_fees(self):

@@ -919,8 +962,5 @@ def test_question_fees(self):
self.assertEqual(bounty, 122, "The arbitrator isn't charged their fee, so their whole payment goes to the bounty")





if __name__ == '__main__':
main()

0 comments on commit 207278c

Please sign in to comment.