Skip to content

Commit

Permalink
E2E Test (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
bh2smith authored Oct 1, 2024
1 parent d452e40 commit 374b29a
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 8 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ jobs:
yarn
yarn lint
yarn build
yarn test unit
43 changes: 43 additions & 0 deletions tests/e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import dotenv from "dotenv";

import { NearSafe } from "../src";

dotenv.config();
describe("Near Safe Requests", () => {
it("buildTransaction", async () => {
const adapter = await NearSafe.create({
accountId: "neareth-dev.testnet",
mpcContractId: "v1.signer-prod.testnet",
pimlicoKey: process.env.PIMLICO_KEY!,
});
const irrelevantData = {
data: "0xbeef",
value: "0",
};
await expect(
adapter.buildTransaction({
chainId: 11155111,
transactions: [
{
to: adapter.mpcAddress,
...irrelevantData,
},
],
usePaymaster: true,
})
).resolves.not.toThrow();
// Can't send raw messages to Safe Contracts.
await expect(
adapter.buildTransaction({
chainId: 11155111,
transactions: [
{
to: adapter.address,
...irrelevantData,
},
],
usePaymaster: true,
})
).rejects.toThrow();
});
});
4 changes: 2 additions & 2 deletions tests/ethers-safe.ts → tests/unit/ethers-safe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import {
MetaTransaction,
UnsignedUserOperation,
UserOperation,
} from "../src/types";
import { PLACEHOLDER_SIG, packGas, packPaymasterData } from "../src/util";
} from "../../src/types";
import { PLACEHOLDER_SIG, packGas, packPaymasterData } from "../../src/util";

/**
* All contracts used in account creation & execution
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Erc4337Bundler, stripApiKey } from "../../src/lib/bundler";
import { Erc4337Bundler, stripApiKey } from "../../../src/lib/bundler";

describe("Safe Pack", () => {
const entryPoint = "0x0000000071727De22E5E9d8BAf0edAc6f37da032";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { encodeMulti } from "../../src/lib/multisend";
import { encodeMulti } from "../../../src/lib/multisend";

describe("Multisend", () => {
it("encodeMulti", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { zeroAddress } from "viem";

import { decodeSafeMessage } from "../../src/lib/safe-message";
import { decodeSafeMessage } from "../../../src/lib/safe-message";

describe("Multisend", () => {
const plainMessage = `Welcome to OpenSea!
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/safe.spec.ts → tests/unit/lib/safe.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { zeroAddress } from "viem";

import { SafeContractSuite as ViemPack } from "../../src/lib/safe";
import { SafeContractSuite as ViemPack } from "../../../src/lib/safe";
import { ContractSuite as EthPack } from "../ethers-safe";

describe("Safe Pack", () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/utils.spec.ts → tests/unit/utils.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { ethers } from "ethers";
import { zeroAddress } from "viem";

import { PaymasterData } from "../src";
import { PaymasterData } from "../../src";
import {
PLACEHOLDER_SIG,
containsValue,
isContract,
packGas,
packPaymasterData,
packSignature,
} from "../src/util";
} from "../../src/util";

describe("Utility Functions (mostly byte packing)", () => {
it("PLACE_HOLDER_SIG", () => {
Expand Down

0 comments on commit 374b29a

Please sign in to comment.