Skip to content

Commit 5ed58d5

Browse files
committed
Get tests working
1 parent 3a5ba7e commit 5ed58d5

File tree

1 file changed

+44
-14
lines changed

1 file changed

+44
-14
lines changed

packages/sdk/test/fees-multi-zkprograms.test.ts

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -162,22 +162,22 @@ describe("check fee analyzer", () => {
162162
perWeightUnitFee: 0n,
163163
methods: {
164164
"TestModule1.Method_1": {
165-
baseFee: 10n,
165+
baseFee: 9n,
166166
weight: 0n,
167167
perWeightUnitFee: 0n,
168168
},
169169
"TestModule1.Method_10": {
170-
baseFee: 10n,
170+
baseFee: 8n,
171171
weight: 0n,
172172
perWeightUnitFee: 0n,
173173
},
174174
"TestModule2.Method_4": {
175-
baseFee: 10n,
175+
baseFee: 7n,
176176
weight: 0n,
177177
perWeightUnitFee: 0n,
178178
},
179179
"TestModule2.Method_7": {
180-
baseFee: 10n,
180+
baseFee: 6n,
181181
weight: 0n,
182182
perWeightUnitFee: 0n,
183183
},
@@ -191,63 +191,93 @@ describe("check fee analyzer", () => {
191191
});
192192

193193
it("with multiple zk programs", async () => {
194-
expect.assertions(4);
194+
expect.assertions(12);
195195
const testModule1 = appChain.runtime.resolve("TestModule1");
196196
const testModule2 = appChain.runtime.resolve("TestModule2");
197197
const faucet = appChain.runtime.resolve("Faucet");
198+
const transactionFeeModule = appChain.protocol.resolve("TransactionFee");
198199

199200
const tx1 = await appChain.transaction(
200201
senderKey.toPublicKey(),
201202
async () => {
202203
await faucet.drip();
203-
}
204+
},
205+
{ nonce: 0 }
204206
);
205207

206208
await tx1.sign();
207209
await tx1.send();
208210

209-
await appChain.produceBlock();
210-
211211
const tx2 = await appChain.transaction(
212212
senderKey.toPublicKey(),
213213
async () => {
214214
await testModule1.Method_1();
215-
}
215+
},
216+
{ nonce: 4 }
216217
);
217218

218219
await tx2.sign();
219220
await tx2.send();
221+
const methodId2 = tx2.transaction?.methodId.toBigInt();
222+
expectDefined(methodId2);
223+
const transactionFeeConfig2 =
224+
transactionFeeModule.feeAnalyzer.getFeeConfig(methodId2);
225+
const transactionFee2 = transactionFeeModule.getFee(transactionFeeConfig2);
226+
expect(transactionFee2.toString()).toEqual("9");
220227

221228
const tx3 = await appChain.transaction(
222229
senderKey.toPublicKey(),
223230
async () => {
224231
await testModule2.Method_4();
225-
}
232+
},
233+
{ nonce: 1 }
226234
);
227235

228236
await tx3.sign();
229237
await tx3.send();
238+
const methodId3 = tx3.transaction?.methodId.toBigInt();
239+
expectDefined(methodId3);
240+
const transactionFeeConfig3 =
241+
transactionFeeModule.feeAnalyzer.getFeeConfig(methodId3);
242+
const transactionFee3 = transactionFeeModule.getFee(transactionFeeConfig3);
243+
expect(transactionFee3.toString()).toEqual("7");
230244

231245
const tx4 = await appChain.transaction(
232246
senderKey.toPublicKey(),
233247
async () => {
234248
await testModule2.Method_7();
235-
}
249+
},
250+
{ nonce: 2 }
236251
);
237252

238253
await tx4.sign();
239254
await tx4.send();
240255

256+
const methodId4 = tx4.transaction?.methodId.toBigInt();
257+
expectDefined(methodId4);
258+
const transactionFeeConfig4 =
259+
transactionFeeModule.feeAnalyzer.getFeeConfig(methodId4);
260+
const transactionFee4 = transactionFeeModule.getFee(transactionFeeConfig4);
261+
expect(transactionFee4.toString()).toEqual("6");
262+
241263
const tx5 = await appChain.transaction(
242264
senderKey.toPublicKey(),
243265
async () => {
244266
await testModule1.Method_10();
245-
}
267+
},
268+
{ nonce: 3 }
246269
);
247270

248271
await tx5.sign();
249272
await tx5.send();
250273

274+
const methodId5 = tx5.transaction?.methodId.toBigInt();
275+
expectDefined(methodId5);
276+
const transactionFeeConfig5 =
277+
transactionFeeModule.feeAnalyzer.getFeeConfig(methodId5);
278+
const transactionFee5 = transactionFeeModule.getFee(transactionFeeConfig5);
279+
expect(transactionFee5.toString()).toEqual("8");
280+
251281
await appChain.produceBlock();
252282

253283
const senderBalance = await appChain.query.runtime.Balances.balances.get(
@@ -266,9 +296,9 @@ describe("check fee analyzer", () => {
266296
);
267297

268298
expectDefined(senderBalance);
269-
expect(senderBalance.toString()).toBe("990");
299+
expect(senderBalance.toString()).toBe("970");
270300

271301
expectDefined(feeRecipientBalance);
272-
expect(feeRecipientBalance.toString()).toBe("10");
302+
expect(feeRecipientBalance.toString()).toBe("30");
273303
});
274304
});

0 commit comments

Comments
 (0)