@agoric/casting 0.4.3-dev-6d9ae67.0 → 0.4.3-dev-275a1bd.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 +7 -7
- package/src/follower-cosmjs.d.ts.map +1 -1
- package/src/follower-cosmjs.js +10 -5
- package/src/types.d.ts +7 -2
- package/src/types.d.ts.map +1 -1
- package/src/types.js +7 -4
- package/test/test-mvp.js +56 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/casting",
|
|
3
|
-
"version": "0.4.3-dev-
|
|
3
|
+
"version": "0.4.3-dev-275a1bd.0+275a1bd",
|
|
4
4
|
"description": "Agoric's OCap broadcasting system",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/main.js",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"author": "Agoric",
|
|
23
23
|
"license": "Apache-2.0",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@agoric/internal": "0.3.3-dev-
|
|
26
|
-
"@agoric/notifier": "0.6.3-dev-
|
|
27
|
-
"@agoric/spawner": "0.6.9-dev-
|
|
28
|
-
"@agoric/store": "0.9.3-dev-
|
|
25
|
+
"@agoric/internal": "0.3.3-dev-275a1bd.0+275a1bd",
|
|
26
|
+
"@agoric/notifier": "0.6.3-dev-275a1bd.0+275a1bd",
|
|
27
|
+
"@agoric/spawner": "0.6.9-dev-275a1bd.0+275a1bd",
|
|
28
|
+
"@agoric/store": "0.9.3-dev-275a1bd.0+275a1bd",
|
|
29
29
|
"@cosmjs/encoding": "^0.30.1",
|
|
30
30
|
"@cosmjs/proto-signing": "^0.30.1",
|
|
31
31
|
"@cosmjs/stargate": "^0.30.1",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"node-fetch": "^2.6.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@agoric/cosmic-proto": "0.3.1-dev-
|
|
41
|
+
"@agoric/cosmic-proto": "0.3.1-dev-275a1bd.0+275a1bd",
|
|
42
42
|
"@endo/ses-ava": "^0.2.43",
|
|
43
43
|
"@types/node-fetch": "^2.6.2",
|
|
44
44
|
"ava": "^5.3.0",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"typeCoverage": {
|
|
63
63
|
"atLeast": 88.12
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "275a1bd4850ee9ae75db34f1dda3516c3ca766ac"
|
|
66
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"follower-cosmjs.d.ts","sourceRoot":"","sources":["follower-cosmjs.js"],"names":[],"mappings":"AAgGO,+CALI,GAAG,
|
|
1
|
+
{"version":3,"file":"follower-cosmjs.d.ts","sourceRoot":"","sources":["follower-cosmjs.js"],"names":[],"mappings":"AAgGO,+CALI,GAAG,gJAifb;+BA3jByB,OAAO,YAAY,EAAE,QAAQ,CAAC,OAAO,YAAY,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC;;;;;;iCAIxF;IACZ,QAAY,CAAC,KAAK,EAAE,UAAU,CAAC;IAC/B,QAAY,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB"}
|
package/src/follower-cosmjs.js
CHANGED
|
@@ -331,11 +331,16 @@ export const makeCosmjsFollower = (
|
|
|
331
331
|
blockHeight,
|
|
332
332
|
currentBlockHeight,
|
|
333
333
|
) => {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
334
|
+
await null;
|
|
335
|
+
try {
|
|
336
|
+
// AWAIT
|
|
337
|
+
const value = await /** @type {T} */ (
|
|
338
|
+
unserializer ? E(unserializer).fromCapData(data) : data
|
|
339
|
+
);
|
|
340
|
+
return { value, blockHeight, currentBlockHeight };
|
|
341
|
+
} catch (e) {
|
|
342
|
+
return { blockHeight, currentBlockHeight, error: e, value: undefined };
|
|
343
|
+
}
|
|
339
344
|
};
|
|
340
345
|
|
|
341
346
|
/**
|
package/src/types.d.ts
CHANGED
|
@@ -21,11 +21,16 @@ export type Follower<T> = {
|
|
|
21
21
|
getEachIterable: (options?: IterateEachOptions) => Promise<AsyncIterable<T>>;
|
|
22
22
|
getReverseIterable: (options?: IterateEachOptions) => Promise<AsyncIterable<T>>;
|
|
23
23
|
};
|
|
24
|
-
export type
|
|
25
|
-
value: T;
|
|
24
|
+
export type ValueFollowerBase = {
|
|
26
25
|
blockHeight: number;
|
|
27
26
|
currentBlockHeight: number;
|
|
28
27
|
};
|
|
28
|
+
export type ValueFollowerElement<T> = ValueFollowerBase & ({
|
|
29
|
+
value: T;
|
|
30
|
+
} | {
|
|
31
|
+
value: undefined;
|
|
32
|
+
error: any;
|
|
33
|
+
});
|
|
29
34
|
export type Unserializer = Pick<import('@endo/marshal').Marshal<unknown>, 'fromCapData' | 'unserialize'>;
|
|
30
35
|
export type Crasher = {
|
|
31
36
|
crash: (...args: unknown[]) => void;
|
package/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.js"],"names":[],"mappings":"sBAO0B,OAAO,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC;;6BAIvB,MAAM,OAAO,GAAG,YAAY,MAAM,KAAK,QAAQ,IAAI,CAAC;sBAC5D,MAAM,KAAK,QAAQ,IAAI,CAAC;2BACxB,MAAM,KAAK,QAAQ,OAAO,CAAC;;;;YAMnC,UAAU,EAAE;;;mBAKJ,MAAM,SAAS,GAAG,YAAY,MAAM,KAAK,QAAQ,IAAI,CAAC;oBACtD,MAAM,KAAK,QAAQ,IAAI,CAAC;gBAChC,MAAM,aAAa;6BACR,MAAM,uBAAuB,MAAM;yBACvC,KAAK,WAAW,CAAC,KAAK,QAAQ,SAAS,aAAa,CAAC,CAAC;;4BAG7D,KAAK,MAAM,CAAC,GAAG,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;;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ACN,MAAM,CAAC,CAAC"}
|
package/src/types.js
CHANGED
|
@@ -40,14 +40,17 @@ export {};
|
|
|
40
40
|
*/
|
|
41
41
|
|
|
42
42
|
/**
|
|
43
|
-
* @
|
|
44
|
-
* @template T
|
|
45
|
-
* @typedef {object} ValueFollowerElement
|
|
46
|
-
* @property {T} value
|
|
43
|
+
* @typedef {object} ValueFollowerBase
|
|
47
44
|
* @property {number} blockHeight
|
|
48
45
|
* @property {number} currentBlockHeight
|
|
49
46
|
*/
|
|
50
47
|
|
|
48
|
+
/**
|
|
49
|
+
* @see {ChangeFollower}
|
|
50
|
+
* @template T
|
|
51
|
+
* @typedef {ValueFollowerBase & ({ value: T } | { value: undefined, error: any })} ValueFollowerElement
|
|
52
|
+
*/
|
|
53
|
+
|
|
51
54
|
/**
|
|
52
55
|
* @typedef {Pick<import('@endo/marshal').Marshal<unknown>, 'fromCapData' | 'unserialize'>} Unserializer
|
|
53
56
|
*/
|
package/test/test-mvp.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
// eslint-disable-next-line import/order
|
|
3
|
+
import './lockdown.js';
|
|
4
|
+
|
|
5
|
+
import { makeMarshal } from '@endo/marshal';
|
|
3
6
|
import { test } from './prepare-test-env-ava.js';
|
|
4
7
|
|
|
5
8
|
import {
|
|
@@ -167,6 +170,59 @@ test('unrecognized proof', async t => {
|
|
|
167
170
|
);
|
|
168
171
|
});
|
|
169
172
|
|
|
173
|
+
test('yields error on bad capdata without terminating', async t => {
|
|
174
|
+
const marshal = makeMarshal();
|
|
175
|
+
const improperlyMarshalledData = { bad: 'data' };
|
|
176
|
+
const properlyMarshalledData = { foo: 'bar' };
|
|
177
|
+
const fakeValues = [
|
|
178
|
+
improperlyMarshalledData,
|
|
179
|
+
marshal.toCapData(harden(properlyMarshalledData)),
|
|
180
|
+
];
|
|
181
|
+
t.plan(4);
|
|
182
|
+
const options = { batchSize: 1, marshaller: { toCapData: data => data } };
|
|
183
|
+
const { controller, PORT } = await t.context.startFakeServer(
|
|
184
|
+
t,
|
|
185
|
+
fakeValues,
|
|
186
|
+
options,
|
|
187
|
+
);
|
|
188
|
+
controller.advance(0);
|
|
189
|
+
/** @type {import('../src/types.js').LeaderOptions} */
|
|
190
|
+
const lo = {
|
|
191
|
+
retryCallback: null, // fail fast, no retries
|
|
192
|
+
keepPolling: () => delay(1000).then(() => true), // poll really quickly
|
|
193
|
+
jitter: null, // no jitter
|
|
194
|
+
};
|
|
195
|
+
/** @type {import('../src/types.js').FollowerOptions} */
|
|
196
|
+
const so = {
|
|
197
|
+
proof: 'none',
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const leader = makeLeader(`http://localhost:${PORT}/network-config`, lo);
|
|
201
|
+
const castingSpec = makeCastingSpec(':mailbox.agoric1foobarbaz');
|
|
202
|
+
const follower = await makeFollower(castingSpec, leader, so);
|
|
203
|
+
let i = 0;
|
|
204
|
+
// eslint-disable-next-line no-unreachable-loop
|
|
205
|
+
for await (const { value, error } of iterateEach(follower)) {
|
|
206
|
+
if (i === 0) {
|
|
207
|
+
t.log(`value from follower, should be undefined:`, value);
|
|
208
|
+
t.log(`error from follower, should be defined:`, error);
|
|
209
|
+
|
|
210
|
+
t.deepEqual(value, undefined);
|
|
211
|
+
t.assert(typeof error === 'object');
|
|
212
|
+
|
|
213
|
+
i += 1;
|
|
214
|
+
controller.advance(1);
|
|
215
|
+
} else if (i === 1) {
|
|
216
|
+
t.log(`value from follower, should be defined:`, value);
|
|
217
|
+
t.log(`error from follower, should be undefined:`, error);
|
|
218
|
+
|
|
219
|
+
t.deepEqual(value, properlyMarshalledData);
|
|
220
|
+
t.deepEqual(error, undefined);
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
|
|
170
226
|
test.before(t => {
|
|
171
227
|
t.context.cleanups = [];
|
|
172
228
|
t.context.startFakeServer = startFakeServer;
|