From 8bf8f7dd025eaab1ebcf7a1b5eb109299ee40e0c Mon Sep 17 00:00:00 2001 From: Nicholas Addison Date: Tue, 30 Apr 2024 09:27:16 +1000 Subject: [PATCH] moved more logic into native staking fixture --- contracts/test/_fixture.js | 14 ++++++++++++-- .../strategies/nativeSsvStaking.fork-test.js | 16 +--------------- contracts/utils/ssv.js | 8 ++++++-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/contracts/test/_fixture.js b/contracts/test/_fixture.js index 466bdbf0b7..a3867bd7c0 100644 --- a/contracts/test/_fixture.js +++ b/contracts/test/_fixture.js @@ -1551,14 +1551,24 @@ async function nativeStakingSSVStrategyFixture() { }); if (isFork) { - const { oethVault, weth, nativeStakingSSVStrategy, timelock } = fixture; + const { oethVault, weth, nativeStakingSSVStrategy, ssv, timelock } = + fixture; await oethVault .connect(timelock) .setAssetDefaultStrategy(weth.address, nativeStakingSSVStrategy.address); - fixture.validatorRegistrator = await ethers.provider.getSigner( + // The Defender Relayer + fixture.validatorRegistrator = await impersonateAndFund( addresses.mainnet.validatorRegistrator ); + + // Fund some SSV to the native staking strategy + const ssvWhale = await impersonateAndFund( + "0xf977814e90da44bfa03b6295a0616a897441acec" // Binance 8 + ); + await ssv + .connect(ssvWhale) + .transfer(nativeStakingSSVStrategy.address, oethUnits("100")); } else { const { governorAddr } = await getNamedAccounts(); const { oethVault, weth, nativeStakingSSVStrategy } = fixture; diff --git a/contracts/test/strategies/nativeSsvStaking.fork-test.js b/contracts/test/strategies/nativeSsvStaking.fork-test.js index 9aa5101082..2a0cb82100 100644 --- a/contracts/test/strategies/nativeSsvStaking.fork-test.js +++ b/contracts/test/strategies/nativeSsvStaking.fork-test.js @@ -117,21 +117,6 @@ describe("ForkTest: Native SSV Staking Strategy", function () { "0x0d12c28849771f3f946d8d705a1f73683d97add9edaec5e6b30650cc03bc57d5", }; - beforeEach(async () => { - const { nativeStakingSSVStrategy, ssv } = fixture; - // Add some ETH to the Defender Relayer account - // TODO this can be removed once the account is funded on mainnet - await impersonateAndFund(addresses.mainnet.validatorRegistrator, 1); - - // Fund some SSV to the native staking strategy - const ssvWhale = await impersonateAndFund( - "0xf977814e90da44bfa03b6295a0616a897441acec" // Binance 8 - ); - await ssv - .connect(ssvWhale) - .transfer(nativeStakingSSVStrategy.address, oethUnits("100")); - }); - it("Should register and staked 32 ETH by validator registrator", async () => { const { weth, domen, nativeStakingSSVStrategy, validatorRegistrator } = fixture; @@ -149,6 +134,7 @@ describe("ForkTest: Native SSV Staking Strategy", function () { chainId: 1, ssvNetwork: addresses.mainnet.SSVNetwork, }); + // const cluster = ["0", "0", "0", true, "0"]; const stakeAmount = oethUnits("32"); // Register a new validator with the SSV Network diff --git a/contracts/utils/ssv.js b/contracts/utils/ssv.js index e5ca31cfba..1177cbc749 100644 --- a/contracts/utils/ssv.js +++ b/contracts/utils/ssv.js @@ -1,10 +1,12 @@ -const { logTxDetails } = require("../utils/txLogger"); const { parseUnits, formatUnits } = require("ethers/lib/utils"); const { ClusterScanner, NonceScanner } = require("ssv-scanner"); const { SSVKeys, KeyShares, KeySharesItem } = require("ssv-keys"); const path = require("path"); const fsp = require("fs").promises; +const { isForkWithLocalNode } = require("../test/helpers"); +const { logTxDetails } = require("../utils/txLogger"); + const log = require("../utils/logger")("utils:ssv"); const depositSSV = async (options) => { @@ -126,7 +128,9 @@ const getClusterInfo = async ({ }) => { const ssvNetworkName = chainId === 1 ? "MAINNET" : "HOLESKY"; log(`SSV network: ${ssvNetworkName}`); - const providerUrl = process.env.PROVIDER_URL; + const providerUrl = isForkWithLocalNode + ? "http://localhost:8545/" + : process.env.PROVIDER_URL; log(`Provider URL: ${providerUrl}`); const params = {