-
Notifications
You must be signed in to change notification settings - Fork 1
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 #478 from 00labs/synpress-updates
Synpress test support
- Loading branch information
Showing
9 changed files
with
223 additions
and
14 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,2 @@ | ||
LOCALHOST_CHAIN_ID= | ||
LOCALHOST_MNEMONIC_PHRASE= |
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,66 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
pragma solidity 0.8.23; | ||
|
||
import {ERC20, ERC20Permit} from "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol"; | ||
import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; | ||
import {EnumerableSet} from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; | ||
|
||
contract MockToken18Decimal is ERC20Permit, IERC165 { | ||
using EnumerableSet for EnumerableSet.AddressSet; | ||
|
||
/// Transfers to these addresses will fail and return `false` so that we can test transfer failure handling. | ||
EnumerableSet.AddressSet internal _softFailBlocklist; | ||
/// Transfers to these addresses will fail and revert with an error so that we can test transfer failure handling. | ||
EnumerableSet.AddressSet internal _revertingBlocklist; | ||
|
||
constructor() ERC20Permit("TestToken") ERC20("TestToken", "USDC") { | ||
_mint(msg.sender, 1000 * 10 ** decimals()); | ||
} | ||
|
||
function give1000To(address to) external { | ||
_mint(to, 1000 * 10 ** decimals()); | ||
} | ||
|
||
function give100000To(address to) external { | ||
_mint(to, 100000 * 10 ** decimals()); | ||
} | ||
|
||
function mint(address to, uint256 amount) external { | ||
_mint(to, amount); | ||
} | ||
|
||
function burn(address from, uint256 amount) external { | ||
_burn(from, amount); | ||
} | ||
|
||
function addToSoftFailBlocklist(address addr) external { | ||
_softFailBlocklist.add(addr); | ||
} | ||
|
||
function removeFromSoftFailBlocklist(address addr) external { | ||
_softFailBlocklist.remove(addr); | ||
} | ||
|
||
function addToRevertingBlocklist(address addr) external { | ||
_revertingBlocklist.add(addr); | ||
} | ||
|
||
function removeFromRevertingBlocklist(address addr) external { | ||
_revertingBlocklist.remove(addr); | ||
} | ||
|
||
function supportsInterface(bytes4 interfaceId) external view virtual override returns (bool) { | ||
return interfaceId == 0x36372b07 || interfaceId == 0x01ffc9a7; | ||
} | ||
|
||
function transfer(address to, uint256 amount) public virtual override returns (bool) { | ||
if (_softFailBlocklist.contains(to)) return false; | ||
require(!_revertingBlocklist.contains(to)); | ||
|
||
return super.transfer(to, amount); | ||
} | ||
|
||
function decimals() public view virtual override returns (uint8) { | ||
return 18; | ||
} | ||
} |
Submodule forge-std
updated
11 files
+6 −12 | .github/workflows/ci.yml | |
+3 −1 | .github/workflows/sync.yml | |
+3 −3 | foundry.toml | |
+1 −1 | src/StdAssertions.sol | |
+8 −8 | src/StdChains.sol | |
+1 −1 | src/StdUtils.sol | |
+4 −1 | src/Test.sol | |
+116 −6 | src/Vm.sol | |
+9 −9 | test/StdChains.t.sol | |
+1 −1 | test/StdCheats.t.sol | |
+2 −2 | test/Vm.t.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
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,61 @@ | ||
import { ethers } from "hardhat"; | ||
import moment from "moment"; | ||
import { getAccountSigners } from "../tasks/utils"; | ||
import { toToken } from "../test/TestUtils"; | ||
import { deployPools } from "./deploy-local-test-pools"; | ||
import { LOCAL_PROVIDER, advanceChainBySeconds, advanceChainToTime } from "./utils"; | ||
|
||
(async () => { | ||
try { | ||
const { poolOwner, juniorLender, sentinelServiceAccount, borrowerInactive } = | ||
await getAccountSigners(ethers); | ||
|
||
const contracts = await deployPools(); | ||
|
||
const creditContracts = contracts[0]; | ||
const lpConfig = await creditContracts.poolConfigContract.getLPConfig(); | ||
|
||
// Allow for withdrawals immediately | ||
await creditContracts.poolConfigContract | ||
.connect(poolOwner) | ||
.setLPConfig({ ...lpConfig, ...{ withdrawalLockoutPeriodInDays: 1 } }); | ||
|
||
// Advance time to allow for withdrawals | ||
await advanceChainBySeconds(24 * 60 * 60 + 60); | ||
|
||
// Create redemption request | ||
await creditContracts.juniorTrancheVaultContract | ||
.connect(juniorLender) | ||
.addRedemptionRequest(toToken(10)); | ||
|
||
// Advance time to next epoch | ||
let block = await LOCAL_PROVIDER.getBlock("latest"); | ||
await advanceChainToTime( | ||
moment.unix(block.timestamp).utc().add(1, "month").startOf("month"), | ||
); | ||
|
||
// Process redemption requests by closing epoch | ||
await creditContracts.juniorTrancheVaultContract | ||
.connect(sentinelServiceAccount) | ||
.processYieldForLenders(); | ||
await creditContracts.seniorTrancheVaultContract | ||
.connect(sentinelServiceAccount) | ||
.processYieldForLenders(); | ||
await creditContracts.epochManagerContract.connect(sentinelServiceAccount).closeEpoch(); | ||
|
||
// Revoking allowance for inactive borrower | ||
await creditContracts.mockTokenContract | ||
.connect(borrowerInactive) | ||
.approve(creditContracts.creditContract.address, 0); | ||
await creditContracts.mockTokenContract | ||
.connect(borrowerInactive) | ||
.approve(creditContracts.poolSafeContract.address, 0); | ||
|
||
console.log( | ||
"Pools are deployed. Junior lender is ready to withdraw from the credit line pool", | ||
); | ||
} catch (error) { | ||
console.error(error); | ||
process.exitCode = 1; | ||
} | ||
})(); |
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
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