Skip to content

Commit 7cb0aa2

Browse files
helper update
1 parent 9903bd9 commit 7cb0aa2

1 file changed

Lines changed: 24 additions & 16 deletions

File tree

test/integration/Staking.test.ts

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,11 @@ async function advanceToNextProofingPeriod(
287287
* Ensures a node has at least one knowledge chunk in the current epoch.
288288
* If not, it creates a small knowledge collection to facilitate proof submission.
289289
*/
290+
/**
291+
* Ensure da node ima bar jedan chunk u tekućem epoch-u.
292+
* Ako nema – sam node (kao publisher) objavi mini-KC (1 chunk, 1 TRAC),
293+
* pa odmah osvežimo proof-period tako da chunk uđe u aktivni skup.
294+
*/
290295
async function ensureNodeHasChunksThisEpoch(
291296
nodeId: bigint,
292297
node: { operational: SignerWithAddress; admin: SignerWithAddress },
@@ -297,38 +302,41 @@ async function ensureNodeHasChunksThisEpoch(
297302
admin: SignerWithAddress;
298303
}[],
299304
receivingNodesIdentityIds: number[],
300-
) {
305+
): Promise<void> {
301306
const produced =
302307
await contracts.epochStorage.getNodeCurrentEpochProducedKnowledgeValue(
303308
nodeId,
304309
);
305310

306-
// If the node has not published anything in this epoch,
307-
// and it is NOT already in the 'receivingNodes' list, add it to ensure it gets at least one replica.
308311
if (produced === 0n) {
309-
const selfAlreadyListed = receivingNodes.some(
310-
(r) => r.operational.address === node.operational.address,
311-
);
312-
313-
if (!selfAlreadyListed) {
314-
receivingNodes.unshift(node); // prepend - order doesn't matter
312+
/* dodaj self u listu primaoca (ako već nije tu) */
313+
if (
314+
!receivingNodes.some(
315+
(r) => r.operational.address === node.operational.address,
316+
)
317+
) {
318+
receivingNodes.unshift(node);
315319
receivingNodesIdentityIds.unshift(Number(nodeId));
316320
}
317321

322+
/* ► samo-objavljena KC: publisher == node ← ovde je ključ! */
318323
await createKnowledgeCollection(
319-
accounts.kcCreator,
320-
node, // <- node that will prove
324+
node.operational, // signer = node.operational
325+
node, // publisher-node
321326
Number(nodeId),
322327
receivingNodes,
323328
receivingNodesIdentityIds,
324329
{ KnowledgeCollection: contracts.kc, Token: contracts.token },
325330
merkleRoot,
326-
`ensure-chunks-${Date.now()}`, // unique op-id
327-
1,
328-
4,
329-
1,
330-
toTRAC(1), // 1-chunk, 1 TRAC KC
331+
`ensure-chunks-${Date.now()}`,
332+
1, // holders
333+
4, // chunks
334+
1, // replicas
335+
toTRAC(1),
331336
);
337+
338+
/* odmah pomeri start proof-perioda da KC postane aktivna */
339+
await contracts.randomSamplingStorage.updateAndGetActiveProofPeriodStartBlock();
332340
}
333341
}
334342

0 commit comments

Comments
 (0)