Skip to content

Commit

Permalink
fix: fix tests and logger
Browse files Browse the repository at this point in the history
  • Loading branch information
jahabeebs committed Nov 29, 2024
1 parent f6e666c commit 0e1020d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 26 deletions.
5 changes: 2 additions & 3 deletions apps/agent/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import {
ProtocolProvider,
} from "@ebo-agent/automated-dispute";
import { BlockNumberService } from "@ebo-agent/blocknumber";
import { NotificationService, stringify } from "@ebo-agent/shared";
import { Logger, NotificationService, stringify } from "@ebo-agent/shared";

import { config } from "./config/index.js";

// TODO: Replace with logger.getInstance() when working
const logger = console;
const logger = Logger.getInstance();

const main = async (): Promise<void> => {
logger.debug("Initializing agent...");
Expand Down
3 changes: 2 additions & 1 deletion apps/agent/test/e2e/scenarios/01_happy_path/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ describe.sequential("single agent", () => {
});

beforeEach(async () => {
Logger.getInstance();
l2ProtocolAnvil = await createAnvilServer(
PROTOCOL_L2_LOCAL_RPC_HOST,
PROTOCOL_L2_LOCAL_RPC_PORT,
Expand Down Expand Up @@ -181,7 +182,7 @@ describe.sequential("single agent", () => {
}
});

test.skip("basic flow", { timeout: E2E_TEST_TIMEOUT }, async () => {
test("basic flow", { timeout: E2E_TEST_TIMEOUT }, async () => {
if (!accounts || accounts[0] === undefined || accounts[0]?.privateKey === undefined) {
throw new Error("Accounts not found");
}
Expand Down
32 changes: 10 additions & 22 deletions packages/automated-dispute/tests/services/protocolProvider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
getContract,
Hex,
http,
keccak256,
toBytes,
WaitForTransactionReceiptTimeoutError,
} from "viem";
import { privateKeyToAccount, privateKeyToAddress } from "viem/accounts";
Expand Down Expand Up @@ -1228,6 +1230,12 @@ describe("ProtocolProvider", () => {
});

describe("getAvailableChains", () => {
const ARBITRUM_SEPOLIA_ID = "eip155:421614" as const;
const ETHEREUM_ID = "eip155:1" as const;

const ETHEREUM_ID_HASH = keccak256(toBytes(ETHEREUM_ID)).toLowerCase();
const ARBITRUM_SEPOLIA_ID_HASH = keccak256(toBytes(ARBITRUM_SEPOLIA_ID)).toLowerCase();

it("successfully retrieves available chains", async () => {
const protocolProvider = new ProtocolProvider(
mockRpcConfigBase,
Expand All @@ -1238,16 +1246,13 @@ describe("ProtocolProvider", () => {
mockBlockNumberService,
);

const mockAllowedChainIdsBytes32: `0x${string}`[] = [
"0x6569703135353a31000000000000000000000000000000000000000000000000",
"0x6569703135353a34323136313400000000000000000000000000000000000000",
];
const mockAllowedChainIdsBytes32 = [ETHEREUM_ID_HASH, ARBITRUM_SEPOLIA_ID_HASH];

(
protocolProvider["eboRequestCreatorContract"].read.getAllowedChainIds as Mock
).mockResolvedValue(mockAllowedChainIdsBytes32);

const expectedChains: Caip2ChainId[] = ["eip155:1", "eip155:421614"];
const expectedChains: Caip2ChainId[] = [ETHEREUM_ID, ARBITRUM_SEPOLIA_ID];

const chains = await protocolProvider.getAvailableChains();

Expand Down Expand Up @@ -1299,23 +1304,6 @@ describe("ProtocolProvider", () => {
});
});

describe("getAccountingModuleAddress", () => {
it("returns the correct accounting module address", () => {
const protocolProvider = new ProtocolProvider(
mockRpcConfigBase,
mockContractAddress,
mockedPrivateKey,
mockServiceProviderAddress,
mockLogger(),
mockBlockNumberService,
);

expect(protocolProvider.getAccountingModuleAddress()).toBe(
mockContractAddress.horizonAccountingExtension,
);
});
});

describe("Service Provider Address", () => {
it("uses the provided serviceProviderAddress from config", () => {
const protocolProvider = new ProtocolProvider(
Expand Down

0 comments on commit 0e1020d

Please sign in to comment.