Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
RuslanProgrammer committed Sep 17, 2024
1 parent e57fc75 commit 336e26e
Show file tree
Hide file tree
Showing 8 changed files with 4,127 additions and 443 deletions.
5 changes: 0 additions & 5 deletions smart-contracts/.mocharc.json

This file was deleted.

4 changes: 4 additions & 0 deletions smart-contracts/.solcover.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
skipFiles: ['mock', 'interfaces'],
configureYulOptimizer: true,
};
1 change: 0 additions & 1 deletion smart-contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ npx hardhat help
npx hardhat test
REPORT_GAS=true npx hardhat test
npx hardhat node
npx hardhat ignition deploy ./ignition/modules/Lock.ts
```
45 changes: 16 additions & 29 deletions smart-contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import '@nomicfoundation/hardhat-chai-matchers';
import '@nomicfoundation/hardhat-ethers';
import '@nomicfoundation/hardhat-ignition-viem';
import '@nomicfoundation/hardhat-toolbox-viem';
import '@nomicfoundation/hardhat-verify';
import '@solarity/hardhat-gobind';
import '@solarity/hardhat-markup';
import '@solarity/hardhat-migrate';
import '@typechain/hardhat';
import 'dotenv/config';
import type { HardhatUserConfig } from 'hardhat/config';
import * as dotenv from 'dotenv';
import { HardhatUserConfig } from 'hardhat/types';
import 'solidity-coverage';
import 'tsconfig-paths/register';

dotenv.config();

function typechainTarget() {
const target = process.env.TYPECHAIN_TARGET;

Expand All @@ -23,45 +25,30 @@ const config: HardhatUserConfig = {
networks: {
hardhat: {
initialDate: '2024-07-15T01:00:00.000Z',
gas: 'auto', // required for tests where two transactions should be mined in the same block
// gas: 'auto', // required for tests where two transactions should be mined in the same block
// loggingEnabled: true,
// mining: {
// auto: true,
// interval: 10_000,
// },
},
localhost: {
url: 'http://127.0.0.1:8545',
initialDate: '1970-01-01T00:00:00Z',
gasMultiplier: 1.2,
timeout: 1000000000000000,
},
},
solidity: {
version: '0.8.24',
settings: {
optimizer: {
enabled: true,
runs: 1000,
details: {
yul: true,
constantOptimizer: true,
},
runs: 200,
},
// viaIR: true,
evmVersion: 'paris',
},
},
mocha: {
// reporter: "",
},
gasReporter: {
enabled: process.env.REPORT_GAS ? true : false,
// outputJSON: true,
// outputJSONFile: "gas.json",
coinmarketcap: process.env.COINMARKETCAP_API_KEY,
// reportPureAndViewMethods: true,
// darkMode: true,
currency: 'USD',
// offline: true,
// L2Etherscan: process.env.ETHERSCAN_API_KEY,
// L2: "arbitrum",
// L1Etherscan: process.env.ETHERSCAN_API_KEY,
// L1: "ethereum",
},
gobind: {
outdir: './bindings/go',
onlyFiles: ['./contracts'],
Expand Down
70 changes: 36 additions & 34 deletions smart-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
"compile": "hardhat compile",
"test": "hardhat test",
"test:gas": "REPORT_GAS=true hardhat test",
"coverage": "SOLIDITY_COVERAGE=true hardhat coverage",
"coverage": "npx hardhat coverage --solcoverjs ./.solcover.ts",
"report": "open ./coverage/index.html",
"verify": "hardhat verify",
"bindings-go": "hardhat gobind",
"node-local": "./node-local.sh",
"format": "prettier --write \"contracts/**/*.sol\"",
"copy-bindings": "cp -r bindings/go/contracts/facets/* ../proxy-router/contracts",
"generate-types": "TYPECHAIN_FORCE=true npx hardhat typechain",
"generate-docs": "npx hardhat markup",
Expand All @@ -25,46 +23,50 @@
"lint-sol": "solhint \"contracts/**/*.sol\""
},
"devDependencies": {
"@metamask/eth-sig-util": "^7.0.3",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.7",
"@nomicfoundation/hardhat-ethers": "^3.0.8",
"@nomicfoundation/hardhat-ignition": "^0.15.2",
"@nomicfoundation/hardhat-ignition-viem": "^0.15.2",
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
"@nomicfoundation/hardhat-toolbox-viem": "^3.0.0",
"@nomicfoundation/hardhat-verify": "^2.0.6",
"@nomicfoundation/hardhat-viem": "^2.0.1",
"@nomicfoundation/ignition-core": "^0.15.2",
"@openzeppelin/contracts": "4.9.2",
"@solarity/hardhat-gobind": "^1.2.2",
"@nomicfoundation/hardhat-network-helpers": "^1.0.11",
"@nomiclabs/hardhat-truffle5": "^2.0.7",
"@nomiclabs/hardhat-web3": "^2.0.0",
"@solarity/hardhat-markup": "^1.0.8",
"@solarity/hardhat-migrate": "2.1.7",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@typechain/ethers-v6": "^0.5.1",
"@typechain/hardhat": "^9.1.0",
"@typechain/truffle-v5": "^8.0.6",
"@typechain/web3-v1": "^6.0.6",
"@typechain/truffle-v5": "^8.0.7",
"@typechain/web3-v1": "^6.0.7",
"@types/chai": "^4.3.19",
"@types/chai-as-promised": "^8.0.0",
"@types/dotenv": "^8.2.0",
"@types/mocha": ">=9.1.0",
"@types/node": ">=18.0.0",
"@types/yargs-parser": "^21.0.3",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/mocha": "^10.0.8",
"@types/node": "^18.19.50",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"chai": "^4.5.0",
"ethers": "^6.13.2",
"hardhat": "^2.22.10",
"hardhat-gas-reporter": "^1.0.9",
"mocha": "^10.7.0",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"hardhat-contract-sizer": "^2.10.0",
"hardhat-gas-reporter": "^1.0.10",
"mocha": "^10.7.3",
"morpheus-smart-contracts": "https://github.com/MorpheusAIs/SmartContracts.git#753accd",
"prettier": "^3.2.5",
"prettier-plugin-solidity": "^1.3.1",
"solhint": "^5.0.1",
"solidity-coverage": "^0.8.12",
"ts-node": "^10.9.1",
"prettier": "^3.3.3",
"prettier-plugin-solidity": "^1.4.1",
"solhint": "^4.5.4",
"solhint-plugin-prettier": "^0.1.0",
"solidity-coverage": "^0.8.13",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.2.2",
"viem": "^2.10.1",
"yargs-parser": "^21.1.1"
"typescript": "^5.6.2",
"web3": "^1.10.4"
},
"dependencies": {
"@solarity/solidity-lib": "^2.7.11",
"typechain": "8.3.2"
"@openzeppelin/contracts": "4.9.2",
"@openzeppelin/contracts-upgradeable": "4.9.2",
"@solarity/hardhat-gobind": "^1.2.2",
"@solarity/solidity-lib": "2.7.6",
"dotenv": "^10.0.0",
"ethers": "^6.13.2",
"hardhat": "^2.22.10",
"typechain": "^8.3.2"
}
}
16 changes: 3 additions & 13 deletions smart-contracts/test/Staking/withdrawReward.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,7 @@ describe('Staking contract - withdrawReward', () => {
//// aliceStakes
await LMR.connect(ALICE).approve(staking, stakingAmount);
const aliceStakeId = await staking.connect(ALICE).stake.staticCall(poolId, stakingAmount, lockDuration);
const tx = await staking.connect(ALICE).stake(poolId, stakingAmount, lockDuration);
const aliceStakeTime = await getCurrentBlockTime();

////
await staking.connect(ALICE).stake(poolId, stakingAmount, lockDuration);

await expect(
staking.connect(ALICE).withdrawReward(poolId, aliceStakeId + 1n, ALICE),
Expand All @@ -141,22 +138,15 @@ describe('Staking contract - withdrawReward', () => {
//// aliceStakes
await LMR.connect(ALICE).approve(staking, stakingAmount);
const aliceStakeId = await staking.connect(ALICE).stake.staticCall(poolId, stakingAmount, lockDuration);
const tx = await staking.connect(ALICE).stake(poolId, stakingAmount, lockDuration);
const aliceStakeTime = await getCurrentBlockTime();

////
await staking.connect(ALICE).stake(poolId, stakingAmount, lockDuration);

await ethers.provider.send('evm_setAutomine', [false]);
await setTime(pool.endDate + 1n);

await staking.connect(ALICE).withdrawReward(poolId, aliceStakeId, ALICE);

await expect(staking.connect(ALICE).withdrawReward(poolId, aliceStakeId, ALICE)).to.be.revertedWithCustomError(
staking,
'NoRewardAvailable',
);

await ethers.provider.send('evm_mine', []);
await ethers.provider.send('evm_setAutomine', [true]);
});
});
});
Loading

0 comments on commit 336e26e

Please sign in to comment.