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

[CENT-255] Added unit tests for 0xfffff...ff input #197

Merged
merged 1 commit into from
Aug 10, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
104 changes: 104 additions & 0 deletions test/MiscTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ var initializeTokenWithProxy = tokenUtils.initializeTokenWithProxy;
var getInitializedV1 = tokenUtils.getInitializedV1;
var FiatToken = tokenUtils.FiatToken;

var maxAmount = "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";
var amount = 100;

async function run_tests(newToken) {
Expand Down Expand Up @@ -451,6 +452,109 @@ async function run_tests(newToken) {
assert.equal("0x00", initialized);
});

it('ms047 configureMinter works on amount=2^256-1', async function() {
await token.configureMinter(minterAccount, maxAmount, { from: masterMinterAccount });
var customVars = [
{ 'variable': 'isAccountMinter.minterAccount', 'expectedValue': true },
{ 'variable': 'minterAllowance.minterAccount', 'expectedValue': new BigNumber(maxAmount) }
];
await checkVariables([token], [customVars]);
});

it('ms048 mint works on amount=2^256-1', async function() {
await token.configureMinter(minterAccount, maxAmount, { from: masterMinterAccount });
var customVars = [
{ 'variable': 'isAccountMinter.minterAccount', 'expectedValue': true },
{ 'variable': 'minterAllowance.minterAccount', 'expectedValue': new BigNumber(maxAmount) }
];
await checkVariables([token], [customVars]);

await token.mint(arbitraryAccount, maxAmount, { from: minterAccount });
customVars = [
{ 'variable': 'isAccountMinter.minterAccount', 'expectedValue': true },
{ 'variable': 'minterAllowance.minterAccount', 'expectedValue': new BigNumber(0) },
{ 'variable': 'balances.arbitraryAccount', 'expectedValue': new BigNumber(maxAmount) },
{ 'variable': 'totalSupply', 'expectedValue': new BigNumber(maxAmount) }
];
await checkVariables([token], [customVars]);
});

it('ms049 burn on works on amount=2^256-1', async function() {
await token.configureMinter(minterAccount, maxAmount, { from: masterMinterAccount });
await token.mint(minterAccount, maxAmount, { from: minterAccount });
customVars = [
{ 'variable': 'isAccountMinter.minterAccount', 'expectedValue': true },
{ 'variable': 'balances.minterAccount', 'expectedValue': new BigNumber(maxAmount) },
{ 'variable': 'totalSupply', 'expectedValue': new BigNumber(maxAmount) }
];
await checkVariables([token], [customVars]);

await token.burn(maxAmount, { from: minterAccount });
customVars = [
{ 'variable': 'isAccountMinter.minterAccount', 'expectedValue': true },
];
await checkVariables([token], [customVars]);
});

it('ms050 approve works on amount=2^256-1', async function() {
await token.configureMinter(minterAccount, maxAmount, { from: masterMinterAccount });
await token.mint(arbitraryAccount, maxAmount, { from: minterAccount });
customVars = [
{ 'variable': 'isAccountMinter.minterAccount', 'expectedValue': true },
{ 'variable': 'balances.arbitraryAccount', 'expectedValue': new BigNumber(maxAmount) },
{ 'variable': 'totalSupply', 'expectedValue': new BigNumber(maxAmount) }
];
await checkVariables([token], [customVars]);

await token.approve(pauserAccount, maxAmount, {from: arbitraryAccount});
customVars = [
{ 'variable': 'isAccountMinter.minterAccount', 'expectedValue': true },
{ 'variable': 'balances.arbitraryAccount', 'expectedValue': new BigNumber(maxAmount) },
{ 'variable': 'totalSupply', 'expectedValue': new BigNumber(maxAmount) },
{ 'variable': 'allowance.arbitraryAccount.pauserAccount', 'expectedValue': new BigNumber(maxAmount) }
];
await checkVariables([token], [customVars]);
});

it('ms051 transfer works on amount=2^256-1', async function() {
await token.configureMinter(minterAccount, maxAmount, { from: masterMinterAccount });
await token.mint(arbitraryAccount, maxAmount, { from: minterAccount });
customVars = [
{ 'variable': 'isAccountMinter.minterAccount', 'expectedValue': true },
{ 'variable': 'balances.arbitraryAccount', 'expectedValue': new BigNumber(maxAmount) },
{ 'variable': 'totalSupply', 'expectedValue': new BigNumber(maxAmount) }
];
await checkVariables([token], [customVars]);

await token.transfer(pauserAccount, maxAmount, {from: arbitraryAccount});
customVars = [
{ 'variable': 'isAccountMinter.minterAccount', 'expectedValue': true },
{ 'variable': 'balances.pauserAccount', 'expectedValue': new BigNumber(maxAmount) },
{ 'variable': 'totalSupply', 'expectedValue': new BigNumber(maxAmount) },
];
await checkVariables([token], [customVars]);
});

it('ms052 transferFrom works on amount=2^256-1', async function() {
await token.configureMinter(minterAccount, maxAmount, { from: masterMinterAccount });
await token.mint(arbitraryAccount, maxAmount, { from: minterAccount });
await token.approve(pauserAccount, maxAmount, {from: arbitraryAccount});
customVars = [
{ 'variable': 'isAccountMinter.minterAccount', 'expectedValue': true },
{ 'variable': 'balances.arbitraryAccount', 'expectedValue': new BigNumber(maxAmount) },
{ 'variable': 'totalSupply', 'expectedValue': new BigNumber(maxAmount) },
{ 'variable': 'allowance.arbitraryAccount.pauserAccount', 'expectedValue': new BigNumber(maxAmount) }
];
await checkVariables([token], [customVars]);

await token.transferFrom(arbitraryAccount, pauserAccount, maxAmount, {from: pauserAccount});
customVars = [
{ 'variable': 'isAccountMinter.minterAccount', 'expectedValue': true },
{ 'variable': 'balances.pauserAccount', 'expectedValue': new BigNumber(maxAmount) },
{ 'variable': 'totalSupply', 'expectedValue': new BigNumber(maxAmount) },
];
await checkVariables([token], [customVars]);
});
}

module.exports = {
Expand Down