Skip to content

Commit

Permalink
hardhat tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
koloz193 committed Jun 4, 2024
1 parent 63c9bcd commit 803695f
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 73 deletions.
2 changes: 1 addition & 1 deletion l1-contracts/contracts/common/L1ContractErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ error MissingSystemLogs(uint256 expected, uint256 actual);
// 0xe85392f9
error CanOnlyProcessOneBatch();
// 0x55ad3fd3
error BatchHashMismatch(bytes32 exected, bytes32 actual);
error BatchHashMismatch(bytes32 expected, bytes32 actual);
// 0xf093c2e5
error UpgradeBatchNumberIsNotZero();
// 0x0105f9c0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,8 @@ library Diamond {
(bool success, bytes memory data) = _init.delegatecall(_calldata);
if (!success) {
// If the returndata is too small, we still want to produce some meaningful error
if (data.length <= 4) {

if (data.length < 4) {
revert MalformedCalldata();
}

Expand Down
4 changes: 4 additions & 0 deletions l1-contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export default {
enabled: process.env.TEST_CONTRACTS_FORK === "1",
},
},
local: {
url: "http://127.0.0.1:8545/",
accounts: ["0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"]

Check failure on line 52 in l1-contracts/hardhat.config.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",·"0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"]` with `⏎········"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",⏎········"0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d",⏎······],`

Check failure on line 52 in l1-contracts/hardhat.config.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",·"0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"]` with `⏎········"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",⏎········"0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d",⏎······],`

Check failure on line 52 in l1-contracts/hardhat.config.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",·"0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d"]` with `⏎········"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",⏎········"0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d",⏎······],`
}

Check failure on line 53 in l1-contracts/hardhat.config.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `,`

Check failure on line 53 in l1-contracts/hardhat.config.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `,`

Check failure on line 53 in l1-contracts/hardhat.config.ts

View workflow job for this annotation

GitHub Actions / lint

Insert `,`
},
etherscan: {
apiKey: process.env.MISC_ETHERSCAN_API_KEY,
Expand Down
32 changes: 16 additions & 16 deletions l1-contracts/test/test_config/constant/hardhat.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,96 +3,96 @@
"name": "DAI",
"symbol": "DAI",
"decimals": 18,
"address": "0x4fE0EE70D78132fBb5C68C1d5e0020f3c05542f2"
"address": "0x3202935CA01eADd2F0B4e7aA23EFA52315121172"
},
{
"name": "wBTC",
"symbol": "wBTC",
"decimals": 8,
"address": "0x3202935CA01eADd2F0B4e7aA23EFA52315121172"
"address": "0xe73a1c05498e492f182f9B3E3cd65b2F9f52eE94"
},
{
"name": "BAT",
"symbol": "BAT",
"decimals": 18,
"address": "0xe73a1c05498e492f182f9B3E3cd65b2F9f52eE94"
"address": "0x7aAE2ee8317b384aDE246664933A147411b60045"
},
{
"name": "GNT",
"symbol": "GNT",
"decimals": 18,
"address": "0x7aAE2ee8317b384aDE246664933A147411b60045"
"address": "0x02a344d1e31e92e39c2681937645F1d668C37d4e"
},
{
"name": "MLTT",
"symbol": "MLTT",
"decimals": 18,
"address": "0x02a344d1e31e92e39c2681937645F1d668C37d4e"
"address": "0x28033f8EdB2F43747E55401C4a3E3b4b2cF5146C"
},
{
"name": "DAIK",
"symbol": "DAIK",
"decimals": 18,
"address": "0x28033f8EdB2F43747E55401C4a3E3b4b2cF5146C"
"address": "0x147dCc3a8E99794C2Ec79EaF1a142324D6778255"
},
{
"name": "wBTCK",
"symbol": "wBTCK",
"decimals": 8,
"address": "0x147dCc3a8E99794C2Ec79EaF1a142324D6778255"
"address": "0x74cA8715E29196Bfbcd7444B09203d22dDaF7d1a"
},
{
"name": "BATK",
"symbol": "BATS",
"decimals": 18,
"address": "0x74cA8715E29196Bfbcd7444B09203d22dDaF7d1a"
"address": "0x2eAf3eac597d23db3A8427329482aE47935141d9"
},
{
"name": "GNTK",
"symbol": "GNTS",
"decimals": 18,
"address": "0x2eAf3eac597d23db3A8427329482aE47935141d9"
"address": "0x2B1b32d23f2be391280bFbD2B51daB8Ad2a69B9e"
},
{
"name": "MLTTK",
"symbol": "MLTTS",
"decimals": 18,
"address": "0x2B1b32d23f2be391280bFbD2B51daB8Ad2a69B9e"
"address": "0xc2Ca10940Ad80Cd98512B767457bd44713232B5a"
},
{
"name": "DAIL",
"symbol": "DAIL",
"decimals": 18,
"address": "0xc2Ca10940Ad80Cd98512B767457bd44713232B5a"
"address": "0xd6b4CDa9F0Ef6d9F6b35Ab5424df0dD95E6a6D1b"
},
{
"name": "wBTCL",
"symbol": "wBTCP",
"decimals": 8,
"address": "0xd6b4CDa9F0Ef6d9F6b35Ab5424df0dD95E6a6D1b"
"address": "0x15CD4a1C10AE2D3727Dad680a1966947931588C9"
},
{
"name": "BATL",
"symbol": "BATW",
"decimals": 18,
"address": "0x15CD4a1C10AE2D3727Dad680a1966947931588C9"
"address": "0x45f430CFD5Bf38eCE39f1B9A2930B3fD494619e8"
},
{
"name": "GNTL",
"symbol": "GNTW",
"decimals": 18,
"address": "0x45f430CFD5Bf38eCE39f1B9A2930B3fD494619e8"
"address": "0x801Ab08819573537C0B256d139473eF13482B3Dd"
},
{
"name": "MLTTL",
"symbol": "MLTTW",
"decimals": 18,
"address": "0x801Ab08819573537C0B256d139473eF13482B3Dd"
"address": "0xf55F3af54B9a507Bd0260e5844C1648921214745"
},
{
"name": "Wrapped Ether",
"symbol": "WETH",
"decimals": 18,
"address": "0xf55F3af54B9a507Bd0260e5844C1648921214745"
"address": "0xed01DF970925Cc0BB427f9E8014449C8a529D303"
}
]
6 changes: 3 additions & 3 deletions l1-contracts/test/unit_tests/custom_base_token.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ describe("Custom base token chain and bridge tests", () => {
)
);

expect(revertReason).equal("ShB not legacy bridge");
expect(revertReason).contains("Unauthorized");
});

it("Should deposit base token successfully direct via bridgehub", async () => {
Expand Down Expand Up @@ -147,13 +147,13 @@ describe("Custom base token chain and bridge tests", () => {
const revertReason = await getCallRevertReason(
l1SharedBridge.connect(randomSigner).finalizeWithdrawal(chainId, 0, 0, 0, "0x", [])
);
expect(revertReason).equal("ShB wrong msg len");
expect(revertReason).contains("MalformedMessage");
});

it("Should revert on finalizing a withdrawal with wrong function selector", async () => {
const revertReason = await getCallRevertReason(
l1SharedBridge.connect(randomSigner).finalizeWithdrawal(chainId, 0, 0, 0, ethers.utils.randomBytes(96), [])
);
expect(revertReason).equal("ShB Incorrect message function selector");
expect(revertReason).contains("InvalidSelector");
});
});
8 changes: 4 additions & 4 deletions l1-contracts/test/unit_tests/governance_test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe("Admin facet tests", function () {
const revertReason = await getCallRevertReason(
adminFacetTest.connect(randomSigner).setValidator(validatorAddress, true)
);
expect(revertReason).equal("Hyperchain: not state transition manager");
expect(revertReason).contains("Unauthorized");
});

it("StateTransitionManager successfully set porter availability", async () => {
Expand All @@ -48,7 +48,7 @@ describe("Admin facet tests", function () {

it("random account fails to set porter availability", async () => {
const revertReason = await getCallRevertReason(adminFacetTest.connect(randomSigner).setPorterAvailability(false));
expect(revertReason).equal("Hyperchain: not state transition manager");
expect(revertReason).contains("Unauthorized");
});

it("StateTransitionManager successfully set priority transaction max gas limit", async () => {
Expand All @@ -64,7 +64,7 @@ describe("Admin facet tests", function () {
const revertReason = await getCallRevertReason(
adminFacetTest.connect(randomSigner).setPriorityTxMaxGasLimit(gasLimit)
);
expect(revertReason).equal("Hyperchain: not state transition manager");
expect(revertReason).contains("Unauthorized");
});

describe("change admin", function () {
Expand Down Expand Up @@ -92,7 +92,7 @@ describe("Admin facet tests", function () {

it("failed to accept admin from not proposed account", async () => {
const revertReason = await getCallRevertReason(adminFacetTest.connect(randomSigner).acceptAdmin());
expect(revertReason).equal("n4");
expect(revertReason).contains("Unauthorized");
});

it("accept admin from proposed account", async () => {
Expand Down
18 changes: 9 additions & 9 deletions l1-contracts/test/unit_tests/l1_shared_bridge_test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe("Shared Bridge tests", () => {
{ value: mintValue }
)
);
expect(revertReason).equal("6T");
expect(revertReason).contains("EmptyDeposit");
});

it("Should deposit successfully", async () => {
Expand Down Expand Up @@ -129,7 +129,7 @@ describe("Shared Bridge tests", () => {
const revertReason = await getCallRevertReason(
l1SharedBridge.connect(randomSigner).finalizeWithdrawal(chainId, 0, 0, 0, "0x", [ethers.constants.HashZero])
);
expect(revertReason).equal("ShB wrong msg len");
expect(revertReason).contains("MalformedMessage");
});

it("Should revert on finalizing a withdrawal with wrong message length", async () => {
Expand All @@ -145,14 +145,14 @@ describe("Shared Bridge tests", () => {
[ethers.constants.HashZero]
)
);
expect(revertReason).equal("ShB wrong msg len 2");
expect(revertReason).contains("MalformedMessage");
});

it("Should revert on finalizing a withdrawal with wrong function selector", async () => {
const revertReason = await getCallRevertReason(
l1SharedBridge.connect(randomSigner).finalizeWithdrawal(chainId, 0, 0, 0, ethers.utils.randomBytes(96), [])
);
expect(revertReason).equal("ShB Incorrect message function selector");
expect(revertReason).contains("InvalidSelector");
});

it("Should deposit erc20 token successfully", async () => {
Expand Down Expand Up @@ -183,7 +183,7 @@ describe("Shared Bridge tests", () => {
const revertReason = await getCallRevertReason(
l1SharedBridge.connect(randomSigner).finalizeWithdrawal(chainId, 0, 0, 0, "0x", [ethers.constants.HashZero])
);
expect(revertReason).equal("ShB wrong msg len");
expect(revertReason).contains("MalformedMessage");
});

it("Should revert on finalizing a withdrawal with wrong function signature", async () => {
Expand All @@ -192,7 +192,7 @@ describe("Shared Bridge tests", () => {
.connect(randomSigner)
.finalizeWithdrawal(chainId, 0, 0, 0, ethers.utils.randomBytes(76), [ethers.constants.HashZero])
);
expect(revertReason).equal("ShB Incorrect message function selector");
expect(revertReason).contains("InvalidSelector");
});

it("Should revert on finalizing a withdrawal with wrong batch number", async () => {
Expand All @@ -206,7 +206,7 @@ describe("Shared Bridge tests", () => {
const revertReason = await getCallRevertReason(
l1SharedBridge.connect(randomSigner).finalizeWithdrawal(chainId, 10, 0, 0, l2ToL1message, [])
);
expect(revertReason).equal("xx");
expect(revertReason).contains("BatchNotExecuted");
});

it("Should revert on finalizing a withdrawal with wrong length of proof", async () => {
Expand All @@ -220,7 +220,7 @@ describe("Shared Bridge tests", () => {
const revertReason = await getCallRevertReason(
l1SharedBridge.connect(randomSigner).finalizeWithdrawal(chainId, 0, 0, 0, l2ToL1message, [])
);
expect(revertReason).equal("xc");
expect(revertReason).contains("MerklePathEmpty");
});

it("Should revert on finalizing a withdrawal with wrong proof", async () => {
Expand All @@ -236,6 +236,6 @@ describe("Shared Bridge tests", () => {
.connect(randomSigner)
.finalizeWithdrawal(chainId, 0, 0, 0, l2ToL1message, Array(9).fill(ethers.constants.HashZero))
);
expect(revertReason).equal("ShB withd w proof");
expect(revertReason).contains("InvalidProof");
});
});
Loading

0 comments on commit 803695f

Please sign in to comment.