Skip to content

Commit

Permalink
fix: fix for live tests with paused contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
Van0k committed Mar 27, 2024
1 parent 814a6c2 commit 53b1efb
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions contracts/test/suites/LiveTestHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// (c) Gearbox Foundation, 2023.
pragma solidity ^0.8.10;

import {Pausable} from "@openzeppelin/contracts/security/Pausable.sol";

import {ICreditManagerV3} from "@gearbox-protocol/core-v3/contracts/interfaces/ICreditManagerV3.sol";
import {ICreditFacadeV3} from "@gearbox-protocol/core-v3/contracts/interfaces/ICreditFacadeV3.sol";
import {IVersion} from "@gearbox-protocol/core-v2/contracts/interfaces/IVersion.sol";
Expand Down Expand Up @@ -99,18 +101,26 @@ contract LiveTestHelper is IntegrationTestHelper {
} catch {}

if (creditManagerToAttach != address(0)) {
_attachCreditManager(creditManagerToAttach);
_;
console.log("Successfully ran tests on attached CM: %s", address(creditManager));
if (_checkFunctionalSuite(creditManagerToAttach)) {
_attachCreditManager(creditManagerToAttach);
_;
console.log("Successfully ran tests on attached CM: %s", creditManagerToAttach);
} else {
console.log("Pool or facade for attached CM paused, skipping: %s", creditManagerToAttach);
}
} else {
address[] memory cms = cr.getCreditManagers();
uint256 len = cms.length;
for (uint256 i = 0; i < len; ++i) {
if (IVersion(cms[i]).version() >= 3_00) {
uint256 snapshot = vm.snapshot();
_attachCreditManager(cms[i]);
_;
console.log("Successfully ran tests on attached CM: %s", address(creditManager));
if (_checkFunctionalSuite(cms[i])) {
_attachCreditManager(cms[i]);
_;
console.log("Successfully ran tests on attached CM: %s", cms[i]);
} else {
console.log("Pool or facade for attached CM paused, skipping: %s", cms[i]);
}
vm.revertTo(snapshot);
}
}
Expand Down Expand Up @@ -314,6 +324,13 @@ contract LiveTestHelper is IntegrationTestHelper {
}
}

function _checkFunctionalSuite(address creditManager) internal view returns (bool) {
address pool = ICreditManagerV3(creditManager).pool();
address creditFacade = ICreditManagerV3(creditManager).creditFacade();

return !Pausable(pool).paused() && !Pausable(creditFacade).paused();
}

function _setUp() public virtual liveTest {
// lts = new LiveEnvTestSuite();
// MAINNET_CONFIGURATOR = lts.ROOT_ADDRESS();
Expand Down

0 comments on commit 53b1efb

Please sign in to comment.