Skip to content

Commit

Permalink
fix: remove t.end() from Zoe tests and use t.plan() instead
Browse files Browse the repository at this point in the history
  • Loading branch information
katelynsills committed Mar 25, 2020
1 parent f1db0d9 commit b4e12a5
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@ async function main(basedir, withSES, argv) {

const infiniteInstallLoopLog = ['installing infiniteInstallLoop'];
test('zoe - metering - infinite loop in installation', async t => {
t.plan(1);
try {
const dump = await main('zoe-metering', true, ['infiniteInstallLoop']);
t.deepEquals(dump.log, infiniteInstallLoopLog, 'log is correct');
} catch (e) {
t.isNot(e, e, 'unexpected exception');
} finally {
t.end();
}
});

Expand All @@ -56,13 +55,12 @@ const infiniteInstanceLoopLog = [
'instantiating infiniteInstanceLoop',
];
test('zoe - metering - infinite loop in instantiation', async t => {
t.plan(1);
try {
const dump = await main('zoe-metering', true, ['infiniteInstanceLoop']);
t.deepEquals(dump.log, infiniteInstanceLoopLog, 'log is correct');
} catch (e) {
t.isNot(e, e, 'unexpected exception');
} finally {
t.end();
}
});

Expand All @@ -72,13 +70,12 @@ const infiniteTestLoopLog = [
'invoking infiniteTestLoop.doTest()',
];
test('zoe - metering - infinite loop in contract method', async t => {
t.plan(1);
try {
const dump = await main('zoe-metering', true, ['infiniteTestLoop']);
t.deepEquals(dump.log, infiniteTestLoopLog, 'log is correct');
} catch (e) {
t.isNot(e, e, 'unexpected exception');
} finally {
t.end();
}
});

Expand All @@ -88,12 +85,11 @@ const testBuiltinsLog = [
'invoking testBuiltins.doTest()',
];
test('zoe - metering - expensive builtins in contract method', async t => {
t.plan(1);
try {
const dump = await main('zoe-metering', true, ['testBuiltins']);
t.deepEquals(dump.log, testBuiltinsLog, 'log is correct');
} catch (e) {
t.isNot(e, e, 'unexpected exception');
} finally {
t.end();
}
});
18 changes: 6 additions & 12 deletions packages/zoe/test/swingsetTests/zoe/test-zoe.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const expectedAutomaticRefundOkLog = [
];

test('zoe - automaticRefund - valid inputs - with SES', async t => {
t.plan(1);
try {
const startingExtents = [
[3, 0, 0],
Expand All @@ -66,8 +67,6 @@ test('zoe - automaticRefund - valid inputs - with SES', async t => {
t.deepEquals(dump.log, expectedAutomaticRefundOkLog);
} catch (e) {
t.isNot(e, e, 'unexpected exception');
} finally {
t.end();
}
});

Expand All @@ -83,6 +82,7 @@ const expectedCoveredCallOkLog = [
];

test('zoe - coveredCall - valid inputs - with SES', async t => {
t.plan(1);
try {
const startingExtents = [
[3, 0, 0],
Expand All @@ -92,8 +92,6 @@ test('zoe - coveredCall - valid inputs - with SES', async t => {
t.deepEquals(dump.log, expectedCoveredCallOkLog);
} catch (e) {
t.isNot(e, e, 'unexpected exception');
} finally {
t.end();
}
});

Expand All @@ -116,6 +114,7 @@ const expectedSwapForOptionOkLog = [
];

test('zoe - swapForOption - valid inputs - with SES', async t => {
t.plan(1);
try {
const startingExtents = [
[3, 0, 0], // Alice starts with 3 moola
Expand All @@ -127,8 +126,6 @@ test('zoe - swapForOption - valid inputs - with SES', async t => {
t.deepEquals(dump.log, expectedSwapForOptionOkLog);
} catch (e) {
t.isNot(e, e, 'unexpected exception');
} finally {
t.end();
}
});

Expand All @@ -148,6 +145,7 @@ const expectedPublicAuctionOkLog = [
'aliceSimoleanPurse: balance {"brand":{},"extent":7}',
];
test('zoe - publicAuction - valid inputs - with SES', async t => {
t.plan(1);
try {
const startingExtents = [
[1, 0, 0],
Expand All @@ -159,8 +157,6 @@ test('zoe - publicAuction - valid inputs - with SES', async t => {
t.deepEquals(dump.log, expectedPublicAuctionOkLog);
} catch (e) {
t.isNot(e, e, 'unexpected exception');
} finally {
t.end();
}
});

Expand All @@ -173,6 +169,7 @@ const expectedAtomicSwapOkLog = [
'bobSimoleanPurse: balance {"brand":{},"extent":0}',
];
test('zoe - atomicSwap - valid inputs - with SES', async t => {
t.plan(1);
try {
const startingExtents = [
[3, 0, 0],
Expand All @@ -182,8 +179,6 @@ test('zoe - atomicSwap - valid inputs - with SES', async t => {
t.deepEquals(dump.log, expectedAtomicSwapOkLog);
} catch (e) {
t.isNot(e, e, 'unexpected exception');
} finally {
t.end();
}
});

Expand All @@ -198,6 +193,7 @@ const expectedSimpleExchangeOkLog = [
];

test('zoe - simpleExchange - valid inputs - with SES', async t => {
t.plan(1);
try {
const startingExtents = [
[3, 0, 0],
Expand All @@ -207,8 +203,6 @@ test('zoe - simpleExchange - valid inputs - with SES', async t => {
t.deepEquals(dump.log, expectedSimpleExchangeOkLog);
} catch (e) {
t.isNot(e, e, 'unexpected exception');
} finally {
t.end();
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const testGetPrice = (t, input, expectedOutput) => {
};

test('getPrice ok 1', t => {
t.plan(1);
try {
const input = {
inputReserve: 0,
Expand All @@ -27,12 +28,11 @@ test('getPrice ok 1', t => {
testGetPrice(t, input, expectedOutput);
} catch (e) {
t.assert(false, e);
} finally {
t.end();
}
});

test('getPrice ok 2', t => {
t.plan(1);
try {
const input = {
inputReserve: 5984,
Expand All @@ -47,12 +47,11 @@ test('getPrice ok 2', t => {
testGetPrice(t, input, expectedOutput);
} catch (e) {
t.assert(false, e);
} finally {
t.end();
}
});

test('getPrice ok 3', t => {
t.plan(1);
try {
const input = {
inputReserve: 8160,
Expand All @@ -67,12 +66,11 @@ test('getPrice ok 3', t => {
testGetPrice(t, input, expectedOutput);
} catch (e) {
t.assert(false, e);
} finally {
t.end();
}
});

test('getPrice reverse x and y amounts', t => {
t.plan(1);
try {
// Note: this is now the same test as the one above because we are
// only using extents
Expand All @@ -89,12 +87,11 @@ test('getPrice reverse x and y amounts', t => {
testGetPrice(t, input, expectedOutput);
} catch (e) {
t.assert(false, e);
} finally {
t.end();
}
});

test('getPrice ok 4', t => {
t.plan(1);
try {
const input = {
inputReserve: 10,
Expand All @@ -109,7 +106,5 @@ test('getPrice ok 4', t => {
testGetPrice(t, input, expectedOutput);
} catch (e) {
t.assert(false, e);
} finally {
t.end();
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { test } from 'tape-promise/tape';
import { makeStateMachine } from '../../../../src/contracts/helpers/stateMachine';

test('stateMachine', t => {
t.plan(4);
try {
const startState = 'empty';
const allowedTransitions = [
Expand All @@ -22,7 +23,5 @@ test('stateMachine', t => {
t.equal(stateMachine.getStatus(), 'open');
} catch (e) {
t.assert(false, e);
} finally {
t.end();
}
});
Loading

0 comments on commit b4e12a5

Please sign in to comment.