Skip to content

Commit c39aec5

Browse files
nuevoalexnuevoalex
authored andcommitted
log additions to the whitelist
1 parent ba3fdec commit c39aec5

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

source/contracts/Augur.sol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ contract Augur is Controlled, Extractable {
3434
event TokensMinted(address indexed universe, address indexed token, address indexed target, uint256 amount);
3535
event TokensBurned(address indexed universe, address indexed token, address indexed target, uint256 amount);
3636
event FeeWindowCreated(address indexed universe, address feeWindow, uint256 startTime, uint256 endTime, uint256 id);
37+
event WhitelistAddition(address addition);
3738

3839
mapping(address => bool) private universes;
3940

@@ -279,6 +280,11 @@ contract Augur is Controlled, Extractable {
279280
return true;
280281
}
281282

283+
function logContractAddedToWhitelist(address _addition) public onlyControllerCaller returns (bool) {
284+
WhitelistAddition(_addition);
285+
return true;
286+
}
287+
282288
function getProtectedTokens() internal returns (address[] memory) {
283289
return new address[](0);
284290
}

source/contracts/Controller.sol

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ contract Controller is IController {
6666

6767
function addToWhitelist(address _target) public onlyWhitelistedCallers returns (bool) {
6868
whitelist[_target] = true;
69+
getAugur().logContractAddedToWhitelist(_target);
6970
return true;
7071
}
7172

source/libraries/ContractDeployer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export class ContractDeployer {
3131
public async deploy(): Promise<void> {
3232
this.controller = await this.uploadController();
3333
await this.uploadAllContracts();
34+
await this.initializeAllContracts();
3435
await this.whitelistTradingContracts();
35-
await this.initializeAllContracts();
3636

3737
if(this.configuration.createGenesisUniverse) {
3838
this.universe = await this.createGenesisUniverse();

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,8 @@ def controllerSnapshot(fixture, baseSnapshot):
427427
def augurInitializedSnapshot(fixture, controllerSnapshot):
428428
fixture.resetToSnapshot(controllerSnapshot)
429429
fixture.uploadAllContracts()
430-
fixture.whitelistTradingContracts()
431430
fixture.initializeAllContracts()
431+
fixture.whitelistTradingContracts()
432432
fixture.approveCentralAuthority()
433433
return fixture.createSnapshot()
434434

tests/test_controller.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,18 @@
33
from ethereum.tools import tester
44
from ethereum.tools.tester import TransactionFailed
55
from pytest import raises, fixture
6-
from utils import longToHexString, bytesToHexString, stringToBytes, longTo32Bytes, garbageAddress, garbageBytes20, garbageBytes32, twentyZeros, thirtyTwoZeros
6+
from utils import AssertLog, longToHexString, bytesToHexString, stringToBytes, longTo32Bytes, garbageAddress, garbageBytes20, garbageBytes32, twentyZeros, thirtyTwoZeros
77
from struct import pack
88

9-
def test_whitelists(controller):
9+
def test_whitelists(localFixture, controller):
1010
assert controller.assertIsWhitelisted(tester.a0, sender = tester.k2)
1111
with raises(TransactionFailed): controller.addToWhitelist(tester.a1, sender = tester.k1)
1212
with raises(TransactionFailed): controller.addToWhitelist(tester.a1, sender = tester.k2)
13-
assert controller.addToWhitelist(tester.a1, sender = tester.k0)
13+
14+
whitelistAdditionLog = {"addition": bytesToHexString(tester.a1)}
15+
with AssertLog(localFixture, "WhitelistAddition", whitelistAdditionLog):
16+
assert controller.addToWhitelist(tester.a1, sender = tester.k0)
17+
1418
assert controller.assertIsWhitelisted(tester.a1, sender = tester.k2)
1519
with raises(TransactionFailed): controller.assertIsWhitelisted(tester.a2, sender = tester.k2)
1620
with raises(TransactionFailed): controller.removeFromWhitelist(tester.a1, sender = tester.k2)
@@ -89,6 +93,8 @@ def test_getContractDetails(controller):
8993
def localSnapshot(fixture, controllerSnapshot):
9094
fixture.resetToSnapshot(controllerSnapshot)
9195
fixture.upload('solidity_test_helpers/ControllerUser.sol')
96+
fixture.uploadAndAddToController('../source/contracts/Augur.sol')
97+
fixture.contracts["Augur"].setController(fixture.contracts['Controller'].address)
9298
decentralizedController = fixture.upload('../source/contracts/Controller.sol', 'decentralizedController')
9399
decentralizedController.switchModeSoOnlyEmergencyStopsAndEscapeHatchesCanBeUsed(sender = tester.k0)
94100
return fixture.createSnapshot()

0 commit comments

Comments
 (0)