diff --git a/contracts/connectors/curve_vesting.sol b/contracts/connectors/curve_vesting.sol index a891be6..b6f1076 100644 --- a/contracts/connectors/curve_vesting.sol +++ b/contracts/connectors/curve_vesting.sol @@ -13,14 +13,14 @@ contract CurveVestingHelpers is Stores, DSMath{ /** * @dev Return Curve Token Address */ - function getCurveTokenAddr() internal pure returns (address) { + function getCurveTokenAddr() virtual internal view returns (address) { return 0xD533a949740bb3306d119CC777fa900bA034cd52; } /** * @dev Return Curve Vesting Address */ - function getCurveVestingAddr() internal pure returns (address) { + function getCurveVestingAddr() virtual internal view returns (address) { return 0x575CCD8e2D300e2377B43478339E364000318E2c; } } @@ -52,3 +52,8 @@ contract CurveVestingProtocol is CurveVestingHelpers { emitEvent(_eventCode, _eventParam); } } + +contract ConnectCurveVestingProtocol is CurveVestingProtocol { + string public name = "Curve-vesting-v1"; +} + diff --git a/contracts/tests/MockCurveVesting.sol b/contracts/tests/MockCurveVesting.sol new file mode 100644 index 0000000..77e07a9 --- /dev/null +++ b/contracts/tests/MockCurveVesting.sol @@ -0,0 +1,24 @@ +pragma solidity ^0.6.0; + +import { ConnectCurveVestingProtocol } from "../connectors/curve_vesting.sol"; + +contract MockConnectCurveVestingProtocol is ConnectCurveVestingProtocol{ + address public curveTokenAddr; + address public curveVestingAddr; + + constructor(address _curveVestingAddr, address _curveTokenAddr) public { + curveVestingAddr = _curveVestingAddr; + curveTokenAddr = _curveTokenAddr; + } + + function getCurveTokenAddr() override internal view returns (address) { + return curveTokenAddr; + } + + function getCurveVestingAddr() override internal view returns (address) { + return curveVestingAddr; + } + + function emitEvent(bytes32 eventCode, bytes memory eventData) override internal {} + function setUint(uint setId, uint val) override internal {} +} diff --git a/test/CurveVestingProtocol.js b/test/CurveVestingProtocol.js new file mode 100644 index 0000000..5c71b0d --- /dev/null +++ b/test/CurveVestingProtocol.js @@ -0,0 +1,37 @@ +const { + BN, // Big Number support + expectEvent, // Assertions for emitted events + expectRevert, // Assertions for transactions that should fail + balance, + ether +} = require('@openzeppelin/test-helpers'); + +const MockContract = artifacts.require("MockContract"); +const MockConnectCurveVestingProtocol = artifacts.require('MockConnectCurveVestingProtocol'); +const erc20ABI = require("./abi/erc20.js"); +const curveVestingABI = require("./abi/curveVesting.json"); + +contract("ConnectCurveVestingProtocol", async accounts => { + const [sender, receiver] = accounts; + let mock, token, curveVesting; + + before(async function(){ + mock = await MockContract.new(); + mockConnectCurveVestingProtocol = await MockConnectCurveVestingProtocol.new(mock.address, mock.address) + token = new web3.eth.Contract(erc20ABI, mock.address); + curveVesting = new web3.eth.Contract(curveVestingABI, mock.address); + + // mocking balanceOf + let balanceOf = await token.methods.balanceOf(mockConnectCurveVestingProtocol.address).encodeABI(); + await mock.givenMethodReturnUint(balanceOf, 10000000); + }) + + it('can claim CRV', async function() { + const tx = await mockConnectCurveVestingProtocol.claim( + sender, + 0, + 0 + ) + expectEvent(tx, "LogClaim"); + }); +}) diff --git a/test/abi/curveVesting.json b/test/abi/curveVesting.json new file mode 100644 index 0000000..e7247a0 --- /dev/null +++ b/test/abi/curveVesting.json @@ -0,0 +1 @@ +[{"name":"Fund","inputs":[{"type":"address","name":"recipient","indexed":true},{"type":"uint256","name":"amount","indexed":false}],"anonymous":false,"type":"event"},{"name":"Claim","inputs":[{"type":"address","name":"recipient","indexed":true},{"type":"uint256","name":"claimed","indexed":false}],"anonymous":false,"type":"event"},{"name":"ToggleDisable","inputs":[{"type":"address","name":"recipient","indexed":false},{"type":"bool","name":"disabled","indexed":false}],"anonymous":false,"type":"event"},{"name":"CommitOwnership","inputs":[{"type":"address","name":"admin","indexed":false}],"anonymous":false,"type":"event"},{"name":"ApplyOwnership","inputs":[{"type":"address","name":"admin","indexed":false}],"anonymous":false,"type":"event"},{"outputs":[],"inputs":[{"type":"address","name":"_token"},{"type":"uint256","name":"_start_time"},{"type":"uint256","name":"_end_time"},{"type":"bool","name":"_can_disable"},{"type":"address[4]","name":"_fund_admins"}],"stateMutability":"nonpayable","type":"constructor"},{"name":"add_tokens","outputs":[],"inputs":[{"type":"uint256","name":"_amount"}],"stateMutability":"nonpayable","type":"function","gas":39108},{"name":"fund","outputs":[],"inputs":[{"type":"address[100]","name":"_recipients"},{"type":"uint256[100]","name":"_amounts"}],"stateMutability":"nonpayable","type":"function","gas":3962646},{"name":"toggle_disable","outputs":[],"inputs":[{"type":"address","name":"_recipient"}],"stateMutability":"nonpayable","type":"function","gas":40280},{"name":"disable_can_disable","outputs":[],"inputs":[],"stateMutability":"nonpayable","type":"function","gas":21295},{"name":"disable_fund_admins","outputs":[],"inputs":[],"stateMutability":"nonpayable","type":"function","gas":21325},{"name":"vestedSupply","outputs":[{"type":"uint256","name":""}],"inputs":[],"stateMutability":"view","type":"function","gas":4468},{"name":"lockedSupply","outputs":[{"type":"uint256","name":""}],"inputs":[],"stateMutability":"view","type":"function","gas":5465},{"name":"vestedOf","outputs":[{"type":"uint256","name":""}],"inputs":[{"type":"address","name":"_recipient"}],"stateMutability":"view","type":"function","gas":5163},{"name":"balanceOf","outputs":[{"type":"uint256","name":""}],"inputs":[{"type":"address","name":"_recipient"}],"stateMutability":"view","type":"function","gas":6275},{"name":"lockedOf","outputs":[{"type":"uint256","name":""}],"inputs":[{"type":"address","name":"_recipient"}],"stateMutability":"view","type":"function","gas":6305},{"name":"claim","outputs":[],"inputs":[],"stateMutability":"nonpayable","type":"function"},{"name":"claim","outputs":[],"inputs":[{"type":"address","name":"addr"}],"stateMutability":"nonpayable","type":"function"},{"name":"commit_transfer_ownership","outputs":[{"type":"bool","name":""}],"inputs":[{"type":"address","name":"addr"}],"stateMutability":"nonpayable","type":"function","gas":38032},{"name":"apply_transfer_ownership","outputs":[{"type":"bool","name":""}],"inputs":[],"stateMutability":"nonpayable","type":"function","gas":38932},{"name":"token","outputs":[{"type":"address","name":""}],"inputs":[],"stateMutability":"view","type":"function","gas":1601},{"name":"start_time","outputs":[{"type":"uint256","name":""}],"inputs":[],"stateMutability":"view","type":"function","gas":1631},{"name":"end_time","outputs":[{"type":"uint256","name":""}],"inputs":[],"stateMutability":"view","type":"function","gas":1661},{"name":"initial_locked","outputs":[{"type":"uint256","name":""}],"inputs":[{"type":"address","name":"arg0"}],"stateMutability":"view","type":"function","gas":1845},{"name":"total_claimed","outputs":[{"type":"uint256","name":""}],"inputs":[{"type":"address","name":"arg0"}],"stateMutability":"view","type":"function","gas":1875},{"name":"initial_locked_supply","outputs":[{"type":"uint256","name":""}],"inputs":[],"stateMutability":"view","type":"function","gas":1751},{"name":"unallocated_supply","outputs":[{"type":"uint256","name":""}],"inputs":[],"stateMutability":"view","type":"function","gas":1781},{"name":"can_disable","outputs":[{"type":"bool","name":""}],"inputs":[],"stateMutability":"view","type":"function","gas":1811},{"name":"disabled_at","outputs":[{"type":"uint256","name":""}],"inputs":[{"type":"address","name":"arg0"}],"stateMutability":"view","type":"function","gas":1995},{"name":"admin","outputs":[{"type":"address","name":""}],"inputs":[],"stateMutability":"view","type":"function","gas":1871},{"name":"future_admin","outputs":[{"type":"address","name":""}],"inputs":[],"stateMutability":"view","type":"function","gas":1901},{"name":"fund_admins_enabled","outputs":[{"type":"bool","name":""}],"inputs":[],"stateMutability":"view","type":"function","gas":1931},{"name":"fund_admins","outputs":[{"type":"bool","name":""}],"inputs":[{"type":"address","name":"arg0"}],"stateMutability":"view","type":"function","gas":2115}]