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

update more packages to AVA #1594

Merged
merged 4 commits into from
Aug 23, 2020
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
16 changes: 12 additions & 4 deletions packages/install-metering-and-ses/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
"main": "install-metering-and-ses.js",
"scripts": {
"build": "exit 0",
"test": "tap --no-coverage --jobs=1 'test*.js'",
"test": "ava",
"lint-fix": "eslint --fix '**/*.js'",
"lint-check": "eslint '**/*.js'"
},
"devDependencies": {
"@agoric/eventual-send": "^0.9.3",
"@agoric/transform-metering": "^1.3.0",
"esm": "^3.2.5",
"tap": "^14.10.5",
"tape": "^4.13.2"
"ava": "^3.11.1",
"esm": "^3.2.5"
},
"dependencies": {
"@agoric/eventual-send": "^0.9.3",
Expand Down Expand Up @@ -78,5 +77,14 @@
},
"publishConfig": {
"access": "public"
},
"ava": {
"files": [
"test/**/test-*.js"
],
"require": [
"esm"
],
"timeout": "2m"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* global Compartment harden */
import './install-metering-and-ses';
import test from 'tape';
import '../install-metering-and-ses';
import test from 'ava';
import { makeMeter } from '@agoric/transform-metering';

// I don't know how to test that replaceGlobalMeter already exists, because
Expand All @@ -16,15 +16,14 @@ import { tameMetering } from '@agoric/tame-metering';
const replaceGlobalMeter = tameMetering();

test('SES globals are present', t => {
t.equal(typeof Compartment, 'function');
t.equal(typeof harden, 'function');
t.end();
t.is(typeof Compartment, 'function');
t.is(typeof harden, 'function');
});

test('can replaceGlobalMeter', t => {
const { meter } = makeMeter();
const oldMeter = replaceGlobalMeter(meter);
t.isNot(meter, oldMeter);
t.not(meter, oldMeter);
// provoke some globals
const a = [];
a.length = 10;
Expand All @@ -33,5 +32,4 @@ test('can replaceGlobalMeter', t => {
t.is(meter, newMeter);
// TODO: once meters provide an API to read out their value, assert that
// the value changed at all
t.end();
});
17 changes: 12 additions & 5 deletions packages/registrar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"scripts": {
"build": "exit 0",
"test": "tape -r esm 'test/**/test*.js' | tap-spec",
"test": "ava",
"lint-fix": "eslint --fix '**/*.js'",
"lint-check": "eslint '**/*.js'",
"lint-fix-jessie": "eslint -c '.eslintrc-jessie.js' --fix '**/*.js'",
Expand All @@ -31,10 +31,8 @@
},
"devDependencies": {
"@agoric/install-ses": "^0.2.0",
"esm": "^3.2.25",
"tap-spec": "^5.0.0",
"tape": "^4.11.0",
"tape-promise": "^4.0.0"
"ava": "^3.11.1",
"esm": "^3.2.25"
},
"files": [
"src/",
Expand Down Expand Up @@ -84,5 +82,14 @@
},
"publishConfig": {
"access": "public"
},
"ava": {
"files": [
"test/**/test-*.js"
],
"require": [
"esm"
],
"timeout": "2m"
}
}
90 changes: 39 additions & 51 deletions packages/registrar/test/unitTests/test-registrar.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,49 @@
import '@agoric/install-ses';
import { test } from 'tape-promise/tape';
import test from 'ava';
import { makeRegistrar } from '../../src/registrar';

test('Registrar operations', async t => {
try {
const registrarService = makeRegistrar('testnet');
const obj1 = {};
const obj2 = {};
const id1 = registrarService.register('myname', obj1);
t.assert(id1.match(/^myname_\d{4,}$/), 'id1 is correct format');
const id2 = registrarService.register('myname', obj2);
t.assert(id2.match(/^myname_\d{4,}$/), 'id2 is correct format');
t.isNot(id2, id1, 'ids for different objects are different');
const id1a = registrarService.register('myname', obj1);
t.assert(id1a.match(/^myname_\d{4,}$/), 'id1a is correct format');
t.isNot(id1a, id1, 'ids for same object are different');
const id1b = registrarService.register('othername', obj1);
t.assert(id1b.match(/^othername_\d{4,}$/), 'id1b is correct format');
const ret1 = registrarService.get(id1);
t.equals(ret1, obj1, 'returned obj1 is equal');
const ret2 = registrarService.get(id2);
t.equals(ret2, obj2, 'returned obj2 is equal');
const ret1a = registrarService.get(id1a);
t.equals(ret1a, obj1, 'returned obj1a is equal');
const ret1b = registrarService.get(id1b);
t.equals(ret1b, obj1, 'returned obj1b is equal');
const registrarService = makeRegistrar('testnet');
const obj1 = {};
const obj2 = {};
const id1 = registrarService.register('myname', obj1);
t.assert(id1.match(/^myname_\d{4,}$/), 'id1 is correct format');
const id2 = registrarService.register('myname', obj2);
t.assert(id2.match(/^myname_\d{4,}$/), 'id2 is correct format');
t.not(id2, id1, 'ids for different objects are different');
const id1a = registrarService.register('myname', obj1);
t.assert(id1a.match(/^myname_\d{4,}$/), 'id1a is correct format');
t.not(id1a, id1, 'ids for same object are different');
const id1b = registrarService.register('othername', obj1);
t.assert(id1b.match(/^othername_\d{4,}$/), 'id1b is correct format');
const ret1 = registrarService.get(id1);
t.is(ret1, obj1, 'returned obj1 is equal');
const ret2 = registrarService.get(id2);
t.is(ret2, obj2, 'returned obj2 is equal');
const ret1a = registrarService.get(id1a);
t.is(ret1a, obj1, 'returned obj1a is equal');
const ret1b = registrarService.get(id1b);
t.is(ret1b, obj1, 'returned obj1b is equal');

t.equals(registrarService.keys().length, 4, 'number of keys is expected');
} catch (e) {
t.isNot(e, e, 'unexpected exception');
} finally {
t.end();
}
t.is(registrarService.keys().length, 4, 'number of keys is expected');
});

test('Registrar collisions', async t => {
try {
const registrarService = makeRegistrar('collide');
const iterations = 3000;
const myobj = {};
let maxlength = Number.NEGATIVE_INFINITY;
for (let i = 0; i < iterations; i += 1) {
const id = registrarService.register('a', myobj);
maxlength = Math.max(maxlength, id.length);
}
t.equals(maxlength, 7, 'expected maximum key length');

const keys = registrarService.keys();
t.equals(keys.length, iterations, 'expected number of keys');
t.equals(
keys.filter(key => registrarService.get(key) !== myobj).length,
0,
'expected no deviations',
);
} catch (e) {
t.isNot(e, e, 'unexpected exception');
} finally {
t.end();
const registrarService = makeRegistrar('collide');
const iterations = 3000;
const myobj = {};
let maxlength = Number.NEGATIVE_INFINITY;
for (let i = 0; i < iterations; i += 1) {
const id = registrarService.register('a', myobj);
maxlength = Math.max(maxlength, id.length);
}
t.is(maxlength, 7, 'expected maximum key length');

const keys = registrarService.keys();
t.is(keys.length, iterations, 'expected number of keys');
t.is(
keys.filter(key => registrarService.get(key) !== myobj).length,
0,
'expected no deviations',
);
});
15 changes: 11 additions & 4 deletions packages/same-structure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@
"@agoric/marshal": "^0.2.3"
},
"devDependencies": {
"esm": "^3.2.25",
"tap-spec": "^5.0.0",
"tape": "^4.11.0",
"tape-promise": "^4.0.0"
"ava": "^3.11.1",
"esm": "^3.2.25"
},
"files": [
"src/",
Expand Down Expand Up @@ -86,5 +84,14 @@
},
"publishConfig": {
"access": "public"
},
"ava": {
"files": [
"test/**/test-*.js"
],
"require": [
"esm"
],
"timeout": "2m"
}
}
15 changes: 11 additions & 4 deletions packages/stat-logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,19 @@
"vega-canvas": "^1.2.1"
},
"devDependencies": {
"esm": "^3.2.25",
"tap-spec": "^5.0.0",
"tape": "^4.10.2",
"tape-promise": "^4.0.0"
"ava": "^3.11.1",
"esm": "^3.2.25"
},
"publishConfig": {
"access": "public"
},
"ava": {
"files": [
"test/**/test-*.js"
],
"require": [
"esm"
],
"timeout": "2m"
}
}
Loading