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 contract block to allow truffle-test single file execution #198

Merged
merged 6 commits into from
Aug 15, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 4 additions & 4 deletions test/ABITests.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var Tx = require('ethereumjs-tx');

var tokenUtils = require('./TokenTestUtils');
var FiatToken = tokenUtils.FiatToken;
var name = tokenUtils.name;
Expand Down Expand Up @@ -57,7 +56,7 @@ function mockStringAddressEncode(methodName, address) {
return functionSignature(methodName) + version + encodeAddress(address);
}

async function run_tests(newToken) {
async function run_tests(newToken, accounts) {

beforeEach(async function checkBefore() {
rawToken = await newToken();
Expand Down Expand Up @@ -282,8 +281,9 @@ async function run_tests(newToken) {
});
}

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

module.exports = {
run_tests: run_tests,
}


5 changes: 4 additions & 1 deletion test/EventsTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var checkTransferEvents = tokenUtils.checkTransferEvents;

var amount = 100;

async function run_tests(newToken) {
async function run_tests(newToken, accounts) {

beforeEach('Make fresh token contract', async function () {
rawToken = await FiatToken.new();
Expand Down Expand Up @@ -146,6 +146,9 @@ async function run_tests(newToken) {
});
}

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

module.exports = {
run_tests: run_tests,
}
5 changes: 4 additions & 1 deletion test/ExtendedPositiveTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var upgradeTo = tokenUtils.upgradeTo;

var amount = 100;

async function run_tests(newToken) {
async function run_tests(newToken, accounts) {

beforeEach('Make fresh token contract', async function () {
rawToken = await newToken();
Expand Down Expand Up @@ -416,6 +416,9 @@ async function run_tests(newToken) {

}

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

module.exports = {
run_tests: run_tests,
}
3 changes: 3 additions & 0 deletions test/FiatTokenLegacy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,9 @@ async function run_tests(newToken, accounts) {
});
}

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

module.exports = {
run_tests: run_tests,
}
5 changes: 4 additions & 1 deletion test/MiscTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var FiatToken = tokenUtils.FiatToken;
var maxAmount = "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";
var amount = 100;

async function run_tests(newToken) {
async function run_tests(newToken, accounts) {

beforeEach('Make fresh token contract', async function () {
rawToken = await newToken();
Expand Down Expand Up @@ -557,6 +557,9 @@ async function run_tests(newToken) {
});
}

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

module.exports = {
run_tests: run_tests,
}
5 changes: 4 additions & 1 deletion test/NegativeTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var amount = 100;
let longZero = 0x0000000000000000000000000000000000000000;
let shortZero = 0x00;

async function run_tests(newToken) {
async function run_tests(newToken, accounts) {

beforeEach('Make fresh token contract', async function () {
rawToken = await newToken();
Expand Down Expand Up @@ -677,6 +677,9 @@ async function run_tests(newToken) {
});
}

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

module.exports = {
run_tests: run_tests,
}
5 changes: 4 additions & 1 deletion test/PositiveTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var FiatToken = tokenUtils.FiatToken;

var amount = 100;

async function run_tests(newToken) {
async function run_tests(newToken, accounts) {

beforeEach('Make fresh token contract', async function () {
rawToken = await newToken();
Expand Down Expand Up @@ -268,6 +268,9 @@ async function run_tests(newToken) {

}

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

module.exports = {
run_tests: run_tests,
}
5 changes: 4 additions & 1 deletion test/ProxyNegativeTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var UpgradedFiatTokenNewFields = tokenUtils.UpgradedFiatTokenNewFields;

var amount = 100;

async function run_tests(newToken) {
async function run_tests(newToken, accounts) {

beforeEach('Make fresh token contract', async function () {
rawToken = await newToken();
Expand Down Expand Up @@ -142,6 +142,9 @@ async function run_tests(newToken) {

}

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

module.exports = {
run_tests: run_tests,
}
5 changes: 4 additions & 1 deletion test/ProxyPositiveTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var sendRawTransaction = abiUtils.sendRawTransaction;

var amount = 100;

async function run_tests(newToken) {
async function run_tests(newToken, accounts) {

beforeEach('Make fresh token contract', async function () {
rawToken = await newToken();
Expand Down Expand Up @@ -314,6 +314,9 @@ async function run_tests(newToken) {

}

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

module.exports = {
run_tests: run_tests,
}
105 changes: 14 additions & 91 deletions test/TestWrapper.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,4 @@
var tokenUtils = require('./TokenTestUtils');
var positive_tests = require('./PositiveTests');
var extended_positive_tests = require('./ExtendedPositiveTests');
var negative_tests = require('./NegativeTests');
var misc_tests = require('./MiscTests');
var abi_tests = require('./ABITests.test');
var legacy_tests = require('./FiatTokenLegacy.test');
var proxy_positive_tests = require('./ProxyPositiveTests');
var proxy_negative_tests = require('./ProxyNegativeTests');
var events_tests = require('./EventsTests');

var name = tokenUtils.name;
var symbol = tokenUtils.symbol;
var currency = tokenUtils.currency;
var decimals = tokenUtils.decimals;
var tokenOwnerAccount = tokenUtils.tokenOwnerAccount;
var blacklisterAccount = tokenUtils.blacklisterAccount;
var masterMinterAccount = tokenUtils.masterMinterAccount;
var pauserAccount = tokenUtils.pauserAccount;
var arbitraryAccount = tokenUtils.arbitraryAccount;
var UpgradedFiatToken = tokenUtils.UpgradedFiatToken;
var FiatToken = tokenUtils.FiatToken;

Expand All @@ -34,78 +15,20 @@ async function newUpgradedToken() {
return token;
}

///////////////////////////////////////////////////////////////////////////////

// Run specific tests combos by commenting/uncommenting the contract blocks below.

contract('FiatToken_ABIHackingTests', async function () {
await abi_tests.run_tests(newToken);
});

contract('FiatToken_ABIHackingTests_Upgraded', async function () {
await abi_tests.run_tests(newUpgradedToken);
});

contract('FiatToken_PositiveTests', async function () {
await positive_tests.run_tests(newToken);
});

contract('FiatToken_PositiveTests_Upgraded', async function () {
await positive_tests.run_tests(newUpgradedToken);
});

contract('FiatToken_ExtendedPositiveTests', async function () {
await extended_positive_tests.run_tests(newToken);
});

contract('FiatToken_ExtendedPositiveTests_Upgraded', async function () {
await extended_positive_tests.run_tests(newUpgradedToken);
});

contract('FiatToken_NegativeTests', async function () {
await negative_tests.run_tests(newToken);
});

contract('FiatToken_NegativeTests_Upgraded', async function () {
await negative_tests.run_tests(newUpgradedToken);
});
// Executes the run_tests_function using an original and
// an upgraded token. The test_suite_name is printed standard output.
function execute(test_suite_name, run_tests_function) {
contract(test_suite_name, async function (accounts) {
await run_tests_function(newToken, accounts);
});

contract('FiatToken_MiscTests', async function () {
await misc_tests.run_tests(newToken);
});
contract(test_suite_name + " Upgraded", async function (accounts) {
await run_tests_function(newUpgradedToken, accounts);
});

contract('FiatToken_MiscTests_Upgraded', async function () {
await misc_tests.run_tests(newUpgradedToken);
});

contract('FiatToken_ProxyPositiveTests', async function (accounts) {
await proxy_positive_tests.run_tests(newToken);
});

contract('FiatToken_ProxyPositiveTests_Upgraded', async function (accounts) {
await proxy_positive_tests.run_tests(newUpgradedToken);
});

contract('FiatToken_ProxyNegativeTests', async function (accounts) {
await proxy_negative_tests.run_tests(newToken);
});

contract('FiatToken_ProxyNegativeTests_Upgraded', async function (accounts) {
await proxy_negative_tests.run_tests(newUpgradedToken);
});

contract('FiatToken_LegacyTests', async function (accounts) {
await legacy_tests.run_tests(newToken, accounts);
});

contract('FiatToken_LegacyTests_Upgraded', async function (accounts) {
await legacy_tests.run_tests(newUpgradedToken, accounts);
});

contract('FiatToken_EventTests', async function () {
await events_tests.run_tests(newToken);
});
return;
}

contract('FiatToken_EventTests_Upgraded', async function () {
await events_tests.run_tests(newUpgradedToken);
});
module.exports = {
execute: execute
}