def localSnapshot(fixture, kitchenSinkSnapshot): fixture.resetToSnapshot(kitchenSinkSnapshot) augur = fixture.contracts["Augur"] kitchenSinkSnapshot['zeroX'] = fixture.upload('solidity_test_helpers/ZeroX/ZeroXPoC.sol', "zeroX", constructorArgs=[augur.address]) market = ABIContract(fixture.chain, kitchenSinkSnapshot['yesNoMarket'].translator, kitchenSinkSnapshot['yesNoMarket'].address) return fixture.createSnapshot()
def localSnapshot(fixture, baseSnapshot): fixture.resetToSnapshot(baseSnapshot) controller = fixture.upload('../source/contracts/Controller.sol') assert fixture.contracts['Controller'].owner() == bytesToHexString(tester.a0) fixture.upload('solidity_test_helpers/ControllerUser.sol') fixture.uploadAugur() return fixture.createSnapshot()
def localSnapshot(fixture, augurInitializedWithMocksSnapshot): fixture.resetToSnapshot(augurInitializedWithMocksSnapshot) controller = fixture.contracts['Controller'] mockCash = fixture.contracts['MockCash'] mockAugur = fixture.contracts['MockAugur'] mockFeeToken = fixture.contracts['MockFeeToken'] mockFeeTokenFactory = fixture.contracts['MockFeeTokenFactory'] mockFeeTokenFactory.setCreateFeeToken(mockFeeToken.address) mockReputationToken = fixture.contracts['MockReputationToken'] controller.registerContract(stringToBytes('Cash'), mockCash.address, twentyZeros, thirtyTwoZeros) controller.registerContract(stringToBytes('Augur'), mockAugur.address, twentyZeros, thirtyTwoZeros) controller.registerContract(stringToBytes('FeeTokenFactory'), mockFeeTokenFactory.address, twentyZeros, thirtyTwoZeros) feeWindow = fixture.upload('../source/contracts/reporting/FeeWindow.sol', 'feeWindow') fixture.contracts["initializedFeeWindow"] = feeWindow feeWindow.setController(fixture.contracts["Controller"].address) mockUniverse = fixture.contracts['MockUniverse'] mockUniverse.setReputationToken(mockReputationToken.address) mockUniverse.setDisputeRoundDurationInSeconds(5040) mockUniverse.setForkingMarket(5040) mockUniverse.setForkingMarket(longToHexString(0)) mockUniverse.setIsForking(False) fixture.contracts["Time"].setTimestamp(feeWindowId) feeWindow.initialize(mockUniverse.address, feeWindowId) return fixture.createSnapshot()
def localSnapshot(fixture, augurInitializedWithMocksSnapshot): fixture.resetToSnapshot(augurInitializedWithMocksSnapshot) controller = fixture.contracts['Controller'] mockLegacyReputationToken = fixture.contracts['MockLegacyReputationToken'] controller.registerContract(stringToBytes('LegacyReputationToken'), mockLegacyReputationToken.address, twentyZeros, thirtyTwoZeros) mockLegacyReputationToken.setTotalSupply(100) mockLegacyReputationToken.setBalanceOfValueFor(tester.a0, 100) return fixture.createSnapshot()
def localSnapshot(fixture, augurInitializedWithMocksSnapshot): fixture.resetToSnapshot(augurInitializedWithMocksSnapshot) controller = fixture.contracts['Controller'] mockCash = fixture.contracts['MockCash'] mockAugur = fixture.contracts['MockAugur'] mockInitialReporter = fixture.contracts['MockInitialReporter'] mockDisputeCrowdsourcer = fixture.contracts['MockDisputeCrowdsourcer'] mockShareTokenFactory = fixture.contracts['MockShareTokenFactory'] mockInitialReporterFactory = fixture.contracts['MockInitialReporterFactory'] mockDisputeCrowdsourcerFactory = fixture.contracts['MockDisputeCrowdsourcerFactory'] mockShareToken = fixture.contracts['MockShareToken'] # pre populate share tokens for max of 8 possible outcomes for index in range(8): item = fixture.uploadAndAddToController('solidity_test_helpers/MockShareToken.sol', 'newMockShareToken' + str(index)); mockShareTokenFactory.pushCreateShareToken(item.address) controller.registerContract(stringToBytes('Cash'), mockCash.address, twentyZeros, thirtyTwoZeros) controller.registerContract(stringToBytes('ShareTokenFactory'), mockShareTokenFactory.address, twentyZeros, thirtyTwoZeros) controller.registerContract(stringToBytes('InitialReporterFactory'), mockInitialReporterFactory.address, twentyZeros, thirtyTwoZeros) controller.registerContract(stringToBytes('DisputeCrowdsourcerFactory'), mockDisputeCrowdsourcerFactory.address, twentyZeros, thirtyTwoZeros) mockShareTokenFactory.resetCreateShareToken() mockReputationToken = fixture.contracts['MockReputationToken'] mockUniverse = fixture.contracts['MockUniverse'] mockUniverse.setReputationToken(mockReputationToken.address) mockFeeWindow = fixture.contracts['MockFeeWindow'] mockFeeWindow.setReputationToken(mockReputationToken.address) mockFeeWindow.setUniverse(mockUniverse.address) mockNextFeeWindow = fixture.upload('solidity_test_helpers/MockFeeWindow.sol', 'mockNextFeeWindow') mockNextFeeWindow.setReputationToken(mockReputationToken.address) mockNextFeeWindow.setUniverse(mockUniverse.address) mockInitialReporterFactory.setInitialReporter(mockInitialReporter.address) mockDisputeCrowdsourcerFactory.setDisputeCrowdsourcer(mockDisputeCrowdsourcer.address) constants = fixture.contracts['Constants'] market = fixture.upload('../source/contracts/reporting/Market.sol', 'market') fixture.contracts["initializedMarket"] = market contractMap = fixture.upload('../source/contracts/libraries/collections/Map.sol', 'Map') endTime = fixture.contracts["Time"].getTimestamp() + constants.DESIGNATED_REPORTING_DURATION_SECONDS() market.setController(fixture.contracts["Controller"].address) mockUniverse.setForkingMarket(longToHexString(0)) mockUniverse.setOrCacheDesignatedReportNoShowBond(100) mockReputationToken.setBalanceOf(100) mockUniverse.setOrCacheTargetReporterGasCosts(15) mockUniverse.setOrCacheValidityBond(12) mockUniverse.setNextFeeWindow(mockNextFeeWindow.address) mockFeeWindow.setEndTime(fixture.contracts["Time"].getTimestamp() + constants.DESIGNATED_REPORTING_DURATION_SECONDS()) mockNextFeeWindow.setEndTime(mockFeeWindow.getEndTime() + constants.DESIGNATED_REPORTING_DURATION_SECONDS()) assert market.initialize(mockUniverse.address, endTime, 16, mockCash.address, tester.a1, tester.a2, 5, numTicks, value=100) return fixture.createSnapshot()
def reportingSnapshot(fixture, kitchenSinkSnapshot): fixture.resetToSnapshot(kitchenSinkSnapshot) # Give some REP to testers to make things interesting universe = ABIContract(fixture.chain, kitchenSinkSnapshot['universe'].translator, kitchenSinkSnapshot['universe'].address) reputationToken = fixture.applySignature('ReputationToken', universe.getReputationToken()) for testAccount in [tester.a1, tester.a2, tester.a3]: reputationToken.transfer(testAccount, 1 * 10**6 * 10**18) return fixture.createSnapshot()
def localSnapshot(fixture, controllerSnapshot): fixture.resetToSnapshot(controllerSnapshot) fixture.uploadAugur() name = "DelegatorHelper" targetName = "DelegatorHelperTarget" fixture.uploadAndAddToController("solidity_test_helpers/DelegatorHelper.sol", targetName, name) fixture.uploadAndAddToController("../source/contracts/libraries/Delegator.sol", name, "delegator", constructorArgs=[fixture.contracts['Controller'].address, stringToBytes(targetName)]) fixture.contracts[name] = fixture.applySignature(name, fixture.contracts[name].address) return fixture.createSnapshot()
def localSnapshot(fixture, kitchenSinkSnapshot): fixture.resetToSnapshot(kitchenSinkSnapshot) universe = ABIContract(fixture.chain, kitchenSinkSnapshot['universe'].translator, kitchenSinkSnapshot['universe'].address) cash = ABIContract(fixture.chain, kitchenSinkSnapshot['cash'].translator, kitchenSinkSnapshot['cash'].address) fixture.markets = [ fixture.createReasonableCategoricalMarket(universe, 2, cash), fixture.createReasonableCategoricalMarket(universe, 3, cash), fixture.createReasonableCategoricalMarket(universe, 4, cash), fixture.createReasonableCategoricalMarket(universe, 5, cash), fixture.createReasonableCategoricalMarket(universe, 6, cash), fixture.createReasonableCategoricalMarket(universe, 7, cash), fixture.createReasonableCategoricalMarket(universe, 8, cash) ] return fixture.createSnapshot()
def localSnapshot(fixture, controllerSnapshot): fixture.resetToSnapshot(controllerSnapshot) fixture.uploadAugur() # Upload a token fixture.uploadAndAddToController("solidity_test_helpers/StandardTokenHelper.sol") # Upload Cash cash = fixture.uploadAndAddToController("../source/contracts/trading/Cash.sol") cash.setController(fixture.contracts['Controller'].address) # Upload the mailbox name = "Mailbox" targetName = "MailboxTarget" fixture.uploadAndAddToController("../source/contracts/reporting/Mailbox.sol", targetName, name) fixture.uploadAndAddToController("../source/contracts/libraries/Delegator.sol", name, "delegator", constructorArgs=[fixture.contracts['Controller'].address, stringToBytes(targetName)]) fixture.contracts[name] = fixture.applySignature(name, fixture.contracts[name].address) fixture.contracts[name].initialize(tester.a0) return fixture.createSnapshot()
def localSnapshot(fixture, augurInitializedWithMocksSnapshot): fixture.resetToSnapshot(augurInitializedWithMocksSnapshot) controller = fixture.contracts['Controller'] mockReputationTokenFactory = fixture.contracts['MockReputationTokenFactory'] mockFeeWindowFactory = fixture.contracts['MockFeeWindowFactory'] mockMarketFactory = fixture.contracts['MockMarketFactory'] mockUniverseFactory = fixture.contracts['MockUniverseFactory'] controller.registerContract(stringToBytes('MarketFactory'), mockMarketFactory.address, twentyZeros, thirtyTwoZeros) controller.registerContract(stringToBytes('ReputationTokenFactory'), mockReputationTokenFactory.address, twentyZeros, thirtyTwoZeros) controller.registerContract(stringToBytes('FeeWindowFactory'), mockFeeWindowFactory.address, twentyZeros, thirtyTwoZeros) controller.registerContract(stringToBytes('UniverseFactory'), mockUniverseFactory.address, twentyZeros, thirtyTwoZeros) mockReputationToken = fixture.contracts['MockReputationToken'] mockUniverse = fixture.contracts['MockUniverse'] universe = fixture.upload('../source/contracts/reporting/Universe.sol', 'universe') fixture.contracts['populatedUniverse'] = universe mockReputationTokenFactory.setCreateReputationTokenValue(mockReputationToken.address) universe.setController(fixture.contracts['Controller'].address) assert universe.initialize(mockUniverse.address, stringToBytes("5")) return fixture.createSnapshot()
def localSnapshot(fixture, kitchenSinkSnapshot): fixture.resetToSnapshot(kitchenSinkSnapshot) universe = ABIContract(fixture.chain, kitchenSinkSnapshot['universe'].translator, kitchenSinkSnapshot['universe'].address) market = ABIContract(fixture.chain, kitchenSinkSnapshot['yesNoMarket'].translator, kitchenSinkSnapshot['yesNoMarket'].address) categoricalMarket = ABIContract(fixture.chain, kitchenSinkSnapshot['categoricalMarket'].translator, kitchenSinkSnapshot['categoricalMarket'].address) scalarMarket = ABIContract(fixture.chain, kitchenSinkSnapshot['scalarMarket'].translator, kitchenSinkSnapshot['scalarMarket'].address) # Skip to Designated Reporting fixture.contracts["Time"].setTimestamp(market.getEndTime() + 1) # Distribute REP reputationToken = fixture.applySignature('ReputationToken', universe.getReputationToken()) for testAccount in [tester.a1, tester.a2, tester.a3]: reputationToken.transfer(testAccount, 1 * 10**6 * 10**18) # Designated Report on the markets designatedReportCost = universe.getOrCacheDesignatedReportStake() with TokenDelta(reputationToken, 0, tester.a0, "Doing the designated report didn't deduct REP correctly or didn't award the no show bond"): market.doInitialReport([market.getNumTicks(), 0], False) categoricalMarket.doInitialReport([categoricalMarket.getNumTicks(), 0, 0], False) scalarMarket.doInitialReport([scalarMarket.getNumTicks(), 0], False) return fixture.createSnapshot()
def localSnapshot(fixture, baseSnapshot): fixture.resetToSnapshot(baseSnapshot) fixture.upload('solidity_test_helpers/ArrayHelper.sol') return fixture.createSnapshot()
def localSnapshot(fixture, controllerSnapshot): fixture.resetToSnapshot(controllerSnapshot) fixture.upload('solidity_test_helpers/ControllerUser.sol') decentralizedController = fixture.upload('../source/contracts/Controller.sol', 'decentralizedController') decentralizedController.switchModeSoOnlyEmergencyStopsAndEscapeHatchesCanBeUsed(sender = tester.k0) return fixture.createSnapshot()
def localSnapshot(fixture, baseSnapshot): fixture.resetToSnapshot(baseSnapshot) fixture.upload('solidity_test_helpers/ContractExistsHelper.sol') return fixture.createSnapshot()
def localSnapshot(fixture, augurInitializedWithMocksSnapshot): return fixture.createSnapshot()
def localSnapshot(fixture, kitchenSinkSnapshot): fixture.resetToSnapshot(kitchenSinkSnapshot) augur = fixture.contracts["Augur"] kitchenSinkSnapshot['zeroX'] = fixture.upload('solidity_test_helpers/ZeroX/ZeroXPoC.sol', "zeroX", constructorArgs=[augur.address]) return fixture.createSnapshot()
def localSnapshot(fixture, augurInitializedWithMocksSnapshot): fixture.resetToSnapshot(augurInitializedWithMocksSnapshot) controller = fixture.contracts['Controller'] mockCash = fixture.contracts['MockCash'] mockAugur = fixture.contracts['MockAugur'] mockInitialReporter = fixture.contracts['MockInitialReporter'] mockDisputeCrowdsourcer = fixture.contracts['MockDisputeCrowdsourcer'] mockShareTokenFactory = fixture.contracts['MockShareTokenFactory'] mockInitialReporterFactory = fixture.contracts[ 'MockInitialReporterFactory'] mockDisputeCrowdsourcerFactory = fixture.contracts[ 'MockDisputeCrowdsourcerFactory'] mockShareToken = fixture.contracts['MockShareToken'] # pre populate share tokens for max of 8 possible outcomes for index in range(8): item = fixture.uploadAndAddToController( 'solidity_test_helpers/MockShareToken.sol', 'newMockShareToken' + str(index)) mockShareTokenFactory.pushCreateShareToken(item.address) controller.registerContract(stringToBytes('Cash'), mockCash.address) controller.registerContract(stringToBytes('ShareTokenFactory'), mockShareTokenFactory.address) controller.registerContract(stringToBytes('InitialReporterFactory'), mockInitialReporterFactory.address) controller.registerContract(stringToBytes('DisputeCrowdsourcerFactory'), mockDisputeCrowdsourcerFactory.address) mockShareTokenFactory.resetCreateShareToken() mockReputationToken = fixture.contracts['MockReputationToken'] mockUniverse = fixture.contracts['MockUniverse'] mockUniverse.setReputationToken(mockReputationToken.address) mockFeeWindow = fixture.contracts['MockFeeWindow'] mockFeeWindow.setReputationToken(mockReputationToken.address) mockFeeWindow.setUniverse(mockUniverse.address) mockNextFeeWindow = fixture.upload( 'solidity_test_helpers/MockFeeWindow.sol', 'mockNextFeeWindow') mockNextFeeWindow.setReputationToken(mockReputationToken.address) mockNextFeeWindow.setUniverse(mockUniverse.address) mockInitialReporterFactory.setInitialReporter(mockInitialReporter.address) mockDisputeCrowdsourcerFactory.setDisputeCrowdsourcer( mockDisputeCrowdsourcer.address) constants = fixture.contracts['Constants'] market = fixture.upload('../source/contracts/reporting/Market.sol', 'market') fixture.contracts["initializedMarket"] = market contractMap = fixture.upload( '../source/contracts/libraries/collections/Map.sol', 'Map') endTime = fixture.contracts["Time"].getTimestamp( ) + constants.DESIGNATED_REPORTING_DURATION_SECONDS() market.setController(fixture.contracts["Controller"].address) mockUniverse.setForkingMarket(longToHexString(0)) mockUniverse.setOrCacheDesignatedReportNoShowBond(100) mockReputationToken.setBalanceOf(100) mockUniverse.setOrCacheTargetReporterGasCosts(15) mockUniverse.setOrCacheValidityBond(12) mockUniverse.setNextFeeWindow(mockNextFeeWindow.address) mockFeeWindow.setEndTime(fixture.contracts["Time"].getTimestamp() + constants.DESIGNATED_REPORTING_DURATION_SECONDS()) mockNextFeeWindow.setEndTime( mockFeeWindow.getEndTime() + constants.DESIGNATED_REPORTING_DURATION_SECONDS()) assert market.initialize(mockUniverse.address, endTime, 16, mockCash.address, tester.a1, tester.a2, 5, numTicks, value=100) return fixture.createSnapshot()
def localSnapshot(fixture, kitchenSinkSnapshot): fixture.resetToSnapshot(kitchenSinkSnapshot) fixture.contracts['universe'] = ABIContract(fixture.chain, kitchenSinkSnapshot['universe'].translator, kitchenSinkSnapshot['universe'].address) fixture.contracts['market'] = ABIContract(fixture.chain, kitchenSinkSnapshot['yesNoMarket'].translator, kitchenSinkSnapshot['yesNoMarket'].address) fixture.contracts['cash'] = ABIContract(fixture.chain, kitchenSinkSnapshot['cash'].translator, kitchenSinkSnapshot['cash'].address) return fixture.createSnapshot()
def localSnapshot(fixture, kitchenSinkSnapshot): fixture.resetToSnapshot(kitchenSinkSnapshot) return fixture.createSnapshot()
def localSnapshot(fixture, kitchenSinkSnapshot): fixture.resetToSnapshot(kitchenSinkSnapshot) augur = fixture.contracts["Augur"] return fixture.createSnapshot()
def localSnapshot(fixture, kitchenSinkSnapshot): fixture.resetToSnapshot(kitchenSinkSnapshot) universe = ABIContract(fixture.chain, kitchenSinkSnapshot['universe'].translator, kitchenSinkSnapshot['universe'].address) market = ABIContract(fixture.chain, kitchenSinkSnapshot['yesNoMarket'].translator, kitchenSinkSnapshot['yesNoMarket'].address) return fixture.createSnapshot()
def localSnapshot(fixture, kitchenSinkSnapshot): fixture.resetToSnapshot(kitchenSinkSnapshot) return fixture.createSnapshot()
def localSnapshot(fixture, augurInitializedSnapshot): fixture.resetToSnapshot(augurInitializedSnapshot) controller = fixture.contracts['Controller'] mockAugur = fixture.uploadAndAddToController("solidity_test_helpers/MockAugur.sol", "Augur") mockToken = fixture.uploadAndAddToController("solidity_test_helpers/MockToken.sol") return fixture.createSnapshot()