-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
144 additions
and
78 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 |
---|---|---|
@@ -1,21 +1,26 @@ | ||
{ | ||
"usesRpcPrefix" : false, | ||
"rpc" : "https://api.avax.network/ext/bc/C/rpc", | ||
"chainId" : 43114, | ||
"testBlock" : 24437213, | ||
"testMarkets" : ["DAI", "USDC", "WBTC", "WETH"], | ||
"LendingPoolAddressesProvider" : "0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb", | ||
"DAI" : "0xd586E7F844cEa2F87f50152665BCbc2C279D8d70", | ||
"FRAX" : "0xD24C2Ad096400B6FBcd2ad8B24E7acBc21A1da64", | ||
"MAI" : "0x5c49b268c9841AFF1Cc3B0a418ff5c3442eE3F3b", | ||
"USDC" : "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E", | ||
"USDT" : "0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7", | ||
"AAVE" : "0x63a72806098Bd3D9520cC43356dD78afe5D386D9", | ||
"BTCb" : "0x152b9d0FdC40C096757F570A51E494bd4b943E50", | ||
"LINK" : "0x5947BB275c521040051D82396192181b413227A3", | ||
"sAVAX" : "0x2b2C81e08f1Af8835a78Bb2A90AE924ACE0eA4bE", | ||
"WAVAX" : "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7", | ||
"WBTC" : "0x50b7545627a5162F82A992c33b87aDc75187B218", | ||
"WETH" : "0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB", | ||
"wrappedNative" : "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7" | ||
} | ||
"usesRpcPrefix": false, | ||
"rpc": "https://api.avax.network/ext/bc/C/rpc", | ||
"chainId": 43114, | ||
"testBlock": 24437213, | ||
"testMarkets": [ | ||
"DAI", | ||
"USDC", | ||
"WBTC", | ||
"WETH" | ||
], | ||
"addressesProvider": "0xa97684ead0e402dC232d5A977953DF7ECBaB3CDb", | ||
"DAI": "0xd586E7F844cEa2F87f50152665BCbc2C279D8d70", | ||
"FRAX": "0xD24C2Ad096400B6FBcd2ad8B24E7acBc21A1da64", | ||
"MAI": "0x5c49b268c9841AFF1Cc3B0a418ff5c3442eE3F3b", | ||
"USDC": "0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E", | ||
"USDT": "0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7", | ||
"AAVE": "0x63a72806098Bd3D9520cC43356dD78afe5D386D9", | ||
"BTCb": "0x152b9d0FdC40C096757F570A51E494bd4b943E50", | ||
"LINK": "0x5947BB275c521040051D82396192181b413227A3", | ||
"sAVAX": "0x2b2C81e08f1Af8835a78Bb2A90AE924ACE0eA4bE", | ||
"WAVAX": "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7", | ||
"WBTC": "0x50b7545627a5162F82A992c33b87aDc75187B218", | ||
"WETH": "0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB", | ||
"wrappedNative": "0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7" | ||
} |
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,40 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
pragma solidity ^0.8.17; | ||
|
||
import {MorphoStorage} from "../src/MorphoStorage.sol"; | ||
import {MorphoInternal} from "../src/MorphoInternal.sol"; | ||
|
||
import "./setup/TestSetup.sol"; | ||
|
||
contract TestMorphoInternal is TestSetup, MorphoInternal { | ||
using TestConfig for TestConfig.Config; | ||
|
||
constructor() MorphoStorage(config.load(vm.envString("NETWORK")).getAddress("addressesProvider")) {} | ||
|
||
function testSetPauseStatus() public { | ||
Types.PauseStatuses storage pauseStatuses = _market[dai].pauseStatuses; | ||
assertEq(pauseStatuses.isSupplyPaused, false); | ||
|
||
_setPauseStatus(dai, true); | ||
|
||
assertEq(pauseStatuses.isSupplyPaused, true); | ||
} | ||
|
||
/// TESTS TO ADD: | ||
|
||
// _computeIndexes | ||
// _updateIndexes | ||
// _getUserSupplyBalanceFromIndexes | ||
// _getUserBorrowBalanceFromIndexes | ||
// _getUserSupplyBalance | ||
// _getUserBorrowBalance | ||
|
||
// _assetLiquidityData | ||
// _liquidityDataCollateral | ||
// _liquidityDataDebt | ||
// _liquidityData | ||
|
||
// _updateInDS | ||
// _updateSupplierInDS | ||
// _updateBorrowerInDS | ||
} |
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,50 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
pragma solidity >=0.8.0; | ||
|
||
import "@forge-std/Vm.sol"; | ||
import "@forge-std/StdJson.sol"; | ||
|
||
library TestConfig { | ||
using stdJson for string; | ||
|
||
struct Config { | ||
string json; | ||
} | ||
|
||
Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code"))))); | ||
string private constant CONFIG_PATH = "/config/"; | ||
|
||
function load(Config storage config, string memory network) internal returns (Config storage) { | ||
string memory root = vm.projectRoot(); | ||
string memory path = string(abi.encodePacked(root, CONFIG_PATH, network, ".json")); | ||
|
||
config.json = vm.readFile(path); | ||
|
||
return config; | ||
} | ||
|
||
function getAddress(Config storage config, string memory key) internal view returns (address) { | ||
return config.json.readAddress(string(abi.encodePacked(key))); | ||
} | ||
|
||
function getTestMarkets(Config storage config) internal view returns (address[] memory) { | ||
string[] memory marketNames = config.json.readStringArray(string(abi.encodePacked("testMarkets"))); | ||
address[] memory markets = new address[](marketNames.length); | ||
|
||
for (uint256 i; i < markets.length; i++) { | ||
markets[i] = getAddress(config, marketNames[i]); | ||
} | ||
|
||
return markets; | ||
} | ||
|
||
function createFork(Config storage config) internal returns (uint256 forkId) { | ||
bool rpcPrefixed = stdJson.readBool(config.json, string(abi.encodePacked("usesRpcPrefix"))); | ||
string memory endpoint = rpcPrefixed | ||
? string(abi.encodePacked(config.json.readString(string(abi.encodePacked("rpc"))), vm.envString("ALCHEMY_KEY"))) | ||
: config.json.readString(string(abi.encodePacked("rpc"))); | ||
|
||
forkId = vm.createSelectFork(endpoint, config.json.readUint(string(abi.encodePacked("testBlock")))); | ||
vm.chainId(config.json.readUint(string(abi.encodePacked("chainId")))); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,50 +1,15 @@ | ||
// SPDX-License-Identifier: GNU AGPLv3 | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
pragma solidity >=0.8.0; | ||
|
||
import "@forge-std/Vm.sol"; | ||
import "@forge-std/StdJson.sol"; | ||
import "@forge-std/console2.sol"; | ||
|
||
library TestHelpers { | ||
using stdJson for string; | ||
|
||
Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code"))))); | ||
string private constant CONFIG_PATH = "/config/"; | ||
|
||
function getJsonConfig(string memory network) internal view returns (string memory json) { | ||
string memory root = vm.projectRoot(); | ||
string memory path = string(abi.encodePacked(root, CONFIG_PATH, network, ".json")); | ||
json = vm.readFile(path); | ||
} | ||
|
||
function getAddressFromJson(string memory json, string memory key) internal pure returns (address) { | ||
return json.readAddress(string(abi.encodePacked(key))); | ||
} | ||
|
||
function getTestMarkets(string memory json) internal pure returns (address[] memory) { | ||
string[] memory marketNames = json.readStringArray(string(abi.encodePacked("testMarkets"))); | ||
address[] memory markets = new address[](marketNames.length); | ||
|
||
for (uint256 i; i < markets.length; i++) { | ||
markets[i] = getAddressFromJson(json, marketNames[i]); | ||
} | ||
return markets; | ||
} | ||
|
||
function setForkFromEnv() internal returns (uint256 forkId) { | ||
string memory endpoint = vm.envString("FOUNDRY_ETH_RPC_URL"); | ||
uint256 blockNumber = vm.envUint("FOUNDRY_FORK_BLOCK_NUMBER"); | ||
|
||
forkId = vm.createSelectFork(endpoint, blockNumber); | ||
} | ||
|
||
function setForkFromJson(string memory json) internal returns (uint256 forkId) { | ||
bool rpcPrefixed = stdJson.readBool(json, string(abi.encodePacked("usesRpcPrefix"))); | ||
string memory endpoint = rpcPrefixed | ||
? string(abi.encodePacked(json.readString(string(abi.encodePacked("rpc"))), vm.envString("ALCHEMY_KEY"))) | ||
: json.readString(string(abi.encodePacked("rpc"))); | ||
|
||
forkId = vm.createSelectFork(endpoint, json.readUint(string(abi.encodePacked("testBlock")))); | ||
vm.chainId(json.readUint(string(abi.encodePacked("chainId")))); | ||
} | ||
} |
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