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

Basic tests #224

Merged
merged 4 commits into from
Oct 9, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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: 2 additions & 0 deletions test/TokenTestUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var BigNumber = require('bignumber.js');
var trueInStorageFormat = "0x01";
var bigZero = new BigNumber(0);
var bigHundred = new BigNumber(100);
var maxAmount = "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";
var assertDiff = require('assert-diff');
assertDiff.options.strict = true;
var Q = require('q');
Expand Down Expand Up @@ -963,4 +964,5 @@ module.exports = {
encodeCall: encodeCall,
getInitializedV1: getInitializedV1,
getAdmin: getAdmin,
maxAmount: maxAmount,
};
633 changes: 633 additions & 0 deletions test/minting/MintP0BasicTests.js

Large diffs are not rendered by default.

76 changes: 76 additions & 0 deletions test/minting/MintP0_ABITests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
var MintController = artifacts.require('minting/MintController');
var FiatToken = artifacts.require('FiatTokenV1');

var BigNumber = require('bignumber.js');
var tokenUtils = require('./../TokenTestUtils');
var checkMINTp0 = tokenUtils.checkMINTp0;
var expectRevert = tokenUtils.expectRevert;
var expectJump = tokenUtils.expectJump;
var bigZero = tokenUtils.bigZero;
var maxAmount = tokenUtils.maxAmount;

var clone = require('clone');

var mintUtils = require('./MintControllerUtils.js');
var AccountUtils = require('./../AccountUtils.js');
var Accounts = AccountUtils.Accounts;
var AccountPrivateKeys = AccountUtils.AccountPrivateKeys;
var getAccountState = AccountUtils.getAccountState;
var MintControllerState = AccountUtils.MintControllerState;
var initializeTokenWithProxyAndMintController = mintUtils.initializeTokenWithProxyAndMintController;
var checkMintControllerState = mintUtils.checkMintControllerState;

var zeroAddress = "0x0000000000000000000000000000000000000000";

var abiUtils = require('./../ABIUtils');
var makeRawTransaction = abiUtils.makeRawTransaction;
var sendRawTransaction = abiUtils.sendRawTransaction;
var functionSignature = abiUtils.functionSignature;
var encodeAddress = abiUtils.encodeAddress;
var encodeUint = abiUtils.encodeUint;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functionSignature, encodeAddress, encodeUint are unused

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

var msgData0 = abiUtils.msgData0;
var msgData = abiUtils.msgData;
var msgData1 = abiUtils.msgData1;
var msgData2 = abiUtils.msgData2;
var msgData3 = abiUtils.msgData3;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

msgData2, msgData3 are unused

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed


async function run_tests(newToken, accounts) {

beforeEach('Make fresh token contract', async function () {
rawToken = await newToken();
tokenConfig = await initializeTokenWithProxyAndMintController(rawToken);
token = tokenConfig.token;
mintController = tokenConfig.mintController;
expectedMintControllerState = clone(tokenConfig.customState);
expectedTokenState = [{ 'variable': 'masterMinter', 'expectedValue': mintController.address }];
});

it('abi100 internal_setMinterAllowance is internal', async function () {
await mintController.configureController(Accounts.controller1Account, Accounts.minterAccount, {from: Accounts.mintOwnerAccount});
let badData = msgData1('internal_setMinterAllowance(address,uint256)', Accounts.controller1Account, 569);
let raw = makeRawTransaction(
badData,
Accounts.mintOwnerAccount,
AccountPrivateKeys.mintOwnerPrivateKey,
mintController.address);
await expectRevert(sendRawTransaction(raw));
});

it('abi101 setOwner is internal', async function () {
let badData = msgData('setOwner(address)', Accounts.arbitraryAccount);
let raw = makeRawTransaction(
badData,
Accounts.mintOwnerAccount,
AccountPrivateKeys.mintOwnerPrivateKey,
mintController.address);
await expectRevert(sendRawTransaction(raw));
});

}

var testWrapper = require('./../TestWrapper');
testWrapper.execute('MINTp0_ABITests', run_tests);

module.exports = {
run_tests: run_tests,
}
Original file line number Diff line number Diff line change
@@ -1,55 +1,55 @@
File,Function,Special Condition,Code,Description
Controller.sol,configureController,msg.sender == owner,bt004,bt004 configureController works when owner is msg.sender
Controller.sol,configureController,msg.sender != owner,bt005,bt005 configureController reverts when owner is not msg.sender
Controller.sol,configureController,controllers[C]=0,bt019,bt019 configureController works when controller[C]=0
Controller.sol,configureController,controllers[C] != 0,bt020,bt020 configureController works when controller[C] != 0
Controller.sol,configureController,controllers[C]=C,bt021,"bt021 configureController(C,C) works"
Controller.sol,configureController,controllers[C] == msg.sender,bt022,bt022 configureController works when setting controller[C]=msg.sender
Controller.sol,configureController,controllers[C] == newM,bt023,"bt023 configureController(C, newM) works when controller[C]=newM"
Controller.sol,constructor,controllers[ALL] = 0,bt016,bt016 Constructor sets all controllers to 0
Controller.sol,removeController,msg.sender == owner,bt008,bt008 removeController works when owner is msg.sender
Controller.sol,removeController,msg.sender != owner,bt009,bt009 removeController reverts when owner is not msg.sender
Controller.sol,removeController,controllers[C]=0,bt017,bt017 removeController does not revert when controllers[C] is 0
Controller.sol,removeController,controllers[C]=M,bt018,bt018 removeController removes an arbitrary controller
FiatTokenV1.sol,constructor,minterManager.isMinter[ALL] == false,bt045,bt045 constructor - minterManager.isMinter[ALL] is false
FiatTokenV1.sol,constructor,minterManager.minterAllowance[ALL] == 0,bt046,bt046 constructor - minterManager.minterAllowance[ALL] = 0
MintController.sol,configureMinter,controllers[msg.sender]==0,bt012,bt012 configureMinter reverts when msg.sender is not a controller
MintController.sol,configureMinter,controllers[msg.sender]==M,bt013,bt013 configureMinter sents controllers[msg.sender] to M
MintController.sol,configureMinter,minterManager = 0,bt033,bt033 configureMinter reverts when minterManager is 0
MintController.sol,configureMinter,minterManager != MinterManagerInterface,bt034,bt034 configureMinter reverts when minterManager is a user account
MintController.sol,configureMinter,minterManager == OK,bt035,bt035 configureMinter works when minterManager is ok
MintController.sol,configureMinter,minterManager.isMinter == false,bt039,"bt039 configureMinter(M, amt) works when minterManager.isMinter(M)=false"
MintController.sol,configureMinter,minterManager.isMinter == true,bt040,"bt040 configureMinter(M, amt) works when minterManager.isMinter(M)=true"
MintController.sol,configureMinter,minterManager.minterAllowance[M] == 0,bt050,"bt050 configureMinter(M,amt) works when minterAllowance=0"
MintController.sol,configureMinter,minterManager.minterAllowance[M] == X,bt051,"bt051 configureMinter(M,amt) works when minterAllowance>0"
MintController.sol,configureMinter,minterManager.minterAllowance[M] == BIG,bt052,"bt052 configureMinter(M,amt) works when amt+minterAllowance > 2^256"
MintController.sol,constructor,minterManager == init,bt024,bt024 Constructor sets minterManager
MintController.sol,incrementMinterAllowance,controllers[msg.sender]==0,bt014,bt014 incrementMinterAllowance reverts if msg.sender is not a controller
MintController.sol,incrementMinterAllowance,controllers[msg.sender]==M,bt015,bt015 incrementMinterAllowance sets controllers[msg.sender] to M
MintController.sol,incrementMinterAllowance,minterManager = 0,bt036,bt036 incrementMinterAllowance reverts when minterManager is 0
MintController.sol,incrementMinterAllowance,minterManager != MinterManagerInterface,bt037,bt037 incrementMinterAllowance reverts when minterManager is a user account
MintController.sol,incrementMinterAllowance,minterManager == OK,bt038,bt038 incrementMinterAllowance works when minterManager is ok
MintController.sol,incrementMinterAllowance,minterManager.isMinter == false,bt043,"bt043 incrementMinterAllowance(M, amt) works when minterManager.isMinter(M)=false"
MintController.sol,incrementMinterAllowance,minterManager.isMinter == true,bt044,"bt044 incrementMinterAllowance(M, amt) works when minterManager.isMinter(M)=true"
MintController.sol,incrementMinterAllowance,minterManager.minterAllowance[M] == 0,bt047,"bt047 incrementMinterAllowance(M,amt) works when minterAllowance is 0"
MintController.sol,incrementMinterAllowance,minterManager.minterAllowance[M] == X,bt048,"bt048 incrementMinterAllowance(M, amt) works when minterAllowance > 0"
MintController.sol,incrementMinterAllowance,minterManager.minterAllowance[M] == BIG,bt049,"bt049 incrementMinterAllowance(M,amt) reverts when minterAllowance[M] + amt > 2^256"
MintController.sol,removeMinter,controllers[msg.sender]==0,bt010,bt010 removeMinter reverts when msg.sender is not a controller
MintController.sol,removeMinter,controllers[msg.sender]==M,bt011,bt011 removeMinter sets controllers[msg.sender] to 0
MintController.sol,removeMinter,minterManager = 0,bt030,bt030 removeMinter reverts when minterManager is 0
MintController.sol,removeMinter,minterManager != MinterManagerInterface,bt031,bt031 removeMinter reverts when minterManager is a user account
MintController.sol,removeMinter,minterManager == OK,bt032,bt032 removeMinter works when minterManager is ok
MintController.sol,removeMinter,minterManager.isMinter == false,bt041,bt041 removeMinter(M) works when minterManager.isMinter(M)=false
MintController.sol,removeMinter,minterManager.isMinter == true,bt042,bt042 removeMinter(M) works when minterManager.isMinter(M)=true
MintController.sol,removeMinter,minterManager.minterAllowance[M] == 0,bt053,bt053 removeMinter works when the minterAllowance is 0
MintController.sol,removeMinter,minterManager.minterAllowance[M] == X,bt054,bt054 removeMinter works when the minterAllowance is not zero
MintController.sol,removeMinter,minterManager.minterAllowance[M] == BIG,bt055,bt055 removeMinter works when the minterAllowance is big
MintController.sol,setMinterManager,msg.sender == owner,bt006,bt006 setMinterManager works when owner is msg.sender
MintController.sol,setMinterManager,msg.sender != owner,bt007,bt007 setMinterManager reverts when owner is not msg.sender
MintController.sol,setMinterManager,minterManager == 0,bt025,bt025 setMinterManager(x) works when existing minterManager = 0
MintController.sol,setMinterManager,minterManager != 0,bt026,bt026 setMinterManager(x) works when existing minterManager != 0
MintController.sol,setMinterManager,minterManager == msg.sender,bt027,bt027 setMinterManager(x) works when x = msg.sender
MintController.sol,setMinterManager,minterManager == newMinterManager,bt028,bt028 setMinterManager(x) works when x = minterManager
Ownable.sol,constructor,msg.sender == owner,bt001,bt001 Constructor - owner is msg.sender
Ownable.sol,transferOwnership,msg.sender == owner,bt002,bt002 transferOwnership works when owner is msg.sender
Ownable.sol,transferOwnership,msg.sender != owner,bt003,bt003 transferOwnership reverts when owner is not msg.sender
File,Function,Special Condition,Code,Description
Controller.sol,configureController,msg.sender == owner,bt004,bt004 configureController works when owner is msg.sender
Controller.sol,configureController,msg.sender != owner,bt005,bt005 configureController reverts when owner is not msg.sender
Controller.sol,configureController,controllers[C]=0,bt019,bt019 configureController works when controller[C]=0
Controller.sol,configureController,controllers[C] != 0,bt020,bt020 configureController works when controller[C] != 0
Controller.sol,configureController,controllers[C]=C,bt021,"bt021 configureController(C,C) works"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably want to remove quotes around descriptions in this csv for consistency

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed all quotes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returned quotes because they are needed. If the description has a comma inside it, then the entire column contents needs to be in quotation marks.

Controller.sol,configureController,controllers[C] == msg.sender,bt022,bt022 configureController works when setting controller[C]=msg.sender
Controller.sol,configureController,controllers[C] == newM,bt023,"bt023 configureController(C, newM) works when controller[C]=newM"
Controller.sol,constructor,controllers[ALL] = 0,bt016,bt016 Constructor sets all controllers to 0
Controller.sol,removeController,msg.sender == owner,bt008,bt008 removeController works when owner is msg.sender
Controller.sol,removeController,msg.sender != owner,bt009,bt009 removeController reverts when owner is not msg.sender
Controller.sol,removeController,controllers[C]=0,bt017,bt017 removeController does not revert when controllers[C] is 0
Controller.sol,removeController,controllers[C]=M,bt018,bt018 removeController removes an arbitrary controller
FiatTokenV1.sol,constructor,minterManager.isMinter[ALL] == false,bt045,bt045 constructor - minterManager.isMinter[ALL] is false
FiatTokenV1.sol,constructor,minterManager.minterAllowance[ALL] == 0,bt046,bt046 constructor - minterManager.minterAllowance[ALL] = 0
MintController.sol,configureMinter,controllers[msg.sender]==0,bt012,bt012 configureMinter reverts when msg.sender is not a controller
MintController.sol,configureMinter,controllers[msg.sender]==M,bt013,bt013 configureMinter works when controllers[msg.sender]=M
MintController.sol,configureMinter,minterManager = 0,bt033,bt033 configureMinter reverts when minterManager is 0
MintController.sol,configureMinter,minterManager != MinterManagerInterface,bt034,bt034 configureMinter reverts when minterManager is a user account
MintController.sol,configureMinter,minterManager == OK,bt035,bt035 configureMinter works when minterManager is ok
MintController.sol,configureMinter,minterManager.isMinter == false,bt039,"bt039 configureMinter(M, amt) works when minterManager.isMinter(M)=false"
MintController.sol,configureMinter,minterManager.isMinter == true,bt040,"bt040 configureMinter(M, amt) works when minterManager.isMinter(M)=true"
MintController.sol,configureMinter,minterManager.minterAllowance[M] == 0,bt050,"bt050 configureMinter(M,amt) works when minterAllowance=0"
MintController.sol,configureMinter,minterManager.minterAllowance[M] == X,bt051,"bt051 configureMinter(M,amt) works when minterAllowance>0"
MintController.sol,configureMinter,minterManager.minterAllowance[M] == BIG,bt052,"bt052 configureMinter(M,amt) works when amt+minterAllowance > 2^256"
MintController.sol,constructor,minterManager == init,bt024,bt024 Constructor sets minterManager
MintController.sol,incrementMinterAllowance,controllers[msg.sender]==0,bt014,bt014 incrementMinterAllowance reverts if msg.sender is not a controller
MintController.sol,incrementMinterAllowance,controllers[msg.sender]==M,bt015,bt015 incrementMinterAllowance works when controllers[msg.sender]=M
MintController.sol,incrementMinterAllowance,minterManager = 0,bt036,bt036 incrementMinterAllowance reverts when minterManager is 0
MintController.sol,incrementMinterAllowance,minterManager != MinterManagerInterface,bt037,bt037 incrementMinterAllowance reverts when minterManager is a user account
MintController.sol,incrementMinterAllowance,minterManager == OK,bt038,bt038 incrementMinterAllowance works when minterManager is ok
MintController.sol,incrementMinterAllowance,minterManager.isMinter == false,bt043,"bt043 incrementMinterAllowance(M, amt) reverts when minterManager.isMinter(M)=false"
MintController.sol,incrementMinterAllowance,minterManager.isMinter == true,bt044,"bt044 incrementMinterAllowance(M, amt) works when minterManager.isMinter(M)=true"
MintController.sol,incrementMinterAllowance,minterManager.minterAllowance[M] == 0,bt047,"bt047 incrementMinterAllowance(M,amt) works when minterAllowance is 0"
MintController.sol,incrementMinterAllowance,minterManager.minterAllowance[M] == X,bt048,"bt048 incrementMinterAllowance(M, amt) works when minterAllowance > 0"
MintController.sol,incrementMinterAllowance,minterManager.minterAllowance[M] == BIG,bt049,"bt049 incrementMinterAllowance(M,amt) reverts when minterAllowance[M] + amt > 2^256"
MintController.sol,removeMinter,controllers[msg.sender]==0,bt010,bt010 removeMinter reverts when msg.sender is not a controller
MintController.sol,removeMinter,controllers[msg.sender]==M,bt011,bt011 removeMinter sets minters[M] to 0
MintController.sol,removeMinter,minterManager = 0,bt030,bt030 removeMinter reverts when minterManager is 0
MintController.sol,removeMinter,minterManager != MinterManagerInterface,bt031,bt031 removeMinter reverts when minterManager is a user account
MintController.sol,removeMinter,minterManager == OK,bt032,bt032 removeMinter works when minterManager is ok
MintController.sol,removeMinter,minterManager.isMinter == false,bt041,bt041 removeMinter(M) works when minterManager.isMinter(M)=false
MintController.sol,removeMinter,minterManager.isMinter == true,bt042,bt042 removeMinter(M) works when minterManager.isMinter(M)=true
MintController.sol,removeMinter,minterManager.minterAllowance[M] == 0,bt053,bt053 removeMinter works when the minterAllowance is 0
MintController.sol,removeMinter,minterManager.minterAllowance[M] == X,bt054,bt054 removeMinter works when the minterAllowance is not zero
MintController.sol,removeMinter,minterManager.minterAllowance[M] == BIG,bt055,bt055 removeMinter works when the minterAllowance is big
MintController.sol,setMinterManager,msg.sender == owner,bt006,bt006 setMinterManager works when owner is msg.sender
MintController.sol,setMinterManager,msg.sender != owner,bt007,bt007 setMinterManager reverts when owner is not msg.sender
MintController.sol,setMinterManager,minterManager == 0,bt025,bt025 setMinterManager(x) works when existing minterManager = 0
MintController.sol,setMinterManager,minterManager != 0,bt026,bt026 setMinterManager(x) works when existing minterManager != 0
MintController.sol,setMinterManager,minterManager == msg.sender,bt027,bt027 setMinterManager(x) works when x = msg.sender
MintController.sol,setMinterManager,minterManager == newMinterManager,bt028,bt028 setMinterManager(x) works when x = minterManager
Ownable.sol,constructor,msg.sender == owner,bt001,bt001 Constructor - owner is msg.sender
Ownable.sol,transferOwnership,msg.sender == owner,bt002,bt002 transferOwnership works when owner is msg.sender
Ownable.sol,transferOwnership,msg.sender != owner,bt003,bt003 transferOwnership reverts when owner is not msg.sender
14 changes: 1 addition & 13 deletions verification/verification_reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,18 +184,6 @@ function verification_reporter (runner) {
}
}

// Print out any tests that are included in UnitTestCompleteness tab but
// missing from the test suite.
// TODO: fix completeness spreadshet
/* if (!_.isEmpty(spreadsheet.completeness)) {
console.log('\n' + red_x + color('bright fail',
' UnitTestCompleteness tab includes tests that are not present in test suite:')
+ '\n' + Object.keys(spreadsheet.completeness).toString());
} else {
console.log(green_ok + color('bright pass',
' Test suite suite contains all tests in UnitTestCompleteness tab.'));
}
delete spreadsheet.completeness;*/
// If all the tests in a tab are present, 'cross-off' tab by deleting.
for(var testSuite in missingUnitTests) {
if (_.isEmpty(missingUnitTests[testSuite])) {
Expand All @@ -205,7 +193,7 @@ function verification_reporter (runner) {

// Do not report missing unit tests for files that did not run
for(var testSuite in missingUnitTests){
if(! _.has(executedTestSuites, testSuite) && ! testSuite.match(/Completeness/)) {
if(! _.has(executedTestSuites, testSuite) /* && ! testSuite.match(/Completeness/)*/) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you leave a comment on the PR why this change is necessary just to clarify?

console.log(color('fail', 'Did not run: ' + testSuite));
delete missingUnitTests[testSuite];
}
Expand Down