This repository has been archived by the owner on Oct 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for AccountsDepositWithdrawEndowments facet (#206)
* Create initial test * Add DummyWMatic contract * Add endow closed & InvalidSplit test cases * Add comment * Create dummyWMATIC deploy func * Create consts for valid/invalid requests * Add missing revert cases * Remove unused deployDummyWMATIC * Increase value to 10k * Add test case for deposit with no lock amt * Add test case for deposit with lock amt * Remove redundant index fund deployment * Make DonationMatch inherit IDonationMatching * Add donation match test cases * Remove redundant endowment update in processTokenDeposit * Rename donation match tests * Add skip donation match tests * Add skip donation match tests * Add missing wmatic deposit assertion * Add bps cases * Add missing expect no donation match * Refactor how splitToLiquid is read from registrar * Start work on new test cases when non-index-fund sends requests * Wrap no-locked-amt deposit tests in describe * Add splitToLiquid config to Registrar * Add new 'describe' for charities tests * Add remaining test cases * Separate tests by endow type * Add missing revert case for depositMatic (when WMATIC deposit fails) * Add reversal cases for depositERC20 * Organize depositMatic tests by endow type * Copy paste remaining test cases (commented out) * Remove redundatn 'locked amount' describe * Add index fund sent tests for depositERC20 * Fix+refactor depositMatic tests * Add non-index-fund depositERC20 tests * Fix withdraw to beneficiaryEndowId * Add basic revert cases * Remove dots from revert messages * Add more revert cases (in tokens. loop) * Add reverting test cases for sending tokens to beneficiary * Add successful pass test cases * Add comment * Add test cases including earlyLockedWithdrawFee for both charity&normal.endow * Fix tests * Remove redundant comments/logs from contracts * Revert contract-address.json changes * Test fixes to accommodate SafeERC20 * Remove redundant new line change * Make cur. bal check be >= instead of just > * Remove duplicate VaultType enum
- Loading branch information
Nenad Misic
authored
Jul 19, 2023
1 parent
31e9abc
commit cb32d8c
Showing
5 changed files
with
2,129 additions
and
12 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
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,70 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
// author: @misicnenad | ||
pragma solidity ^0.8.0; | ||
|
||
/** | ||
* Inspired by the official testnet WMATIC code https://mumbai.polygonscan.com/address/0x9c3c9283d3e44854697cd22d3faa240cfb032889#code | ||
*/ | ||
contract DummyWMATIC { | ||
string public name = "Dummy Wrapped Matic"; | ||
string public symbol = "DWMATIC"; | ||
uint8 public decimals = 18; | ||
|
||
event Approval(address indexed src, address indexed guy, uint wad); | ||
event Transfer(address indexed src, address indexed dst, uint wad); | ||
event Deposit(address indexed dst, uint wad); | ||
event Withdrawal(address indexed src, uint wad); | ||
|
||
mapping(address => uint) public balanceOf; | ||
mapping(address => mapping(address => uint)) public allowance; | ||
|
||
fallback() external payable { | ||
deposit(); | ||
} | ||
|
||
receive() external payable { | ||
deposit(); | ||
} | ||
|
||
function deposit() public payable { | ||
balanceOf[msg.sender] += msg.value; | ||
emit Deposit(msg.sender, msg.value); | ||
} | ||
|
||
function withdraw(uint wad) public { | ||
require(balanceOf[msg.sender] >= wad); | ||
balanceOf[msg.sender] -= wad; | ||
payable(msg.sender).transfer(wad); | ||
emit Withdrawal(msg.sender, wad); | ||
} | ||
|
||
function totalSupply() public view returns (uint) { | ||
return address(this).balance; | ||
} | ||
|
||
function approve(address guy, uint wad) public returns (bool) { | ||
allowance[msg.sender][guy] = wad; | ||
emit Approval(msg.sender, guy, wad); | ||
return true; | ||
} | ||
|
||
function transfer(address dst, uint wad) public returns (bool) { | ||
return transferFrom(msg.sender, dst, wad); | ||
} | ||
|
||
function transferFrom(address src, address dst, uint wad) public returns (bool) { | ||
require(balanceOf[src] >= wad); | ||
|
||
if (src != msg.sender && allowance[src][msg.sender] != 0) { | ||
require(allowance[src][msg.sender] >= wad); | ||
allowance[src][msg.sender] -= wad; | ||
} | ||
|
||
balanceOf[src] -= wad; | ||
balanceOf[dst] += wad; | ||
|
||
emit Transfer(src, dst, wad); | ||
|
||
return true; | ||
} | ||
} |
Oops, something went wrong.