-
Notifications
You must be signed in to change notification settings - Fork 3
/
fix-tutorial.patch
246 lines (230 loc) · 9.18 KB
/
fix-tutorial.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
diff --git a/tutorial/lesson1.test.ts b/tutorial/lesson1.test.ts
index 21929c6..57a6d5f 100644
--- a/tutorial/lesson1.test.ts
+++ b/tutorial/lesson1.test.ts
@@ -51,7 +51,7 @@ it("Lesson 1: Form a State with the correct format", async () => {
/* Putting it all together */
const state: State = {
turnNum: 0,
- isFinal: true, // FIXME
+ isFinal: false,
channel,
challengeDuration,
outcome,
diff --git a/tutorial/lesson10.test.ts b/tutorial/lesson10.test.ts
index bea59b4..9930705 100644
--- a/tutorial/lesson10.test.ts
+++ b/tutorial/lesson10.test.ts
@@ -117,6 +117,5 @@ it("Lesson 10: Extract information from a ChallengeRegistered event", async () =
expect(eventVariableParts[eventVariableParts.length - 1][1]).toEqual(
variableParts[variableParts.length - 1].appData
);
- expect(eventFinalizesAt).toEqual(0); // FIXME
- // expect(eventFinalizesAt).toBeGreaterThan(0);
+ expect(eventFinalizesAt).toBeGreaterThan(0);
});
diff --git a/tutorial/lesson11.test.ts b/tutorial/lesson11.test.ts
index d897090..b636c55 100644
--- a/tutorial/lesson11.test.ts
+++ b/tutorial/lesson11.test.ts
@@ -17,7 +17,7 @@ it("Lesson 11: Construct an allocation Outcome", async () => {
whose address is stored in process.env
*/
const assetOutcome: AllocationAssetOutcome = {
- assetHolderAddress: AddressZero, // FIXME
+ assetHolderAddress: process.env.ETH_ASSET_HOLDER_ADDRESS,
allocationItems: [
{ destination: HashZero, amount: "0x03" },
// other payouts go here
diff --git a/tutorial/lesson12.test.ts b/tutorial/lesson12.test.ts
index 606d06a..4477685 100644
--- a/tutorial/lesson12.test.ts
+++ b/tutorial/lesson12.test.ts
@@ -19,8 +19,8 @@ it("Lesson 12: Construct a guarantee Outcome", async () => {
guarantee: {
targetChannelId: HashZero,
destinations: [
- "0x000000000000000000000000000000000000000000000000000000000000000a", // FIXME
- "0x000000000000000000000000000000000000000000000000000000000000000b", // FIXME
+ "0x000000000000000000000000000000000000000000000000000000000000000b",
+ "0x000000000000000000000000000000000000000000000000000000000000000a",
],
},
};
diff --git a/tutorial/lesson13.test.ts b/tutorial/lesson13.test.ts
index 11d5cf5..434828f 100644
--- a/tutorial/lesson13.test.ts
+++ b/tutorial/lesson13.test.ts
@@ -90,8 +90,7 @@ it("Lesson 13: Call pushOutcome", async () => {
const challengerAddress = AddressZero; // Reset in a happy conclude
const outcomeBytes = encodeOutcome(state.outcome);
- const turnNumRecord = largestTurnNum; // FIXME
- // const turnNumRecord = 0; // Always 0 for a happy conclude
+ const turnNumRecord = 0; // Always 0 for a happy conclude
const tx1 = NitroAdjudicator.pushOutcome(
channelId,
diff --git a/tutorial/lesson14.test.ts b/tutorial/lesson14.test.ts
index 8e4405f..0433ff9 100644
--- a/tutorial/lesson14.test.ts
+++ b/tutorial/lesson14.test.ts
@@ -14,6 +14,7 @@ import {
encodeOutcome,
AllocationAssetOutcome,
hashAppPart,
+ encodeAllocation,
} from "@statechannels/nitro-protocol";
/* Set up an ethereum provider connected to our local blockchain */
@@ -117,8 +118,7 @@ it("Lesson 14: Call transferAll", async () => {
/* Submit a transferAll transaction */
const tx3 = ETHAssetHolder.transferAll(
channelId,
- HashZero // FIXME
- // encodeAllocation(assetOutcome.allocationItems)
+ encodeAllocation(assetOutcome.allocationItems)
);
/*
diff --git a/tutorial/lesson15.test.ts b/tutorial/lesson15.test.ts
index 64d939e..99f671d 100644
--- a/tutorial/lesson15.test.ts
+++ b/tutorial/lesson15.test.ts
@@ -181,18 +181,11 @@ it("Lesson 15: Call claimAll", async () => {
/*
Submit claimAll transaction
*/
-
- // FIXME
const tx5 = ETHAssetHolder.claimAll(
guarantorChannelId,
- encodeAllocation(assetOutcomeForTheTargetChannel.allocationItems),
- encodeGuarantee(assetOutcomeForTheGuarantorChannel.guarantee)
+ encodeGuarantee(assetOutcomeForTheGuarantorChannel.guarantee),
+ encodeAllocation(assetOutcomeForTheTargetChannel.allocationItems)
);
- // const tx5 = ETHAssetHolder.claimAll(
- // guarantorChannelId,
- // encodeGuarantee(assetOutcomeForTheGuarantorChannel.guarantee),
- // encodeAllocation(assetOutcomeForTheTargetChannel.allocationItems)
- // );
/*
Check that an AssetTransferred event was emitted.
diff --git a/tutorial/lesson16.test.ts b/tutorial/lesson16.test.ts
index b130cdb..e7258eb 100644
--- a/tutorial/lesson16.test.ts
+++ b/tutorial/lesson16.test.ts
@@ -84,7 +84,7 @@ it("Lesson 16: Ledger funding", async () => {
*/
let signatures;
signatures = [
- signState(sixEachStatePreFS, hubSigningKey).signature, // FIXME
+ signState(sixEachStatePreFS, mySigningKey).signature,
signState(sixEachStatePreFS, hubSigningKey).signature,
];
expect(JSON.stringify(signatures)).toEqual(
diff --git a/tutorial/lesson2.test.ts b/tutorial/lesson2.test.ts
index 91f1e89..40b62d6 100644
--- a/tutorial/lesson2.test.ts
+++ b/tutorial/lesson2.test.ts
@@ -44,7 +44,7 @@ it("Lesson 2: Conform to an on chain validTransition function", async () => {
};
/* Construct another state */
- const toState: State = { ...fromState, turnNum: 1, appData: "0x1" }; // FIXME
+ const toState: State = { ...fromState, turnNum: 1 };
/*
Check validity of transition from one state to the other
diff --git a/tutorial/lesson3.test.ts b/tutorial/lesson3.test.ts
index 2c7e923..161d447 100644
--- a/tutorial/lesson3.test.ts
+++ b/tutorial/lesson3.test.ts
@@ -60,7 +60,6 @@ it("Lesson 3: Support a state with signatures", async () => {
/* Sign the states */
const whoSignedWhat = [0, 1, 2];
const sigs = await signStates(states, wallets, whoSignedWhat);
- sigs.reverse(); // FIXME
/*
* Use the checkpoint method to test our signatures
diff --git a/tutorial/lesson4.test.ts b/tutorial/lesson4.test.ts
index 3101496..1c2fa75 100644
--- a/tutorial/lesson4.test.ts
+++ b/tutorial/lesson4.test.ts
@@ -1,5 +1,5 @@
import { ethers } from "ethers";
-import { Channel } from "@statechannels/nitro-protocol";
+import { Channel, getChannelId } from "@statechannels/nitro-protocol";
it("Lesson 4: construct a Channel and compute its id", async () => {
/*
@@ -22,15 +22,13 @@ it("Lesson 4: construct a Channel and compute its id", async () => {
*/
const channelNonce = 0;
- const channelId = "fixme"; // FIX ME
-
/*
Uncomment the lines below to use the imported helper function to compute the channel id.
Feel free to take a look at the implementation of that helper
*/
const channel: Channel = { chainId, channelNonce, participants };
- // const channelId = getChannelId(channel);
+ const channelId = getChannelId(channel);
/*
Expectations around the format of the channel Id:
diff --git a/tutorial/lesson5.test.ts b/tutorial/lesson5.test.ts
index 4251eb6..5fe8f86 100644
--- a/tutorial/lesson5.test.ts
+++ b/tutorial/lesson5.test.ts
@@ -40,7 +40,7 @@ it("Lesson 5: depositing into the ETH asset holder", async () => {
Attempt to deposit 1 wei against the channel id we created.
Inspect the error message in the console for a hint about the bug on the next line
*/
- const expectedHeld = 1; // FIXME
+ const expectedHeld = 0;
const tx0 = ETHAssetHolder.deposit(destination, expectedHeld, amount, {
value: amount,
});
diff --git a/tutorial/lesson6.test.ts b/tutorial/lesson6.test.ts
index 085c4ff..784989b 100644
--- a/tutorial/lesson6.test.ts
+++ b/tutorial/lesson6.test.ts
@@ -43,7 +43,7 @@ it("Lesson 6: Conclude a channel (happy)", async () => {
const channel: Channel = { chainId, channelNonce, participants };
const largestTurnNum = 4;
const state: State = {
- isFinal: false, // FIXME
+ isFinal: true,
channel,
outcome: [],
appDefinition: AddressZero,
diff --git a/tutorial/lesson7.test.ts b/tutorial/lesson7.test.ts
index bb2459c..0eb9c00 100644
--- a/tutorial/lesson7.test.ts
+++ b/tutorial/lesson7.test.ts
@@ -43,8 +43,7 @@ it("Lesson 7: Register a challenge using forceMove", async () => {
const channel: Channel = { chainId, channelNonce, participants };
/* Choose a challenger */
- const challenger = ethers.Wallet.createRandom(); // FIXME
- // const challenger = wallets[0];
+ const challenger = wallets[0];
/* Construct a progression of states */
const largestTurnNum = 8;
diff --git a/tutorial/lesson8.test.ts b/tutorial/lesson8.test.ts
index 8e9e352..10d9d86 100644
--- a/tutorial/lesson8.test.ts
+++ b/tutorial/lesson8.test.ts
@@ -88,7 +88,7 @@ it("Lesson 8: Clear a challenge using checkpoint", async () => {
/* BEGIN Lesson 8 proper */
/* Form a progression of states */
- const numRounds = 2; // FIXME
+ const numRounds = 3;
largestTurnNum = 3 * numRounds;
appDatas = [largestTurnNum - 2, largestTurnNum - 1, largestTurnNum];
states = appDatas.map((data, idx) => ({
diff --git a/tutorial/lesson9.test.ts b/tutorial/lesson9.test.ts
index ad7ec7c..1e60ddc 100644
--- a/tutorial/lesson9.test.ts
+++ b/tutorial/lesson9.test.ts
@@ -123,7 +123,7 @@ it("Lesson 9: Clear a challenge using respond", async () => {
*/
const expectedChannelStorageHash = channelDataToChannelStorageHash({
turnNumRecord: largestTurnNum,
- finalizesAt: 0x1, // FIXME
+ finalizesAt: 0,
});
/*