Skip to content

Commit

Permalink
Update Dataworker.executePoolRebalances.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholaspai committed Dec 1, 2024
1 parent 870334a commit f441505
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions test/Dataworker.executePoolRebalances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,29 @@ describe("Dataworker: Execute pool rebalances", async function () {
...spokePoolClientsToProviders(spokePoolClients),
[hubPoolClient.chainId]: hubPool.provider,
};
const balanceAllocator = new BalanceAllocator(providers);

// Executing leaves before there is a bundle should do nothing:
let leafCount = await dataworkerInstance.executePoolRebalanceLeaves(spokePoolClients, balanceAllocator);
expect(leafCount).to.equal(0);
expect(lastSpyLogIncludes(spy, "No pending proposal")).to.be.true;

await dataworkerInstance.proposeRootBundle(spokePoolClients);

// Execute queue and check that root bundle is pending:
await l1Token_1.approve(hubPool.address, MAX_UINT_VAL);
await multiCallerClient.executeTxnQueues();

// Executing leaves before bundle challenge period has passed should do nothing:
await updateAllClients();
leafCount = await dataworkerInstance.executePoolRebalanceLeaves(spokePoolClients, balanceAllocator);
expect(leafCount).to.equal(0);
expect(lastSpyLogIncludes(spy, "Challenge period not passed")).to.be.true;

// Advance time and execute leaves:
await hubPool.setCurrentTime(Number(await hubPool.getCurrentTime()) + Number(await hubPool.liveness()) + 1);
await updateAllClients();
const balanceAllocator = new BalanceAllocator(providers);
let leafCount = await dataworkerInstance.executePoolRebalanceLeaves(spokePoolClients, balanceAllocator);
leafCount = await dataworkerInstance.executePoolRebalanceLeaves(spokePoolClients, balanceAllocator);
expect(leafCount).to.equal(2);

// Should be 4 transactions: 1 for the to chain, 1 for the from chain, 1 for the extra ETH sent to cover
Expand Down

0 comments on commit f441505

Please sign in to comment.