mirror of
https://github.com/Instadapp/dsa-connectors-old.git
synced 2024-07-29 22:47:46 +00:00
added test for CurveGauge;
added ABI for CurveGauge; added MockCurveGauge and MockCurveGaugeMapping;
This commit is contained in:
parent
0f9e5f69f1
commit
8a9ce14a9d
27
contracts/tests/MockCurveGauge.sol
Normal file
27
contracts/tests/MockCurveGauge.sol
Normal file
|
@ -0,0 +1,27 @@
|
|||
pragma solidity ^0.6.0;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import { ConnectCurveGauge } from "../connectors/curve_gauge.sol";
|
||||
|
||||
contract MockCurveGauge is ConnectCurveGauge{
|
||||
address public curveMintorAddr;
|
||||
address public curveGaugeMappingAddr;
|
||||
|
||||
constructor(address _curveMintorAddr, address _curveGaugeMappingAddr) public {
|
||||
curveMintorAddr = _curveMintorAddr;
|
||||
curveGaugeMappingAddr = _curveGaugeMappingAddr;
|
||||
}
|
||||
|
||||
function emitEvent(bytes32 eventCode, bytes memory eventData) override internal {}
|
||||
|
||||
function getCurveGaugeMappingAddr() override internal view returns (address) {
|
||||
return curveGaugeMappingAddr;
|
||||
}
|
||||
|
||||
function getCurveMintorAddr() override internal view returns (address) {
|
||||
return curveMintorAddr;
|
||||
}
|
||||
|
||||
function setUint(uint setId, uint val) override internal {}
|
||||
}
|
||||
|
7
contracts/tests/MockCurveGaugeMapping.sol
Normal file
7
contracts/tests/MockCurveGaugeMapping.sol
Normal file
|
@ -0,0 +1,7 @@
|
|||
pragma solidity ^0.6.0;
|
||||
|
||||
import { CurveGaugeMapping } from "../mapping/curve_gauge_mapping.sol";
|
||||
|
||||
contract MockCurveGaugeMapping is CurveGaugeMapping {
|
||||
modifier isChief override {_;}
|
||||
}
|
149
test/CurveGauge.js
Normal file
149
test/CurveGauge.js
Normal file
|
@ -0,0 +1,149 @@
|
|||
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 MockCurveGauge = artifacts.require('MockCurveGauge');
|
||||
const MockCurveGaugeMapping = artifacts.require('MockCurveGaugeMapping');
|
||||
const erc20ABI = require("./abi/erc20.js");
|
||||
const gaugeABI = require("./abi/curveGauge.json");
|
||||
|
||||
contract("ConnectCurveGauge", async accounts => {
|
||||
const [sender, receiver] = accounts;
|
||||
let mock, mockCurveGauge, mockCurveGaugeMapping;
|
||||
|
||||
before(async function () {
|
||||
mock = await MockContract.new();
|
||||
mockCurveGaugeMapping = await MockCurveGaugeMapping.new();
|
||||
mockCurveGauge = await MockCurveGauge.new(mock.address, mockCurveGaugeMapping.address);
|
||||
// lp_token = new web3.eth.Contract(erc20ABI, mock.address);
|
||||
curveGauge = new web3.eth.Contract(gaugeABI, mock.address)
|
||||
// mocking lp_token
|
||||
let lp_token = await curveGauge.methods.lp_token().encodeABI();
|
||||
await mock.givenMethodReturnAddress(lp_token, mock.address);
|
||||
// mocking crv_token
|
||||
let crv_token = await curveGauge.methods.crv_token().encodeABI();
|
||||
await mock.givenMethodReturnAddress(crv_token, mock.address);
|
||||
// mocking rewarded_token
|
||||
let rewarded_token = await curveGauge.methods.rewarded_token().encodeABI();
|
||||
await mock.givenMethodReturnAddress(rewarded_token, mock.address);
|
||||
|
||||
mockCurveGaugeMapping.addGaugeMapping('compound', mock.address, false);
|
||||
mockCurveGaugeMapping.addGaugeMapping('susd', mock.address, true);
|
||||
})
|
||||
|
||||
it('can deposit into compound gauge', async function() {
|
||||
const tx = await mockCurveGauge.deposit(
|
||||
"compound",
|
||||
10000000,
|
||||
0,
|
||||
0
|
||||
)
|
||||
expectEvent(tx, "LogDeposit", {
|
||||
amount: "10000000",
|
||||
getId: "0",
|
||||
setId: "0"
|
||||
});
|
||||
});
|
||||
|
||||
it('can claim reward from compound gauge', async function() {
|
||||
const tx = await mockCurveGauge.claimReward(
|
||||
"compound",
|
||||
0,
|
||||
0
|
||||
)
|
||||
expectEvent(tx, "LogClaimedReward");
|
||||
});
|
||||
|
||||
it('can withdraw from compound gauge', async function() {
|
||||
const tx = await mockCurveGauge.withdraw(
|
||||
"compound",
|
||||
10000000,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
)
|
||||
expectEvent(tx, "LogClaimedReward");
|
||||
expectEvent(tx, "LogWithdraw", {
|
||||
amount: "10000000",
|
||||
getId: "0",
|
||||
setId: "0"
|
||||
});
|
||||
});
|
||||
|
||||
it('can deposit into susd gauge', async function() {
|
||||
const tx = await mockCurveGauge.deposit(
|
||||
"susd",
|
||||
10000000,
|
||||
0,
|
||||
0
|
||||
)
|
||||
expectEvent(tx, "LogDeposit", {
|
||||
amount: "10000000",
|
||||
getId: "0",
|
||||
setId: "0"
|
||||
});
|
||||
});
|
||||
|
||||
it('can claim reward from susd gauge', async function() {
|
||||
const tx = await mockCurveGauge.claimReward(
|
||||
"susd",
|
||||
0,
|
||||
0
|
||||
)
|
||||
expectEvent(tx, "LogClaimedReward");
|
||||
});
|
||||
|
||||
it('can withdraw from susd gauge', async function() {
|
||||
const tx = await mockCurveGauge.withdraw(
|
||||
"susd",
|
||||
10000000,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
)
|
||||
expectEvent(tx, "LogClaimedReward");
|
||||
expectEvent(tx, "LogWithdraw", {
|
||||
amount: "10000000",
|
||||
getId: "0",
|
||||
setId: "0"
|
||||
});
|
||||
});
|
||||
|
||||
it('cannot deposit into unknown gauge', async function() {
|
||||
const tx = mockCurveGauge.deposit(
|
||||
"unknown",
|
||||
10000000,
|
||||
0,
|
||||
0
|
||||
)
|
||||
await expectRevert(tx, "wrong-gauge-pool-name")
|
||||
});
|
||||
|
||||
it('cannot claim reward from unknown gauge', async function() {
|
||||
const tx = mockCurveGauge.claimReward(
|
||||
"unknown",
|
||||
0,
|
||||
0
|
||||
)
|
||||
await expectRevert(tx, "wrong-gauge-pool-name")
|
||||
});
|
||||
|
||||
it('cannot withdraw from unknown gauge', async function() {
|
||||
const tx = mockCurveGauge.withdraw(
|
||||
"unknown",
|
||||
10000000,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
)
|
||||
await expectRevert(tx, "wrong-gauge-pool-name")
|
||||
});
|
||||
})
|
1
test/abi/curveGauge.json
Normal file
1
test/abi/curveGauge.json
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user