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

Feature/GBI-2375 - Remaining tests migration #291

Merged
merged 2 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 5 additions & 3 deletions .github/workflows/slither.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ jobs:
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1

- name: Use Node.js 19.6.0
- name: Use Node.js 20.15.1
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
with:
node-version: "19.6.0"
node-version: "20.15.1"

- name: NPM Login
run: npm config set //npm.pkg.github.com/:_authToken ${{ secrets.GITHUB_TOKEN }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm config set //npm.pkg.github.com/:_authToken $GITHUB_TOKEN

- name: Install dependencies
run: npm ci
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repos:
- repo: local
hooks:
- id: code-style
name: Check contact code style
name: Check contract code style
entry: npm run lint:sol
language: system
types: [file]
Expand Down
2 changes: 1 addition & 1 deletion scripts/deployment-utils/deploy-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface LiquidityBridgeContractLibraries {
bridge: string;
}

const BRIDGE_ADDRESS = "0x0000000000000000000000000000000001000006";
export const BRIDGE_ADDRESS = "0x0000000000000000000000000000000001000006";

async function deployProxyLibraries(
network: string
Expand Down
123 changes: 122 additions & 1 deletion test/deployment.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { expect } from "chai";
import hre from "hardhat";
import { ethers } from "hardhat";
import { deployLbcProxy } from "../scripts/deployment-utils/deploy-proxy";
import {
BRIDGE_ADDRESS,
deployLbcProxy,
} from "../scripts/deployment-utils/deploy-proxy";
import { upgradeLbcProxy } from "../scripts/deployment-utils/upgrade-proxy";
import { ZERO_ADDRESS } from "./utils/constants";

describe("LiquidityBridgeContract deployment process should", function () {
let proxyAddress: string;
Expand All @@ -28,4 +32,121 @@ describe("LiquidityBridgeContract deployment process should", function () {
const version = await lbc.version();
expect(version).to.equal("1.3.0");
});

it("validate minimiumCollateral arg in initialize", async () => {
const LiquidityBridgeContract = await ethers.getContractFactory(
"LiquidityBridgeContract",
{
libraries: {
BtcUtils: ZERO_ADDRESS,
SignatureValidator: ZERO_ADDRESS,
Quotes: ZERO_ADDRESS,
},
}
);
const lbc = await LiquidityBridgeContract.deploy();
const MINIMUM_COLLATERAL = ethers.parseEther("0.02");
const RESIGN_DELAY_BLOCKS = 15;
const initializeTx = lbc.initialize(
BRIDGE_ADDRESS,
MINIMUM_COLLATERAL,
1,
50,
RESIGN_DELAY_BLOCKS,
1,
1,
false
);
await expect(initializeTx).to.be.revertedWith("LBC072");
});

it("validate resignDelayBlocks arg in initialize", async () => {
const LiquidityBridgeContract = await ethers.getContractFactory(
"LiquidityBridgeContract",
{
libraries: {
BtcUtils: ZERO_ADDRESS,
SignatureValidator: ZERO_ADDRESS,
Quotes: ZERO_ADDRESS,
},
}
);
const lbc = await LiquidityBridgeContract.deploy();
const MINIMUM_COLLATERAL = ethers.parseEther("0.6");
const RESIGN_DELAY_BLOCKS = 14;
const initializeTx = lbc.initialize(
BRIDGE_ADDRESS,
MINIMUM_COLLATERAL,
1,
50,
RESIGN_DELAY_BLOCKS,
1,
1,
false
);
await expect(initializeTx).to.be.revertedWith("LBC073");
});

it("validate reward percentage arg in initialize", async () => {
const LiquidityBridgeContract = await ethers.getContractFactory(
"LiquidityBridgeContract",
{
libraries: {
BtcUtils: ZERO_ADDRESS,
SignatureValidator: ZERO_ADDRESS,
Quotes: ZERO_ADDRESS,
},
}
);
const MINIMUM_COLLATERAL = ethers.parseEther("0.6");
const RESIGN_DELAY_BLOCKS = 60;

const parameters = {
bridge: BRIDGE_ADDRESS,
minCollateral: MINIMUM_COLLATERAL,
minPegin: 1,
resignBlocks: RESIGN_DELAY_BLOCKS,
dustThreshold: 1,
btcBlockTime: 1,
mainnet: false,
};
const percentages = [
{ value: 0, ok: true },
{ value: 1, ok: true },
{ value: 99, ok: true },
{ value: 100, ok: true },
{ value: 101, ok: false },
];

for (const { value, ok } of percentages) {
const lbc = await LiquidityBridgeContract.deploy();
const initializeTx = lbc.initialize(
parameters.bridge,
parameters.minCollateral,
parameters.minPegin,
value,
parameters.resignBlocks,
parameters.dustThreshold,
parameters.btcBlockTime,
parameters.mainnet
);
if (ok) {
await expect(initializeTx).not.to.be.reverted;
const reinitializeTx = lbc.initialize(
parameters.bridge,
parameters.minCollateral,
parameters.minPegin,
value,
parameters.resignBlocks,
parameters.dustThreshold,
parameters.btcBlockTime,
parameters.mainnet
);
// check that only initializes once
await expect(reinitializeTx).to.be.reverted;
} else {
await expect(initializeTx).to.be.revertedWith("LBC004");
}
}
});
});
Loading
Loading