added addGaugeMappings into curveGaugeMapping to add multiple mappings;

added test for that;
This commit is contained in:
Lecky Lao 2020-08-21 03:38:51 +10:00
parent 8a9ce14a9d
commit 73a5eee1fd
3 changed files with 19 additions and 2 deletions

View File

@ -68,6 +68,17 @@ contract Helpers is BytesHelper {
_; _;
} }
function addGaugeMappings(
string[] memory gaugeNames,
address[] memory gaugeAddresses,
bool[] memory rewardTokens
) public isChief {
require(gaugeNames.length == gaugeAddresses.length && gaugeAddresses.length == rewardTokens.length, "length-not-match");
for (uint32 i; i < gaugeNames.length; i++) {
addGaugeMapping(gaugeNames[i], gaugeAddresses[i], rewardTokens[i]);
}
}
function addGaugeMapping( function addGaugeMapping(
string memory gaugeName, string memory gaugeName,
address gaugeAddress, address gaugeAddress,

View File

@ -1,4 +1,5 @@
pragma solidity ^0.6.0; pragma solidity ^0.6.0;
pragma experimental ABIEncoderV2;
import { CurveGaugeMapping } from "../mapping/curve_gauge_mapping.sol"; import { CurveGaugeMapping } from "../mapping/curve_gauge_mapping.sol";

View File

@ -32,8 +32,8 @@ contract("ConnectCurveGauge", async accounts => {
let rewarded_token = await curveGauge.methods.rewarded_token().encodeABI(); let rewarded_token = await curveGauge.methods.rewarded_token().encodeABI();
await mock.givenMethodReturnAddress(rewarded_token, mock.address); await mock.givenMethodReturnAddress(rewarded_token, mock.address);
mockCurveGaugeMapping.addGaugeMapping('compound', mock.address, false); await mockCurveGaugeMapping.addGaugeMapping('compound', mock.address, false);
mockCurveGaugeMapping.addGaugeMapping('susd', mock.address, true); await mockCurveGaugeMapping.addGaugeMapping('susd', mock.address, true);
}) })
it('can deposit into compound gauge', async function() { it('can deposit into compound gauge', async function() {
@ -146,4 +146,9 @@ contract("ConnectCurveGauge", async accounts => {
) )
await expectRevert(tx, "wrong-gauge-pool-name") await expectRevert(tx, "wrong-gauge-pool-name")
}); });
it('can add multiple gauge mappings', async function() {
const tx = await mockCurveGaugeMapping.addGaugeMappings(['sbtc'], [mock.address], [true]);
expectEvent(tx, "LogAddGaugeMapping");
});
}) })