Skip to content

Commit

Permalink
fix: upgrade to polycrc that supports safe integers
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Sep 6, 2020
1 parent afaadfc commit b7674c6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
6 changes: 3 additions & 3 deletions packages/cosmic-swingset/lib/ag-solo/vats/lib-board.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import { generateSparseInts } from '@agoric/sparse-ints';
import { assert, details, q } from '@agoric/assert';
import makeStore from '@agoric/store';
import polycrc from '@agoric/polycrc';
import polycrc from 'polycrc';

const { crc6 } = polycrc;

const CRC_NUM_DIGITS = 2;
const ID_REGEXP = new RegExp(`^[1-9][0-9]{${CRC_NUM_DIGITS},}$`);
const ID_REGEXP = new RegExp(`^[0-9]{${CRC_NUM_DIGITS + 1},}$`);

/**
* We calculate a CRC, ensuring it's of CRC_NUM_DIGITS length.
Expand Down Expand Up @@ -54,7 +54,7 @@ function makeBoard(seed = 0) {
let id;
do {
const num = sparseInts.next().value;
id = `${num.toString()}${calcCrc(num)}`;
id = `${num}${calcCrc(num)}`;
} while (idToVal.has(id));

valToId.init(value, id);
Expand Down
2 changes: 1 addition & 1 deletion packages/cosmic-swingset/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"@agoric/marshal": "^0.2.4",
"@agoric/nat": "2.0.1",
"@agoric/notifier": "^0.2.0",
"@agoric/polycrc": "^0.1.1",
"@agoric/promise-kit": "^0.1.4",
"@agoric/registrar": "^0.1.4",
"@agoric/same-structure": "^0.0.9",
Expand Down Expand Up @@ -60,6 +59,7 @@
"n-readlines": "^1.0.0",
"node-fetch": "^2.6.0",
"node-lmdb": "^0.8.0",
"polycrc": "https://github.com/agoric-labs/node-polycrc",
"rollup": "^1.26.2",
"rollup-plugin-node-resolve": "^5.2.0",
"temp": "^0.9.1",
Expand Down
5 changes: 5 additions & 0 deletions packages/cosmic-swingset/test/test-home.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ test.serial('home.board', async t => {
{ message: /board does not have id/ },
`getting a value for a fake id throws`,
);
await t.throwsAsync(
() => E(board).getValue('0000000000'),
{ message: /id is probably a typo/ },
`using a non-verified id throws`,
);

const myValue = {};
const myId = await E(board).getId(myValue);
Expand Down
1 change: 0 additions & 1 deletion packages/install-metering-and-ses/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"lint-check": "eslint '**/*.js'"
},
"devDependencies": {
"@agoric/eventual-send": "^0.9.3",
"@agoric/transform-metering": "^1.3.1",
"ava": "^3.11.1",
"esm": "^3.2.5"
Expand Down
9 changes: 4 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@
resolved "https://registry.yarnpkg.com/@agoric/nat/-/nat-2.0.1.tgz#28aba18367deba354bdd424bdf6daa48f5e7d37f"
integrity sha512-puvWkoaJovQib/YaSRSGJ8Kn9rogi/yyaVa3d5znSZb5WiYfUiEKW35BfexHhAdi0VfPz2anFHoRBoBSUIijNA==

"@agoric/polycrc@^0.1.1":
version "0.1.1"
resolved "https://registry.yarnpkg.com/@agoric/polycrc/-/polycrc-0.1.1.tgz#acd868265db960c17926ac608434634851edbcbf"
integrity sha512-3wYc/67b3to++DtwM9DXRaETps/lxI/XJjPnExo/uiQwZEAbo3Hi0MG3t/ogtHBsrCPbvqOosYAP1/G22qvsCw==

"@agoric/transform-module@^0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@agoric/transform-module/-/transform-module-0.3.0.tgz#da0c4ba3b200e270db32ac5d8a56d4f5c955b89d"
Expand Down Expand Up @@ -7418,6 +7413,10 @@ plur@^4.0.0:
dependencies:
irregular-plurals "^3.2.0"

"polycrc@https://github.com/agoric-labs/node-polycrc":
version "1.0.1-agoric"
resolved "https://github.com/agoric-labs/node-polycrc#f396a902c5ba663cb91b6c8c13ec0afe792108d0"

posix-character-classes@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"
Expand Down

0 comments on commit b7674c6

Please sign in to comment.