@agoric/zone 0.2.3-dev-129bb20.0 → 0.2.3-dev-4841c87.0
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 +5 -5
- package/test/exos.test.js +78 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/zone",
|
|
3
|
-
"version": "0.2.3-dev-
|
|
3
|
+
"version": "0.2.3-dev-4841c87.0+4841c87",
|
|
4
4
|
"description": "Allocation zone abstraction for objects on the heap, persistent stores, etc.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": "https://github.com/Agoric/agoric-sdk",
|
|
@@ -27,14 +27,14 @@
|
|
|
27
27
|
"author": "Agoric",
|
|
28
28
|
"license": "Apache-2.0",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@agoric/base-zone": "0.1.1-dev-
|
|
31
|
-
"@agoric/vat-data": "0.5.3-dev-
|
|
30
|
+
"@agoric/base-zone": "0.1.1-dev-4841c87.0+4841c87",
|
|
31
|
+
"@agoric/vat-data": "0.5.3-dev-4841c87.0+4841c87",
|
|
32
32
|
"@endo/errors": "^1.2.10",
|
|
33
33
|
"@endo/far": "^1.1.11",
|
|
34
34
|
"@endo/pass-style": "^1.5.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@agoric/swingset-vat": "0.32.3-dev-
|
|
37
|
+
"@agoric/swingset-vat": "0.32.3-dev-4841c87.0+4841c87",
|
|
38
38
|
"@endo/patterns": "^1.5.0",
|
|
39
39
|
"ava": "^5.3.0"
|
|
40
40
|
},
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"typeCoverage": {
|
|
58
58
|
"atLeast": 98.56
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "4841c8738923019bcbd3e4d41900381ba677d55f"
|
|
61
61
|
}
|
package/test/exos.test.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { M } from '@endo/patterns';
|
|
1
2
|
import {
|
|
2
3
|
annihilate,
|
|
3
4
|
getBaggage,
|
|
@@ -123,3 +124,80 @@ test.serial('vatData migrate to durableZone', t => {
|
|
|
123
124
|
const baggage2 = getBaggage();
|
|
124
125
|
testSecondZoneIncarnation(t, makeDurableZone(baggage2));
|
|
125
126
|
});
|
|
127
|
+
|
|
128
|
+
test.serial('exoClass stateShape expansion', t => {
|
|
129
|
+
annihilate();
|
|
130
|
+
|
|
131
|
+
// See ../../swingset-liveslots/test/virtual-objects/state-shape.test.js
|
|
132
|
+
const stateShapeMismatch = { message: /stateShape mismatch/ };
|
|
133
|
+
const HolderI = M.interface('Holder', {
|
|
134
|
+
get: M.call().rest(M.arrayOf(M.string())).returns(M.record()),
|
|
135
|
+
set: M.call(M.record()).returns(),
|
|
136
|
+
});
|
|
137
|
+
const initHolder = fields => ({ ...fields });
|
|
138
|
+
const holderMethods = {
|
|
139
|
+
get(...fields) {
|
|
140
|
+
const { state } = this;
|
|
141
|
+
// We require fields to be explicit because they are currently defined on
|
|
142
|
+
// the state *prototype*.
|
|
143
|
+
return Object.fromEntries(
|
|
144
|
+
fields.flatMap(key => (key in state ? [[key, state[key]]] : [])),
|
|
145
|
+
);
|
|
146
|
+
},
|
|
147
|
+
set(fields) {
|
|
148
|
+
Object.assign(this.state, fields);
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
const prepareHolder = (zone, stateShape) =>
|
|
152
|
+
zone.exoClass('Holder', HolderI, initHolder, holderMethods, { stateShape });
|
|
153
|
+
|
|
154
|
+
const fields = ['foo', 'bar', 'baz']; // but "baz" is not initially present
|
|
155
|
+
const baggage1 = getBaggage();
|
|
156
|
+
const zone1 = makeDurableZone(baggage1);
|
|
157
|
+
const makeHolder1 = prepareHolder(zone1, {
|
|
158
|
+
foo: M.number(),
|
|
159
|
+
bar: M.number(),
|
|
160
|
+
});
|
|
161
|
+
const holder1 = makeHolder1({ foo: 0, bar: 1 });
|
|
162
|
+
t.deepEqual(holder1.get(...fields), { foo: 0, bar: 1 });
|
|
163
|
+
holder1.set({ foo: 2, bar: 2 });
|
|
164
|
+
t.deepEqual(holder1.get(...fields), { foo: 2, bar: 2 });
|
|
165
|
+
t.throws(() => makeHolder1({ foo: 0, bar: 1, baz: 2 }));
|
|
166
|
+
t.throws(() => makeHolder1({ foo: 0, bar: 'string' }));
|
|
167
|
+
|
|
168
|
+
nextLife();
|
|
169
|
+
t.throws(
|
|
170
|
+
() =>
|
|
171
|
+
prepareHolder(makeDurableZone(getBaggage()), {
|
|
172
|
+
foo: M.string(),
|
|
173
|
+
bar: M.number(),
|
|
174
|
+
}),
|
|
175
|
+
stateShapeMismatch,
|
|
176
|
+
'backwards-incompatible stateShape change',
|
|
177
|
+
);
|
|
178
|
+
|
|
179
|
+
nextLife();
|
|
180
|
+
t.throws(
|
|
181
|
+
() =>
|
|
182
|
+
prepareHolder(makeDurableZone(getBaggage()), {
|
|
183
|
+
foo: M.or(M.number(), M.string()),
|
|
184
|
+
bar: M.number(),
|
|
185
|
+
baz: M.or(undefined, M.number()),
|
|
186
|
+
}),
|
|
187
|
+
stateShapeMismatch,
|
|
188
|
+
'stateShape field value expansion (needs #7407)',
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
nextLife();
|
|
192
|
+
const baggage2 = getBaggage();
|
|
193
|
+
const zone2 = makeDurableZone(baggage2);
|
|
194
|
+
const makeHolder2 = prepareHolder(zone2, {
|
|
195
|
+
foo: M.number(),
|
|
196
|
+
bar: M.number(),
|
|
197
|
+
baz: M.or(undefined, M.number()),
|
|
198
|
+
});
|
|
199
|
+
const holder2 = makeHolder2({ foo: 0, bar: 1, baz: 2 });
|
|
200
|
+
t.deepEqual(holder2.get(...fields), { foo: 0, bar: 1, baz: 2 });
|
|
201
|
+
holder2.set({ foo: 2, bar: 2, baz: undefined });
|
|
202
|
+
t.deepEqual(holder2.get(...fields), { foo: 2, bar: 2, baz: undefined });
|
|
203
|
+
});
|