From 7fcfe64f3366aab5bf6f98059205b55828582ff9 Mon Sep 17 00:00:00 2001 From: felix2feng Date: Thu, 21 Feb 2019 15:18:46 -0800 Subject: [PATCH] Shoren reason stings --- contracts/core/extensions/CoreAccounting.sol | 12 ++--- contracts/core/extensions/CoreFactory.sol | 2 +- contracts/core/extensions/CoreInternal.sol | 16 +++---- contracts/core/extensions/CoreIssuance.sol | 12 ++--- .../core/extensions/CoreOperationState.sol | 2 +- migrations/3_core.js | 4 ++ .../extensions/coreModuleInteraction.spec.ts | 46 +++++++++++++------ 7 files changed, 57 insertions(+), 37 deletions(-) diff --git a/contracts/core/extensions/CoreAccounting.sol b/contracts/core/extensions/CoreAccounting.sol index 07b7141a5..3ba2c6ec2 100644 --- a/contracts/core/extensions/CoreAccounting.sol +++ b/contracts/core/extensions/CoreAccounting.sol @@ -199,19 +199,19 @@ contract CoreAccounting is // Confirm and empty _tokens array is not passed require( _tokens.length > 0, - "Core.batchDeposit: Empty tokens array" + "Core: Empty tokens" ); // Confirm an empty _quantities array is not passed require( _quantities.length > 0, - "Core.batchDeposit: Empty quantities array" + "Core: Empty quantities" ); // Confirm there is one quantity for every token address require( _tokens.length == _quantities.length, - "Core.batchDeposit: Tokens and quantities lengths mismatch" + "Core: Tokens + quantities len mismatch" ); state.transferProxyInstance.batchTransfer( @@ -248,19 +248,19 @@ contract CoreAccounting is // Confirm an empty _tokens array is not passed require( _tokens.length > 0, - "Core.batchWithdraw: Empty tokens array" + "Core: Empty tokens" ); // Confirm an empty _quantities array is not passed require( _quantities.length > 0, - "Core.batchWithdraw: Empty quantities array" + "Core: Empty quantities" ); // Confirm there is one quantity for every token address require( _tokens.length == _quantities.length, - "Core.batchWithdraw: Tokens and quantities lengths mismatch" + "Core: Tokens + quantities len mismatch" ); // Call Vault contract to deattribute withdrawn tokens from user diff --git a/contracts/core/extensions/CoreFactory.sol b/contracts/core/extensions/CoreFactory.sol index 6673418eb..e6c669f4e 100644 --- a/contracts/core/extensions/CoreFactory.sol +++ b/contracts/core/extensions/CoreFactory.sol @@ -70,7 +70,7 @@ contract CoreFactory is // Verify Factory is linked to Core require( state.validFactories[_factory], - "Core.create: Invalid or disabled factory address" + "Core: Invalid factory" ); // Create the Set diff --git a/contracts/core/extensions/CoreInternal.sol b/contracts/core/extensions/CoreInternal.sol index 82e40c752..61d469b94 100644 --- a/contracts/core/extensions/CoreInternal.sol +++ b/contracts/core/extensions/CoreInternal.sol @@ -118,7 +118,7 @@ contract CoreInternal is { require( state.validFactories[_factory], - "CoreInternal.removeFactory: Factory not enabled" + "Core: Factory not enabled" ); state.factories = state.factories.remove(_factory); @@ -147,7 +147,7 @@ contract CoreInternal is { require( state.exchangeIds[_exchangeId] == address(0), - "CoreInternal.removeExchange: Exchange Id not registered" + "Core: Exchange Id not registered" ); state.exchangeIds[_exchangeId] = _exchange; @@ -176,12 +176,12 @@ contract CoreInternal is { require( state.exchangeIds[_exchangeId] != address(0), - "CoreInternal.removeExchange: Exchange already removed" + "Core: Exchange already removed" ); require( state.exchangeIds[_exchangeId] == _exchange, - "CoreInternal.removeExchange: ExchangeId does not matched passed exchange" + "Core: ExchangeId != exchange" ); state.exchanges = state.exchanges.remove(_exchange); @@ -229,7 +229,7 @@ contract CoreInternal is { require( state.validModules[_module], - "CoreInternal.removeModule: Module not enabled" + "Core: Module not enabled" ); state.modules = state.modules.remove(_module); @@ -255,7 +255,7 @@ contract CoreInternal is { require( state.validSets[_set], - "CoreInternal.disableSet: Set not enabled" + "Core: Set not enabled" ); state.setTokens = state.setTokens.remove(_set); @@ -283,7 +283,7 @@ contract CoreInternal is { require( state.disabledSets[_set], - "CoreInternal.reenableSet: Set not disabled" + "Core: Set not disabled" ); state.setTokens = state.setTokens.append(_set); @@ -333,7 +333,7 @@ contract CoreInternal is { require( state.validPriceLibraries[_priceLibrary], - "CoreInternal.removePriceLibrary: PriceLibrary not enabled" + "Core: PriceLibrary not enabled" ); state.priceLibraries = state.priceLibraries.remove(_priceLibrary); diff --git a/contracts/core/extensions/CoreIssuance.sol b/contracts/core/extensions/CoreIssuance.sol index 243f253a0..454644c93 100644 --- a/contracts/core/extensions/CoreIssuance.sol +++ b/contracts/core/extensions/CoreIssuance.sol @@ -155,13 +155,13 @@ contract CoreIssuance is // Verify Set was created by Core and is enabled require( state.validSets[_set], - "Core.redeemAndWithdraw: Invalid or disabled SetToken address" + "Core: Invalid SetToken" ); // Validate quantity is multiple of natural unit require( _quantity % setToken.naturalUnit() == 0, - "Core.redeemAndWithdraw: Quantity must be multiple of natural unit" + "Core: Quantity must be multiple of natural unit" ); // Burn the Set token (thereby decrementing the SetToken balance) @@ -287,7 +287,7 @@ contract CoreIssuance is // Verify Set was created by Core and is enabled require( state.validSets[_set], - "Core.issue: Invalid or disabled SetToken address" + "Core: Invalid SetToken" ); // Declare interface variables @@ -296,7 +296,7 @@ contract CoreIssuance is // Validate quantity is multiple of natural unit require( _quantity % setToken.naturalUnit() == 0, - "Core.issue: Quantity must be multiple of natural unit" + "Core: Quantity must be multiple of natural unit" ); // Fetch set token properties @@ -401,7 +401,7 @@ contract CoreIssuance is // Verify Set was created by Core and is enabled require( state.validSets[_set], - "Core.redeem: Invalid or disabled SetToken address" + "Core: Invalid SetToken address" ); // Declare interface variables @@ -411,7 +411,7 @@ contract CoreIssuance is uint256 naturalUnit = setToken.naturalUnit(); require( _quantity % naturalUnit == 0, - "Core.redeem: Quantity must be multiple of natural unit" + "Core: Quantity must be multiple of natural unit" ); // Burn the Set token (thereby decrementing the SetToken balance) diff --git a/contracts/core/extensions/CoreOperationState.sol b/contracts/core/extensions/CoreOperationState.sol index 6add290af..a094851e7 100644 --- a/contracts/core/extensions/CoreOperationState.sol +++ b/contracts/core/extensions/CoreOperationState.sol @@ -60,7 +60,7 @@ contract CoreOperationState is modifier whenOperational() { require( state.operationState == uint8(OperationState.Operational), - "CoreOperationalState.whenOperational: Function is in non-operational state." + "Core: State is non-operational" ); _; } diff --git a/migrations/3_core.js b/migrations/3_core.js index 496d991f5..001a11592 100644 --- a/migrations/3_core.js +++ b/migrations/3_core.js @@ -3,6 +3,7 @@ const Core = artifacts.require("Core"); const ERC20Wrapper = artifacts.require('ERC20Wrapper'); const ExchangeIssueLibrary = artifacts.require('ExchangeIssueLibrary'); const ExchangeIssueModule = artifacts.require('ExchangeIssueModule'); +const IssuanceLibrary = artifacts.require('IssuanceLibrary'); const KyberNetworkWrapper = artifacts.require('KyberNetworkWrapper'); const LinearAuctionPriceCurve = artifacts.require('LinearAuctionPriceCurve'); const PayableExchangeIssue = artifacts.require("PayableExchangeIssue"); @@ -78,6 +79,9 @@ async function deployAndLinkLibraries(deployer, network) { await ZeroExExchangeWrapper.link('ERC20Wrapper', ERC20Wrapper.address); await PayableExchangeIssue.link('ERC20Wrapper', ERC20Wrapper.address); + await deployer.deploy(IssuanceLibrary); + await Core.link('IssuanceLibrary', IssuanceLibrary.address); + await deployer.deploy(ExchangeIssueLibrary); await PayableExchangeIssue.link('ExchangeIssueLibrary', ExchangeIssueLibrary.address); diff --git a/test/contracts/core/extensions/coreModuleInteraction.spec.ts b/test/contracts/core/extensions/coreModuleInteraction.spec.ts index ba913ff32..d5df868c2 100644 --- a/test/contracts/core/extensions/coreModuleInteraction.spec.ts +++ b/test/contracts/core/extensions/coreModuleInteraction.spec.ts @@ -988,19 +988,35 @@ contract('CoreModuleInteraction', accounts => { }); }); - // describe('#batchIncrementTokenOwnerModule', async () => { - // let subjectTokens: Address[]; - // let subjectOwner: Address; - // let subjectQuantities: BigNumber[]; - // let subjectCaller: Address; - - // async function subject(): Promise { - // return core.batchIncrementTokenOwnerModule.sendTransactionAsync( - // subjectTokens, - // subjectOwner, - // subjectQuantities, - // { from: subjectCaller }, - // ); - // } - // }); + describe('#batchIncrementTokenOwnerModule', async () => { + let subjectTokens: Address[]; + let subjectOwner: Address; + let subjectQuantities: BigNumber[]; + let subjectCaller: Address; + + beforeEach(async () => { + subjectTokens = (await erc20Wrapper.deployTokensAsync(2, ownerAccount)).map(token => token.address); + subjectOwner = otherAccount; + subjectQuantities = [new BigNumber(10), new BigNumber(20)]; + subjectCaller = moduleAccount; + }); + + async function subject(): Promise { + return core.batchIncrementTokenOwnerModule.sendTransactionAsync( + subjectTokens, + subjectOwner, + subjectQuantities, + { from: subjectCaller }, + ); + } + + it('should increment the balances of the tokens properly', async () => { + await subject(); + }); + + describe('when the caller is not an authorized module', async () => { + + }); + + }); }); \ No newline at end of file