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 6, 2024
1 parent 7fd746b commit 7e0badd
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions test/Dataworker.executePoolRebalances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ describe("Dataworker: Execute pool rebalances", async function () {
await fillV3(spokePool_2, depositor, deposit, destinationChainId);
await updateAllClients();


// Executing leaves before there is a bundle should do nothing:
let leafCount = await dataworkerInstance.executePoolRebalanceLeaves(spokePoolClients, getNewBalanceAllocator());
expect(leafCount).to.equal(0);
Expand Down Expand Up @@ -225,12 +224,11 @@ describe("Dataworker: Execute pool rebalances", async function () {
it("ignores negative net send amounts", async function () {
const liquidReserves = toBNWei("1");
mockHubPoolClient.setLpTokenInfo(l1Token_1.address, 0, liquidReserves);
const syncedL1Tokens =
await dataworkerInstance._updateExchangeRatesBeforeExecutingHubChainLeaves(
balanceAllocator,
{ netSendAmounts: [toBNWei(-1)], l1Tokens: [l1Token_1.address] },
true
);
const syncedL1Tokens = await dataworkerInstance._updateExchangeRatesBeforeExecutingHubChainLeaves(
balanceAllocator,
{ netSendAmounts: [toBNWei(-1)], l1Tokens: [l1Token_1.address] },
true
);
expect(syncedL1Tokens.size).to.equal(0);
expect(multiCallerClient.transactionCount()).to.equal(0);
});
Expand All @@ -239,12 +237,11 @@ describe("Dataworker: Execute pool rebalances", async function () {
const netSendAmount = toBNWei("1");
mockHubPoolClient.setLpTokenInfo(l1Token_1.address, 0, currentReserves);

const syncedL1Tokens =
await dataworkerInstance._updateExchangeRatesBeforeExecutingHubChainLeaves(
balanceAllocator,
{ netSendAmounts: [netSendAmount], l1Tokens: [l1Token_1.address] },
true
);
const syncedL1Tokens = await dataworkerInstance._updateExchangeRatesBeforeExecutingHubChainLeaves(
balanceAllocator,
{ netSendAmounts: [netSendAmount], l1Tokens: [l1Token_1.address] },
true
);
expect(syncedL1Tokens.size).to.equal(0);
expect(multiCallerClient.transactionCount()).to.equal(0);
expect(lastSpyLogIncludes(spy, "current liquid reserves > netSendAmount")).to.be.true;
Expand All @@ -270,12 +267,11 @@ describe("Dataworker: Execute pool rebalances", async function () {
const updatedLiquidReserves = netSendAmount.add(1);
balanceAllocator.testSetBalance(1, l1Token_1.address, hubPool.address, updatedLiquidReserves);

const syncedL1Tokens =
await dataworkerInstance._updateExchangeRatesBeforeExecutingHubChainLeaves(
balanceAllocator,
{ netSendAmounts: [netSendAmount], l1Tokens: [l1Token_1.address] },
true
);
const syncedL1Tokens = await dataworkerInstance._updateExchangeRatesBeforeExecutingHubChainLeaves(
balanceAllocator,
{ netSendAmounts: [netSendAmount], l1Tokens: [l1Token_1.address] },
true
);
expect(syncedL1Tokens.size).to.equal(1);
expect(syncedL1Tokens.has(l1Token_1.address)).to.be.true;
expect(multiCallerClient.transactionCount()).to.equal(1);
Expand Down

0 comments on commit 7e0badd

Please sign in to comment.