Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Misc driveby relayer test improvements #1186

Merged
merged 3 commits into from
Feb 12, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions test/Relayer.SlowFill.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
TokenClient,
} from "../src/clients";
import { CONFIG_STORE_VERSION } from "../src/common";
import { bnZero } from "../src/utils";
import {
CHAIN_ID_TEST_LIST,
amountToDeposit,
Expand Down Expand Up @@ -35,7 +36,6 @@ import {
setupTokensForWallet,
sinon,
spyLogIncludes,
toBN,
winston,
} from "./utils";

Expand Down Expand Up @@ -172,6 +172,8 @@ describe("Relayer: Zero sized fill for slow relay", async function () {
destinationChainId,
amountToDeposit.mul(2) // 2x the normal deposit size. Bot only has 1x the deposit amount.
);
expect(deposit1).to.exist;

await updateAllClients();
await relayerInstance.checkForUnfilledDepositsAndFill();
expect(spyLogIncludes(spy, -2, "Zero filling")).to.be.true;
Expand All @@ -182,16 +184,18 @@ describe("Relayer: Zero sized fill for slow relay", async function () {
expect(tx.length).to.equal(1); // There should have been exactly one transaction.

// Check the state change happened correctly on the smart contract. There should be exactly one fill on spokePool_2.
const fillEvents2 = await spokePool_2.queryFilter(spokePool_2.filters.FilledRelay());
expect(fillEvents2.length).to.equal(1);
expect(fillEvents2[0].args.depositId).to.equal(deposit1.depositId);
expect(fillEvents2[0].args.amount).to.equal(deposit1.amount);
expect(fillEvents2[0].args.fillAmount).to.equal(1); // 1wei fill size
expect(fillEvents2[0].args.destinationChainId).to.equal(Number(deposit1.destinationChainId));
expect(fillEvents2[0].args.originChainId).to.equal(Number(deposit1.originChainId));
expect(fillEvents2[0].args.relayerFeePct).to.equal(deposit1.relayerFeePct);
expect(fillEvents2[0].args.depositor).to.equal(deposit1.depositor);
expect(fillEvents2[0].args.recipient).to.equal(deposit1.recipient);
const fillEvent = (await spokePool_2.queryFilter(spokePool_2.filters.FilledRelay())).at(-1);
expect(fillEvent).to.exist;
expect(fillEvent?.args).to.exist;

["depositId", "amount", "destinationChainId", "originChainId", "depositor", "recipient"].forEach((key) => {
const val = fillEvent?.args?.[key];
pxrl marked this conversation as resolved.
Show resolved Hide resolved
expect(val).to.not.be.undefined;
expect(deposit1?.[key]).to.equal(val);
});
expect(fillEvent?.args?.relayerFeePct.eq(deposit1?.relayerFeePct)).to.be.true;
expect(fillEvent?.args?.fillAmount).to.equal(1); // 1wei fill size

// Re-run the execution loop and validate that no additional relays are sent.
multiCallerClient.clearTransactionQueue();
await Promise.all([spokePoolClient_1.update(), spokePoolClient_2.update(), hubPoolClient.update()]);
Expand Down Expand Up @@ -223,9 +227,9 @@ describe("Relayer: Zero sized fill for slow relay", async function () {
// These parameters don't matter, as the relayer only checks that the rebalance matches
// the deposit destination chain and L1 token. The amount must be greater than the unfilled
// deposit amount too.
thresholdPct: toBN(0),
targetPct: toBN(0),
currentAllocPct: toBN(0),
thresholdPct: bnZero,
targetPct: bnZero,
currentAllocPct: bnZero,
cumulativeBalance: await l1Token.balanceOf(relayer.address),
};
});
Expand All @@ -247,7 +251,7 @@ describe("Relayer: Zero sized fill for slow relay", async function () {
it("rebalance amount is too low", async function () {
mockInventoryClient.addPossibleRebalance({
...partialRebalance,
balance: toBN(0), // No balance
balance: bnZero, // No balance
amount: deposit1.amount,
chainId: deposit1.destinationChainId,
l1Token: l1Token.address,
Expand Down
Loading