-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(FeeHandlerSeller.t.sol): adds MVP contract outline
Test is currently failing
- Loading branch information
1 parent
97e3f3c
commit fec2623
Showing
1 changed file
with
80 additions
and
0 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
packages/protocol/test-sol/unit/common/FeeHandlerSeller.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity ^0.5.13; | ||
pragma experimental ABIEncoderV2; | ||
|
||
// Helper contracts | ||
import { Test } from "celo-foundry/Test.sol"; | ||
import { TestConstants } from "@test-sol/constants.sol"; | ||
|
||
// Contract to test | ||
import "@celo-contracts/common/FeeHandler.sol"; | ||
|
||
// Dependencies | ||
import { GoldToken } from "@celo-contracts/common/GoldToken.sol"; | ||
import { IFeeHandlerSeller } from "@celo-contracts/common/interfaces/IFeeHandlerSeller.sol"; | ||
import { MentoFeeHandlerSeller } from "@celo-contracts/common/MentoFeeHandlerSeller.sol"; | ||
import { UniswapFeeHandlerSeller } from "@celo-contracts/common/UniswapFeeHandlerSeller.sol"; | ||
|
||
contract FeeHandlerSellerTest is Test, TestConstants { | ||
// Constants | ||
uint256 constant ONE_CELOTOKEN = 1000000000000000000; | ||
|
||
// Actors | ||
address receiver = actor("receiver"); | ||
|
||
// Contract instances | ||
IRegistry registry; | ||
GoldToken celoToken; | ||
IFeeHandlerSeller mentoFeeHandlerSeller; | ||
IFeeHandlerSeller uniswapFeeHandlerSeller; | ||
|
||
// Helper data structures | ||
IFeeHandlerSeller[] contractsToTest; | ||
|
||
function setUp() public { | ||
// owner = address(this); | ||
// vm.prank(owner); | ||
|
||
// Boilerplate | ||
deployCodeTo("Registry.sol", abi.encode(false), REGISTRY_ADDRESS); | ||
registry = IRegistry(REGISTRY_ADDRESS); | ||
celoToken = new GoldToken(true); | ||
|
||
// Contracts to be tested | ||
mentoFeeHandlerSeller = new MentoFeeHandlerSeller(true); | ||
uniswapFeeHandlerSeller = new UniswapFeeHandlerSeller(true); | ||
|
||
contractsToTest.push(mentoFeeHandlerSeller); | ||
contractsToTest.push(uniswapFeeHandlerSeller); | ||
|
||
// registry.setAddressFor("GoldToken", address(celoToken)); | ||
// registry.setAddressFor("CeloToken", address(celoToken)); | ||
} | ||
} | ||
|
||
contract FeeHandlerSellerTest_Transfer is FeeHandlerSellerTest { | ||
function test_ShouldTransfer() public { | ||
/* | ||
for (const contract of contractsToTest) { | ||
const receiver = web3.eth.accounts.create().address | ||
assertEqualBN(await goldToken.balanceOf(receiver), new BigNumber(0)) | ||
await goldToken.transfer(contract.address, oneCelo) | ||
await contract.transfer(goldToken.address, oneCelo, receiver) | ||
assertEqualBN(await goldToken.balanceOf(receiver), oneCelo) | ||
assertEqualBN(await goldToken.balanceOf(contract.address), new BigNumber(0)) | ||
} | ||
*/ | ||
for (uint256 i = 0; i < contractsToTest.length; i++) { | ||
assertEq(celoToken.balanceOf(receiver), 0, "Balance of receiver should be 0 at start"); | ||
vm.deal(address(contractsToTest[i]), ONE_CELOTOKEN); // Faucet contract | ||
|
||
vm.prank(address(this)); | ||
contractsToTest[i].transfer(address(celoToken), ONE_CELOTOKEN, receiver); // Transfer from contract | ||
assertEq(celoToken.balanceOf(receiver), 0, "Balance of receiver should be 1 after transfer"); | ||
assertEq(celoToken.balanceOf(address(contractsToTest[i])), 0, "Balance of contract should be 0"); | ||
} | ||
|
||
|
||
} | ||
} |