@agoric/cache 0.3.3-dev-803e785.0.803e785 → 0.3.3-dev-6727d47.0.6727d47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/cache",
3
- "version": "0.3.3-dev-803e785.0.803e785",
3
+ "version": "0.3.3-dev-6727d47.0.6727d47",
4
4
  "description": "Agoric's simple cache interface",
5
5
  "type": "module",
6
6
  "main": "src/main.js",
@@ -19,18 +19,21 @@
19
19
  "author": "Agoric",
20
20
  "license": "Apache-2.0",
21
21
  "dependencies": {
22
- "@agoric/internal": "0.3.3-dev-803e785.0.803e785",
23
- "@agoric/notifier": "0.6.3-dev-803e785.0.803e785",
24
- "@agoric/store": "0.9.3-dev-803e785.0.803e785",
25
- "@agoric/vat-data": "0.5.3-dev-803e785.0.803e785",
22
+ "@agoric/internal": "0.3.3-dev-6727d47.0.6727d47",
23
+ "@agoric/notifier": "0.6.3-dev-6727d47.0.6727d47",
24
+ "@agoric/store": "0.9.3-dev-6727d47.0.6727d47",
25
+ "@agoric/vat-data": "0.5.3-dev-6727d47.0.6727d47",
26
26
  "@endo/far": "^1.1.14",
27
27
  "@endo/marshal": "^1.8.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@agoric/zoe": "0.26.3-dev-803e785.0.803e785",
30
+ "@agoric/zoe": "0.26.3-dev-6727d47.0.6727d47",
31
31
  "ava": "^6.4.1",
32
32
  "c8": "^10.1.3"
33
33
  },
34
+ "files": [
35
+ "src"
36
+ ],
34
37
  "publishConfig": {
35
38
  "access": "public"
36
39
  },
@@ -49,5 +52,5 @@
49
52
  "typeCoverage": {
50
53
  "atLeast": 94.13
51
54
  },
52
- "gitHead": "803e785954402887190ee2ebabd6e7980feed10f"
55
+ "gitHead": "6727d47e6970be1f992aa904cd964abdfef00a83"
53
56
  }
package/CHANGELOG.md DELETED
@@ -1,80 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ### [0.3.2](https://github.com/Agoric/agoric-sdk/compare/@agoric/cache@0.3.1...@agoric/cache@0.3.2) (2023-06-02)
7
-
8
- **Note:** Version bump only for package @agoric/cache
9
-
10
-
11
-
12
-
13
-
14
- ### [0.3.1](https://github.com/Agoric/agoric-sdk/compare/@agoric/cache@0.3.0...@agoric/cache@0.3.1) (2023-05-24)
15
-
16
- **Note:** Version bump only for package @agoric/cache
17
-
18
-
19
-
20
-
21
-
22
- ## [0.3.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/cache@0.2.3...@agoric/cache@0.3.0) (2023-05-19)
23
-
24
-
25
- ### ⚠ BREAKING CHANGES
26
-
27
- * emit smallcaps-format data in all marshallers
28
- * remove storeName parameter
29
-
30
- ### Features
31
-
32
- * emit smallcaps-format data in all marshallers ([1753df8](https://github.com/Agoric/agoric-sdk/commit/1753df83465785b5ee71b250770c9b012d750ffc)), closes [#6822](https://github.com/Agoric/agoric-sdk/issues/6822)
33
-
34
-
35
- ### Miscellaneous Chores
36
-
37
- * remove storeName parameter ([452f9bc](https://github.com/Agoric/agoric-sdk/commit/452f9bc680d4f54bed5608eb0d7cf67d80d87ba0))
38
-
39
-
40
-
41
- ### [0.2.4](https://github.com/Agoric/agoric-sdk/compare/@agoric/cache@0.2.3...@agoric/cache@0.2.4) (2023-02-17)
42
-
43
- **Note:** Version bump only for package @agoric/cache
44
-
45
-
46
-
47
-
48
-
49
- ### [0.2.3](https://github.com/Agoric/agoric-sdk/compare/@agoric/cache@0.2.2...@agoric/cache@0.2.3) (2022-10-18)
50
-
51
- **Note:** Version bump only for package @agoric/cache
52
-
53
-
54
-
55
-
56
-
57
- ### [0.2.2](https://github.com/Agoric/agoric-sdk/compare/@agoric/cache@0.2.1...@agoric/cache@0.2.2) (2022-10-08)
58
-
59
- **Note:** Version bump only for package @agoric/cache
60
-
61
-
62
-
63
-
64
-
65
- ### [0.2.1](https://github.com/Agoric/agoric-sdk/compare/@agoric/cache@0.2.0...@agoric/cache@0.2.1) (2022-10-05)
66
-
67
- **Note:** Version bump only for package @agoric/cache
68
-
69
-
70
-
71
-
72
-
73
- ## 0.2.0 (2022-09-20)
74
-
75
-
76
- ### Features
77
-
78
- * **cache:** makeChainStorageCoordinator ([a9b8f3e](https://github.com/Agoric/agoric-sdk/commit/a9b8f3ebe4ff3e25c857426781ae5c403198f234))
79
- * **cache:** new `@agoric/cache` implementation ([0626796](https://github.com/Agoric/agoric-sdk/commit/06267961d3de36b1ddd04d9a6345775846056755))
80
- * **cache:** send the updater to the coordinator, not client loop ([23b94b1](https://github.com/Agoric/agoric-sdk/commit/23b94b1ebd176a7f7ae90ca64d2252ed348e8836))
package/test/mvp.test.js DELETED
@@ -1,40 +0,0 @@
1
- // Must be first to set up globals
2
- import { test } from '@agoric/zoe/tools/prepare-test-env-ava.js';
3
- import { M } from '@agoric/store';
4
- import { makeScalarBigMapStore } from '@agoric/vat-data';
5
-
6
- import { makeCache } from '../src/cache.js';
7
- import { makeScalarStoreCoordinator } from '../src/store.js';
8
-
9
- // Taken from the README.
10
- test('mvp happy path', async t => {
11
- const store = makeScalarBigMapStore('cache');
12
- const coordinator = makeScalarStoreCoordinator(store);
13
- const cache = makeCache(coordinator);
14
-
15
- // Direct value manipulation.
16
- t.is(await cache('baz'), undefined);
17
- t.is(await cache('baz', 'barbosa'), 'barbosa');
18
-
19
- // Match-and-set.
20
- t.is(await cache('baz', 'babaloo', undefined), 'barbosa');
21
- t.is(await cache('baz', 'babaloo', 'barbosa'), 'babaloo');
22
-
23
- // One-time initialization.
24
- t.is(await cache('frotz', 'default'), 'default');
25
- t.is(await cache('frotz', 'ignored'), 'default');
26
-
27
- // Update function for the `'foo'` entry, using its old value (initially `undefined`).
28
- t.is(await cache('foo'), undefined);
29
- const updater = (oldValue = 'bar') => `${oldValue}1`;
30
- t.is(await cache('foo', updater, M.any()), 'bar1');
31
- t.is(await cache('foo', updater, M.any()), 'bar11');
32
- t.is(await cache('foo'), 'bar11');
33
-
34
- // You can also specify a guard pattern for the value to update. If it
35
- // doesn't match the latest value, then the cache isn't updated.
36
- t.is(await cache('foo', updater, 'nomatch'), 'bar11');
37
- t.is(await cache('foo', updater, 'bar11'), 'bar111');
38
- t.is(await cache('foo', updater, 'bar11'), 'bar111');
39
- t.is(await cache('foo'), 'bar111');
40
- });
@@ -1,187 +0,0 @@
1
- // Must be first to set up globals
2
- import '@agoric/zoe/tools/prepare-test-env.js';
3
-
4
- import test from 'ava';
5
- import { makeChainStorageRoot } from '@agoric/internal/src/lib-chainStorage.js';
6
-
7
- import { Far, makeMarshal } from '@endo/marshal';
8
- import { M } from '@agoric/store';
9
- import { makeCache } from '../src/cache.js';
10
- import { makeChainStorageCoordinator } from '../src/store.js';
11
-
12
- const makeSimpleMarshaller = () => {
13
- const vals = [];
14
- const fromVal = val => {
15
- vals.push(val);
16
- return vals.length - 1;
17
- };
18
- const toVal = slot => vals[slot];
19
- return makeMarshal(fromVal, toVal, {
20
- serializeBodyFormat: 'smallcaps',
21
- marshalSaveError: err => {
22
- throw err;
23
- },
24
- });
25
- };
26
- harden(makeSimpleMarshaller);
27
-
28
- const setup = () => {
29
- const storageNodeState = {};
30
- const chainStorage = makeChainStorageRoot(
31
- Far('ToStorage', message => {
32
- assert(message.method === 'set');
33
- assert(message.args.length === 1);
34
- const [[path, value]] = message.args;
35
- assert(path === 'cache');
36
- storageNodeState.cache = value;
37
- }),
38
- 'cache',
39
- );
40
- const cache = makeCache(
41
- makeChainStorageCoordinator(chainStorage, makeSimpleMarshaller()),
42
- );
43
- return { cache, storageNodeState };
44
- };
45
-
46
- test('makeChainStorageCoordinator with non-remote values', async t => {
47
- const { cache, storageNodeState } = setup();
48
-
49
- t.is(await cache('brandName', 'barbosa'), 'barbosa');
50
- t.deepEqual(Object.keys(storageNodeState), ['cache']);
51
- t.deepEqual(JSON.parse(storageNodeState.cache), {
52
- '{"body":"#\\"brandName\\"","slots":[]}': {
53
- body: '#{"generation":"+1","value":"barbosa"}',
54
- slots: [],
55
- },
56
- });
57
-
58
- // One-time initialization (of 'frotz')
59
- t.is(await cache('frotz', 'default'), 'default');
60
- const afterFirstFrotz = {
61
- '{"body":"#\\"brandName\\"","slots":[]}': {
62
- body: '#{"generation":"+1","value":"barbosa"}',
63
- slots: [],
64
- },
65
- '{"body":"#\\"frotz\\"","slots":[]}': {
66
- body: '#{"generation":"+1","value":"default"}',
67
- slots: [],
68
- },
69
- };
70
- t.deepEqual(JSON.parse(storageNodeState.cache), afterFirstFrotz);
71
- // no change
72
- t.is(await cache('frotz', 'ignored'), 'default');
73
- t.deepEqual(JSON.parse(storageNodeState.cache), afterFirstFrotz);
74
-
75
- // cache more complex Passable
76
- const complexPassable = {
77
- str: 'string',
78
- big: 1n,
79
- num: 53,
80
- arr: ['hi', 'there'],
81
- };
82
- t.deepEqual(
83
- await cache(['complex', 'passable'], complexPassable),
84
- complexPassable,
85
- );
86
- t.deepEqual(JSON.parse(storageNodeState.cache), {
87
- ...afterFirstFrotz,
88
- '{"body":"#[\\"complex\\",\\"passable\\"]","slots":[]}': {
89
- body: '#{"generation":"+1","value":{"arr":["hi","there"],"big":"+1","num":53,"str":"string"}}',
90
- slots: [],
91
- },
92
- });
93
- });
94
-
95
- test('makeChainStorageCoordinator with remote values', async t => {
96
- const { cache, storageNodeState } = setup();
97
-
98
- const farThing = Far('farThing', { getAllegedName: () => 'dollaz' });
99
-
100
- t.is(await cache('brand', farThing), farThing);
101
- t.deepEqual(Object.keys(storageNodeState), ['cache']);
102
- t.deepEqual(JSON.parse(storageNodeState.cache), {
103
- '{"body":"#\\"brand\\"","slots":[]}': {
104
- body: '#{"generation":"+1","value":"$0.Alleged: farThing"}',
105
- slots: [0],
106
- },
107
- });
108
- });
109
-
110
- test('makeChainStorageCoordinator with updater', async t => {
111
- const { cache, storageNodeState } = setup();
112
-
113
- const increment = (counter = 0) => Promise.resolve(counter + 1);
114
-
115
- // Initial
116
- t.is(await cache('counter', increment), 1);
117
- t.deepEqual(Object.keys(storageNodeState), ['cache']);
118
- t.deepEqual(JSON.parse(storageNodeState.cache), {
119
- '{"body":"#\\"counter\\"","slots":[]}': {
120
- body: '#{"generation":"+1","value":1}',
121
- slots: [],
122
- },
123
- });
124
-
125
- // Again without a pattern
126
- t.is(await cache('counter', increment), 1);
127
- t.deepEqual(Object.keys(storageNodeState), ['cache']);
128
- t.deepEqual(JSON.parse(storageNodeState.cache), {
129
- '{"body":"#\\"counter\\"","slots":[]}': {
130
- body: '#{"generation":"+1","value":1}',
131
- slots: [],
132
- },
133
- });
134
-
135
- // Again with a matching pattern
136
- t.is(await cache('counter', increment, M.any()), 2);
137
- t.deepEqual(Object.keys(storageNodeState), ['cache']);
138
- t.deepEqual(JSON.parse(storageNodeState.cache), {
139
- '{"body":"#\\"counter\\"","slots":[]}': {
140
- body: '#{"generation":"+2","value":2}',
141
- slots: [],
142
- },
143
- });
144
- });
145
-
146
- test('makeChainStorageCoordinator with remote updater', async t => {
147
- const { cache, storageNodeState } = setup();
148
-
149
- let counter = 0;
150
- const counterObj = Far('counterObj', {
151
- increment: () => {
152
- return (counter += 1);
153
- },
154
- });
155
-
156
- // Initial
157
- t.is(await cache('counter', counterObj.increment), 1);
158
- t.deepEqual(Object.keys(storageNodeState), ['cache']);
159
- t.deepEqual(JSON.parse(storageNodeState.cache), {
160
- '{"body":"#\\"counter\\"","slots":[]}': {
161
- body: '#{"generation":"+1","value":1}',
162
- slots: [],
163
- },
164
- });
165
-
166
- // Again without a pattern, doesn't increment
167
- t.is(await cache('counter', counterObj.increment), 1);
168
- t.is(counter, 1);
169
- t.deepEqual(Object.keys(storageNodeState), ['cache']);
170
- t.deepEqual(JSON.parse(storageNodeState.cache), {
171
- '{"body":"#\\"counter\\"","slots":[]}': {
172
- body: '#{"generation":"+1","value":1}',
173
- slots: [],
174
- },
175
- });
176
-
177
- // Again with a matching pattern
178
- t.is(await cache('counter', counterObj.increment, M.any()), 2);
179
- t.is(counter, 2);
180
- t.deepEqual(Object.keys(storageNodeState), ['cache']);
181
- t.deepEqual(JSON.parse(storageNodeState.cache), {
182
- '{"body":"#\\"counter\\"","slots":[]}': {
183
- body: '#{"generation":"+2","value":2}',
184
- slots: [],
185
- },
186
- });
187
- });
package/tsconfig.json DELETED
@@ -1,11 +0,0 @@
1
- // This file can contain .js-specific Typescript compiler config.
2
- {
3
- "extends": "../../tsconfig.json",
4
- "compilerOptions": {},
5
- "include": [
6
- "*.js",
7
- "public/**/*.js",
8
- "src/**/*.js",
9
- "test/**/*.js",
10
- ],
11
- }