-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from lidofinance/test/lido
Lido staking tests
- Loading branch information
Showing
16 changed files
with
746 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
// Place your lido-core workspace snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and | ||
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope | ||
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is | ||
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | ||
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. | ||
// Placeholders with the same ids are connected. | ||
// Example: | ||
"Print to console": { | ||
"scope": "javascript,typescript", | ||
"prefix": "log", | ||
"body": ["console.log('$1');", "$2"], | ||
"description": "Log output to console", | ||
}, | ||
"Create a context": { | ||
"scope": "javascript,typescript", | ||
"prefix": "ctx", | ||
"body": ["context(\"$1\", () => {\n\t$2\n});"], | ||
"description": "Create a context", | ||
}, | ||
"Create a test": { | ||
"scope": "javascript,typescript", | ||
"prefix": "it", | ||
"body": ["it(\"$1\", async () => {\n\t$2\n});"], | ||
"description": "Create a test", | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { bigintToHex } from "bigint-conversion"; | ||
import { ethers } from "hardhat"; | ||
|
||
import { HardhatEthersSigner } from "@nomicfoundation/hardhat-ethers/signers"; | ||
|
||
import { getNetworkName } from "./client"; | ||
|
||
export async function impersonate(address: string, balance?: bigint): Promise<HardhatEthersSigner> { | ||
const networkName = await getNetworkName(); | ||
|
||
await ethers.provider.send(`${networkName}_impersonateAccount`, [address]); | ||
|
||
if (balance) { | ||
await ethers.provider.send(`${networkName}_setBalance`, [address, "0x" + bigintToHex(balance)]); | ||
} | ||
|
||
return ethers.getSigner(address); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { ethers } from "hardhat"; | ||
|
||
export async function getNetworkName(): Promise<string> { | ||
let clientVersion = await ethers.provider.send("web3_clientVersion"); | ||
|
||
if (typeof clientVersion !== "string") { | ||
throw new Error("Failed to retrieve client version!"); | ||
} | ||
|
||
clientVersion = clientVersion.toLowerCase(); | ||
if (clientVersion.includes("hardhat")) return "hardhat"; | ||
if (clientVersion.includes("anvil")) return "anvil"; | ||
|
||
throw new Error("Unexpected client!"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
// for testing purposes only | ||
pragma solidity 0.4.24; | ||
|
||
|
||
contract StakingRouterMinimalApiForLido { | ||
|
||
function getWithdrawalCredentials() external view returns(bytes32) { | ||
return 0x010000000000000000000000b9d7934878b5fb9610b3fe8a5e441e8fad7e293f; // Lido Withdrawal Creds | ||
} | ||
|
||
function getTotalFeeE4Precision() external view returns(uint16) { | ||
return 1000; // 10% | ||
} | ||
|
||
function TOTAL_BASIS_POINTS() external view returns(uint256) { | ||
return 10000; // 100% | ||
} | ||
|
||
function getStakingFeeAggregateDistributionE4Precision() external view returns( | ||
uint16 treasuryFee, | ||
uint16 modulesFee | ||
) { | ||
treasuryFee = 500; | ||
modulesFee = 500; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
test/0.4.24/contracts/WithdrawalQueueMinimalApiForLido.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
// for testing purposes only | ||
pragma solidity 0.4.24; | ||
|
||
|
||
contract WithdrawalQueueMinimalApiForLido { | ||
bool public isBunkerModeActive; | ||
uint256 public unfinalizedStETH; | ||
|
||
function _setBunkerMode(bool active) external { | ||
isBunkerModeActive = active; | ||
} | ||
|
||
function _setUnfinalizedStETH(uint256 amount) external { | ||
unfinalizedStETH = amount; | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.