Skip to content

Commit 1114188

Browse files
authored
Merge pull request #40 from psilospore/feat/mlv-lottery
Lottery example
2 parents 0dc34fd + b140f1c commit 1114188

File tree

14 files changed

+941
-350
lines changed

14 files changed

+941
-350
lines changed

Diff for: packages/core/src/core.test.ts

+14-21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, test, expect } from "vitest";
22

3-
import { Choreography, Located, Runner } from "./core";
3+
import { Choreography, MultiplyLocated, Runner } from "./core";
44

55
const runner = new Runner();
66

@@ -13,7 +13,7 @@ describe("core", () => {
1313
const choreography: Choreography<
1414
"alice" | "bob",
1515
[],
16-
[Located<string, "bob">]
16+
[MultiplyLocated<string, "bob">]
1717
> = async ({ locally, comm }) => {
1818
const msg = await locally("alice", () => "Hello, world!");
1919
const msgAtBob = await comm("alice", "bob", msg);
@@ -22,7 +22,7 @@ describe("core", () => {
2222

2323
const f = runner.compile(choreography);
2424
const [msgAtBob] = await f([]);
25-
expect(msgAtBob).toEqual("Hello, world!");
25+
expect(runner.unwrap(msgAtBob)).toEqual("Hello, world!");
2626
});
2727
test("Global arguments", async () => {
2828
const p = "GLOBAL ARGUMENT";
@@ -38,17 +38,16 @@ describe("core", () => {
3838
});
3939
test("Located arguments", async () => {
4040
const p = "Alice's Secret Message";
41-
const c: Choreography<Locations, [Located<string, "alice">]> = async (
42-
{ locally },
43-
[msg],
44-
) => {
41+
const c: Choreography<
42+
Locations,
43+
MultiplyLocated<string, "alice">
44+
> = async ({ locally }, msg) => {
4545
await locally("alice", (unwrap) => {
4646
expect(unwrap(msg)).toBe(p);
4747
});
48-
return [];
4948
};
5049
const g = runner.compile(c);
51-
await g([p]);
50+
await g(runner.local(p));
5251
});
5352
test("Async locally", async () => {
5453
let count = 0;
@@ -60,10 +59,9 @@ describe("core", () => {
6059
expect(unwrap(msg)).toBe(5);
6160
count += 1;
6261
});
63-
return [];
6462
};
6563
const g = runner.compile(c);
66-
await g([]);
64+
await g(void 0);
6765
expect(count).toBe(1);
6866
});
6967
test("multicast", async () => {
@@ -83,10 +81,9 @@ describe("core", () => {
8381
expect(unwrap(msgAtSelectedTwo)).toBe("Hello, world!");
8482
count += 1;
8583
});
86-
return [];
8784
};
8885
const g = runner.compile(test);
89-
await g([]);
86+
await g(void 0);
9087
expect(count).toBe(2);
9188
});
9289
test("naked", async () => {
@@ -109,10 +106,9 @@ describe("core", () => {
109106
},
110107
[],
111108
);
112-
return [];
113109
};
114110
const g = runner.compile(test);
115-
await g([]);
111+
await g(void 0);
116112
expect(check).toBe("Hello, world!");
117113
});
118114
test("broadcast", async () => {
@@ -122,10 +118,9 @@ describe("core", () => {
122118
const msg = await broadcast("alice", localMsg);
123119
expect(msg).toBe("Hello everyone!");
124120
count += 1;
125-
return [];
126121
};
127122
const g = runner.compile(test);
128-
await g([]);
123+
await g(void 0);
129124
expect(count).toBe(1);
130125
});
131126
test("enclave", async () => {
@@ -138,14 +133,12 @@ describe("core", () => {
138133
const msg = await broadcast("bob", msgAtBob);
139134
expect(msg).toBe("Hello, world!");
140135
count += 1;
141-
return [];
142136
},
143-
[],
137+
void 0,
144138
);
145-
return [];
146139
};
147140
const g = runner.compile(test);
148-
await g([]);
141+
await g(void 0);
149142
expect(count).toBe(1);
150143
});
151144
});

0 commit comments

Comments
 (0)