Skip to content

Commit c2eb14c

Browse files
committed
Update test
1 parent 73b4659 commit c2eb14c

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed

packages/sequencer/test/integration/BlockProduction.test.ts

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,107 @@ describe("block production", () => {
337337
expect(newState).toBeUndefined();
338338
}, 30_000);
339339

340+
it("should produce txs in non-consecutive blocks", async () => {
341+
log.setLevel("TRACE");
342+
343+
const privateKey = PrivateKey.random();
344+
const publicKey = privateKey.toPublicKey();
345+
346+
const privateKey2 = PrivateKey.random();
347+
const publicKey2 = privateKey2.toPublicKey();
348+
349+
await mempool.add(
350+
createTransaction({
351+
runtime,
352+
method: ["Balance", "setBalanceIf"],
353+
privateKey,
354+
args: [publicKey, UInt64.from(100), Bool(true)],
355+
nonce: 0,
356+
})
357+
);
358+
359+
// let [block, batch] = await blockTrigger.produceBlockAndBatch();
360+
const block = await blockTrigger.produceBlock();
361+
362+
expect(block).toBeDefined();
363+
364+
expect(block!.transactions).toHaveLength(1);
365+
expect(block!.transactions[0].status.toBoolean()).toBe(true);
366+
expect(block!.transactions[0].statusMessage).toBeUndefined();
367+
368+
expect(block!.transactions[0].stateTransitions).toHaveLength(1);
369+
expect(block!.transactions[0].protocolTransitions).toHaveLength(2);
370+
371+
await blockTrigger.produceBlock();
372+
373+
await mempool.add(
374+
createTransaction({
375+
runtime,
376+
method: ["Balance", "setBalanceIf"],
377+
privateKey: privateKey2,
378+
args: [publicKey2, UInt64.from(100), Bool(true)],
379+
nonce: 0,
380+
})
381+
);
382+
await blockTrigger.produceBlock();
383+
384+
await mempool.add(
385+
createTransaction({
386+
runtime,
387+
method: ["Balance", "setBalanceIf"],
388+
privateKey: privateKey2,
389+
args: [publicKey2, UInt64.from(100), Bool(true)],
390+
nonce: 1,
391+
})
392+
);
393+
await blockTrigger.produceBlock();
394+
395+
await mempool.add(
396+
createTransaction({
397+
runtime,
398+
method: ["Balance", "setBalanceIf"],
399+
privateKey: privateKey2,
400+
args: [publicKey2, UInt64.from(100), Bool(true)],
401+
nonce: 2,
402+
})
403+
);
404+
await blockTrigger.produceBlock();
405+
406+
await mempool.add(
407+
createTransaction({
408+
runtime,
409+
method: ["Balance", "setBalanceIf"],
410+
privateKey: privateKey2,
411+
args: [publicKey2, UInt64.from(100), Bool(true)],
412+
nonce: 3,
413+
})
414+
);
415+
await blockTrigger.produceBlock();
416+
417+
// Second tx
418+
await mempool.add(
419+
createTransaction({
420+
runtime,
421+
method: ["Balance", "setBalanceIf"],
422+
privateKey,
423+
args: [publicKey, UInt64.from(100), Bool(true)],
424+
nonce: 1,
425+
})
426+
);
427+
428+
log.info("Starting second block");
429+
430+
const block2 = await blockTrigger.produceBlock();
431+
432+
expect(block2).toBeDefined();
433+
434+
expect(block2!.transactions).toHaveLength(1);
435+
console.log(block2!.transactions[0]);
436+
console.log(block2!.transactions[0].statusMessage);
437+
expect(block2!.transactions[0].status.toBoolean()).toBe(true);
438+
expect(block2!.transactions[0].statusMessage).toBeUndefined();
439+
}, 60_000);
440+
340441
const numberTxs = 3;
341442

342443
it("should produce block with multiple transaction", async () => {

0 commit comments

Comments
 (0)