Skip to content

Commit

Permalink
[#787] Minor fixes in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
akshay-ap committed Jul 19, 2024
1 parent cae40b3 commit 15bdca0
Showing 1 changed file with 32 additions and 36 deletions.
68 changes: 32 additions & 36 deletions test/libraries/SafeMigration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,45 @@ describe("SafeMigration Library", () => {
let SAFE_SINGLETON_ADDRESS: string | null | undefined;
let SAFE_SINGLETON_L2_ADDRESS: string | null | undefined;
let COMPATIBILITY_FALLBACK_HANDLER: string | null | undefined;
let migration: SafeMigration;

describe("constructor", () => {
const setupTests = deployments.createFixture(async () => {
return {
singletonAddress: await getSafeSingletonContract(),
singletonL2Address: await getSafeL2SingletonContract(),
compatibilityFallbackHandlerAddress: await getCompatFallbackHandler(),
};
});

it("reverts when Safe singleton is not a contract", async () => {
const { singletonL2Address, compatibilityFallbackHandlerAddress } = await setupTests();
await expect(
hre.ethers.deployContract("SafeMigration", [ethers.ZeroAddress, singletonL2Address, compatibilityFallbackHandlerAddress]),
).to.be.revertedWith("Safe Singleton is not deployed");
});

it("reverts when SafeL2 singleton is not a contract", async () => {
const { singletonAddress, compatibilityFallbackHandlerAddress } = await setupTests();
await expect(
hre.ethers.deployContract("SafeMigration", [singletonAddress, ethers.ZeroAddress, compatibilityFallbackHandlerAddress]),
).to.be.revertedWith("Safe Singleton (L2) is not deployed");
});

it("reverts when fallback handler is not a contract", async () => {
const { singletonAddress, singletonL2Address } = await setupTests();
await expect(
hre.ethers.deployContract("SafeMigration", [singletonAddress, singletonL2Address, ethers.ZeroAddress]),
).to.be.revertedWith("fallback handler is not deployed");
});
});

migrationPaths.forEach(({ testSuiteName, from, to, latest }) => {
describe(testSuiteName, () => {
const setupTests = deployments.createFixture(async ({ deployments }) => {
await deployments.fixture();
const signers = await ethers.getSigners();
const [user1] = signers;
let migration: SafeMigration;

if (latest) {
migration = await safeMigrationContract();
Expand Down Expand Up @@ -89,7 +120,6 @@ describe("SafeMigration Library", () => {
}
const singleton = await getSafeSingletonAt(singletonAddress);
const singletonL2 = await getSafeSingletonAt(singletonL2Address);
console.log("ddssd");

return {
signers,
Expand All @@ -99,40 +129,6 @@ describe("SafeMigration Library", () => {
};
});

describe("constructor", () => {
it("reverts when Safe singleton is not a contract", async () => {
await setupTests();

await expect(
hre.ethers.deployContract("SafeMigration", [
ethers.ZeroAddress,
SAFE_SINGLETON_L2_ADDRESS,
COMPATIBILITY_FALLBACK_HANDLER,
]),
).to.be.revertedWith("Safe Singleton is not deployed");
});

it("reverts when SafeL2 singleton is not a contract", async () => {
await setupTests();

await expect(
hre.ethers.deployContract("SafeMigration", [
SAFE_SINGLETON_ADDRESS,
ethers.ZeroAddress,
COMPATIBILITY_FALLBACK_HANDLER,
]),
).to.be.revertedWith("Safe Singleton (L2) is not deployed");
});

it("reverts when fallback handler is not a contract", async () => {
await setupTests();

await expect(
hre.ethers.deployContract("SafeMigration", [SAFE_SINGLETON_ADDRESS, SAFE_SINGLETON_L2_ADDRESS, ethers.ZeroAddress]),
).to.be.revertedWith("fallback handler is not deployed");
});
});

describe("migrateSingleton", () => {
it("reverts if not called via delegatecall", async () => {
const {
Expand Down

0 comments on commit 15bdca0

Please sign in to comment.