Skip to content

Commit

Permalink
comment on tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholaspai committed Nov 29, 2024
1 parent 088b8ac commit 0282f30
Showing 1 changed file with 6 additions and 21 deletions.
27 changes: 6 additions & 21 deletions test/Dataworker.executePoolRebalances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,25 +325,9 @@ describe("Dataworker: Execute pool rebalances", async function () {
expect(updated.size).to.equal(0);
expect(multiCallerClient.transactionCount()).to.equal(0);
});
it("exits early if current liquid reserves are greater than total net send amount", async function () {
const netSendAmount = toBNWei("1");
const liquidReserves = toBNWei("2");
// For this test, do not pass in a liquid reserves object and force dataworker to load
// from HubPoolClient
mockHubPoolClient.setLpTokenInfo(l1Token_1.address, 0, liquidReserves);
const updated = await dataworkerInstance._updateExchangeRatesBeforeExecutingNonHubChainLeaves(
{},
balanceAllocator,
[
{ netSendAmounts: [netSendAmount], l1Tokens: [l1Token_1.address], chainId: 1 },
{ netSendAmounts: [netSendAmount], l1Tokens: [l1Token_1.address], chainId: 10 },
],
true
);
expect(updated.size).to.equal(0);
expect(multiCallerClient.transactionCount()).to.equal(0);
});
it("groups aggregate net send amounts by L1 token", async function () {
// Total net send amount is 1 for each token but they are not summed together because they are different,
// so the liquid reserves of 1 for each individual token is enough.
const liquidReserves = toBNWei("1");
const l1Token2 = erc20_1.address;
const updated = await dataworkerInstance._updateExchangeRatesBeforeExecutingNonHubChainLeaves(
Expand Down Expand Up @@ -426,6 +410,7 @@ describe("Dataworker: Execute pool rebalances", async function () {
it("logs error if updated liquid reserves aren't enough to execute leaf", async function () {
const netSendAmount = toBNWei("1");
const liquidReserves = toBNWei("1");
// Total net send amount will be 2, but liquid reserves are only 1.
mockHubPoolClient.setLpTokenInfo(l1Token_1.address, 0, liquidReserves);

// Even after simulating sync, there are not enough liquid reserves.
Expand All @@ -436,7 +421,7 @@ describe("Dataworker: Execute pool rebalances", async function () {
true, // enabled
0, // last lp fee update
bnZero, // utilized reserves
liquidReserves, // liquid reserves, >= than total netSendAmount
liquidReserves, // liquid reserves, still < than total netSendAmount
bnZero, // unaccumulated fees
]),
]);
Expand Down Expand Up @@ -521,8 +506,8 @@ describe("Dataworker: Execute pool rebalances", async function () {
],
true
);
expect(spy.getCall(-1).lastArg.virtualHubPoolBalance).to.equal(netSendAmount.mul(2));
expect(updated.size).to.equal(1);
expect(spy.getCall(-1).lastArg.virtualHubPoolBalance).to.equal(netSendAmount.mul(2));
expect(updated.has(l1Token_1.address)).to.be.true;
expect(multiCallerClient.transactionCount()).to.equal(1);
});
Expand Down Expand Up @@ -557,8 +542,8 @@ describe("Dataworker: Execute pool rebalances", async function () {
],
true
);
expect(spy.getCall(-1).lastArg.virtualHubPoolBalance).to.equal(netSendAmount.mul(3).sub(toBNWei("1")));
expect(updated.size).to.equal(1);
expect(spy.getCall(-1).lastArg.virtualHubPoolBalance).to.equal(netSendAmount.mul(3).sub(toBNWei("1")));
expect(updated.has(l1Token_1.address)).to.be.true;
expect(multiCallerClient.transactionCount()).to.equal(1);
});
Expand Down

0 comments on commit 0282f30

Please sign in to comment.