Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added error msgs to require statements in minting/* contracts #242

Merged
merged 19 commits into from
Jan 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ before_install:


install:
- npm install -g truffle@4.1.13
- npm install -g truffle@5.0.0
- yarn install --frozen-lockfile

env:
Expand Down
4 changes: 2 additions & 2 deletions contracts/minting/Controller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ contract Controller is Ownable {
* @dev ensure that the caller is the controller of a non-zero worker address
*/
modifier onlyController() {
require(controllers[msg.sender] != address(0));
require(controllers[msg.sender] != address(0), "The value of controller[msg.sender] must be non-zero.");
_;
}

Expand All @@ -54,7 +54,7 @@ contract Controller is Ownable {
* Argument _worker must not be 0x00, call removeController(_controller) instead.
*/
function configureController(address _controller, address _worker) onlyOwner public returns (bool) {
require(_worker != address(0));
require(_worker != address(0), "Worker must be a non-zero address.");
controllers[_controller] = _worker;
emit ControllerConfigured(_controller, _worker);
return true;
Expand Down
2 changes: 1 addition & 1 deletion contracts/minting/MintController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ contract MintController is Controller {
*/
function incrementMinterAllowance(uint256 allowanceIncrement) onlyController public returns (bool) {
address minter = controllers[msg.sender];
require(minterManager.isMinter(minter));
require(minterManager.isMinter(minter), "Can only increment allowance for minters in minterManager.");

uint256 currentAllowance = minterManager.minterAllowance(minter);
uint256 newAllowance = currentAllowance.add(allowanceIncrement);
Expand Down
6 changes: 4 additions & 2 deletions migrations/2_deploy_usdc.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@ module.exports = function(deployer, network, accounts) {
console.log("initializing proxy");
// Pretend that the proxy address is a FiatTokenV1
// this is fine because the proxy will forward all the calls to the FiatTokenV1 impl
tokenProxy = FiatTokenV1.at(tokenProxy.address);
return tokenProxy.initialize(
return FiatTokenV1.at(tokenProxy.address);
})
.then(function(tokenProxyAsFiatTokenV1){
return tokenProxyAsFiatTokenV1.initialize(
"USD//C",
"USDC",
"USD",
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"dependencies": {
"assert-diff": "^1.2.6",
"bignumber.js": "6.0.0",
"bn.js": "^4.11.8",
"clone": "2.1.2",
"csv-parse": "3.0.0",
"ethereumjs-abi": "^0.6.5",
Expand All @@ -43,6 +44,7 @@
"zos-lib": "1.3.0"
},
"devDependencies": {
"bn-chai": "^1.0.1",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"chai-bignumber": "^2.0.2",
Expand Down
11 changes: 6 additions & 5 deletions test/ABIUtils.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@

var Tx = require('ethereumjs-tx');

function makeRawTransaction(msgData, msgSender, hexPrivateKey, contractAddress) {
async function makeRawTransaction(msgData, msgSender, hexPrivateKey, contractAddress) {
var nonce = web3.utils.toHex(await web3.eth.getTransactionCount(msgSender));
var tx = new Tx({
nonce: web3.toHex(web3.eth.getTransactionCount(msgSender)),
gasPrice: web3.toHex(web3.toWei('20', 'gwei')),
nonce: nonce,
gasPrice: web3.utils.toHex(web3.utils.toWei('20', 'gwei')),
gasLimit: 1000000,
to: contractAddress,
value: 0,
Expand All @@ -18,15 +19,15 @@ function makeRawTransaction(msgData, msgSender, hexPrivateKey, contractAddress)

function sendRawTransaction(raw) {
return new Promise(function (resolve, reject) {
web3.eth.sendRawTransaction(raw, function (err, transactionHash) {
web3.eth.sendSignedTransaction(raw, function (err, transactionHash) {
if (err !== null) return reject(err);
resolve(transactionHash);
});
});
}

function functionSignature(methodName) {
return web3.sha3(methodName).substr(0, 2 + 8);
return web3.utils.sha3(methodName).substr(0, 2 + 8);
}

function encodeAddress(address) {
Expand Down
44 changes: 29 additions & 15 deletions test/AccountUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,17 @@ var clone = require('clone');

// named list of all accounts
var Accounts = {
deployerAccount: "0x90f8bf6a479f320ead074411a4b0e7944ea8c9c1", // accounts[0]
arbitraryAccount: "0xffcf8fdee72ac11b5c542428b35eef5769c409f0", // accounts[1]
// issuerControllerAccount: "0x22d491bde2303f2f43325b2108d26f1eaba1e32b", // accounts[2]
tokenOwnerAccount: "0xe11ba2b4d45eaed5996cd0823791e0c93114882d", // Accounts.arbitraryAccount
blacklisterAccount: "0xd03ea8624c8c5987235048901fb614fdca89b117", // accounts[4]
arbitraryAccount2: "0x95ced938f7991cd0dfcb48f0a06a40fa1af46ebc", // accounts[5]
masterMinterAccount: "0x3e5e9111ae8eb78fe1cc3bb8915d5d461f3ef9a9", // accounts[6]
minterAccount: "0x28a8746e75304c0780e011bed21c72cd78cd535e", // accounts[7]
pauserAccount: "0xaca94ef8bd5ffee41947b4585a84bda5a3d3da6e", // accounts[8]
mintOwnerAccount: "0x1df62f291b2e969fb0849d99d9ce41e2f137006e", // accounts[9]
// mintProtectorAccount: "0x610bb1573d1046fcb8a70bbbd395754cd57c2b60", // accounts[10]
controller1Account: "0x855fa758c77d68a04990e992aa4dcdef899f654a", // accounts[11]
// controller2Account: "0xfa2435eacf10ca62ae6787ba2fb044f8733ee843", // accounts[12]
// issuerOwnerAccount: "0x64e078a8aa15a41b85890265648e965de686bae6", // accounts[13]
proxyOwnerAccount: "0x2f560290fef1b3ada194b6aa9c40aa71f8e95598", // accounts[14]
deployerAccount: "0x90F8BF6A479F320EAD074411A4B0E7944EA8C9C1", // accounts[0]
arbitraryAccount: "0xFFCF8FDEE72AC11B5C542428B35EEF5769C409F0", // accounts[1]
tokenOwnerAccount: "0xE11BA2B4D45EAED5996CD0823791E0C93114882D", // Accounts.arbitraryAccount
blacklisterAccount: "0xD03EA8624C8C5987235048901FB614FDCA89B117", // accounts[4]
arbitraryAccount2: "0x95CED938F7991CD0DFCB48F0A06A40FA1AF46EBC", // accounts[5]
masterMinterAccount: "0x3E5E9111AE8EB78FE1CC3BB8915D5D461F3EF9A9", // accounts[6]
minterAccount: "0x28A8746E75304C0780E011BED21C72CD78CD535E", // accounts[7]
pauserAccount: "0xACA94EF8BD5FFEE41947B4585A84BDA5A3D3DA6E", // accounts[8]
mintOwnerAccount: "0x1DF62F291B2E969FB0849D99D9CE41E2F137006E", // accounts[9]
controller1Account: "0x855FA758C77D68A04990E992AA4DCDEF899F654A", // accounts[11]
proxyOwnerAccount: "0x2F560290FEF1B3ADA194B6AA9C40AA71F8E95598", // accounts[14]
};

// named list of known private keys
Expand All @@ -44,6 +40,22 @@ var AccountPrivateKeys = {
proxyOwnerAccount: "21d7212f3b4e5332fd465877b64926e3532653e2798a11255a46f533852dfe46", // accounts[14]
};

function addressEquals(address1, address2) {
if (address1.toUpperCase() == address2.toUpperCase()) {
return true;
} else {
assert.isFalse("expect " + address1 + " to equal " + address2);
}
}

function addressNotEquals(address1, address2) {
if (address1.toUpperCase() != address2.toUpperCase()) {
return true;
} else {
assert.isFalse("expect " + address1 + " to not equal " + address2);
}
}

// Returns an object with all named account values set to the default value
// e.g sets {owner: 0, minter: 0,...}
function setAccountDefault(accounts, defaultValue) {
Expand Down Expand Up @@ -152,4 +164,6 @@ module.exports = {
buildExpectedPartialState: buildExpectedPartialState,
checkState: checkState,
getAccountState: getAccountState,
addressEquals: addressEquals,
addressNotEquals: addressNotEquals,
}
4 changes: 0 additions & 4 deletions test/ControllerTestUtils.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
var BigNumber = require('bignumber.js');
var Q = require('q');

// set to true to enable verbose logging in the tests
var debugLogging = false;


var tokenUtils = require('./TokenTestUtils.js');

var Controller = artifacts.require('./../minting/Controller');
var AccountUtils = require('./AccountUtils.js');
var Accounts = AccountUtils.Accounts;
Expand Down
4 changes: 1 addition & 3 deletions test/MintControllerUtils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
var BigNumber = require('bignumber.js');
var bigZero = new BigNumber(0);

var tokenUtils = require('./TokenTestUtils.js');
var bigZero = tokenUtils.bigZero;
var initializeTokenWithProxy = tokenUtils.initializeTokenWithProxy;

var MintController = artifacts.require('./minting/MintController');
Expand Down
Loading