From cdb8bf01eb408a42653ae897e53fc0d886a8d4cb Mon Sep 17 00:00:00 2001 From: Lecky Lao Date: Fri, 10 Jul 2020 01:08:08 +1000 Subject: [PATCH] created Mocks and MockSynthetix; adding constructor for MockSynthetix and passing mock for synthetix address; --- contracts/connectors/synthetix.sol | 6 +++--- contracts/tests/MockSynthetix.sol | 19 +++++++++++++++++++ contracts/{ => tests}/Mocks.sol | 0 migrations/2_deploy_connector.js | 12 ++++++++++-- test/SynthetixProtocol.js | 6 +++--- 5 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 contracts/tests/MockSynthetix.sol rename contracts/{ => tests}/Mocks.sol (100%) diff --git a/contracts/connectors/synthetix.sol b/contracts/connectors/synthetix.sol index e46c494..c354dbf 100644 --- a/contracts/connectors/synthetix.sol +++ b/contracts/connectors/synthetix.sol @@ -12,11 +12,11 @@ interface IStakingRewards { function getReward() external; } -contract SynthetixStakingHelper is DSMath, Stores { +contract SynthetixStakingHelper is DSMath, Stores { /** * @dev Return Synthetix staking pool address. */ - function getSynthetixStakingAddr(address token) internal pure returns (address){ + function getSynthetixStakingAddr(address token) virtual internal view returns (address){ if (token == address(0x075b1bb99792c9E1041bA13afEf80C91a1e70fB3)){ // SBTC return 0x13C1542A468319688B89E323fe9A3Be3A90EBb27; @@ -117,7 +117,7 @@ contract SynthetixStaking is SynthetixStakingHelper { setUint(setIdAmount, _amt); setUint(setIdReward, rewardAmt); - + emit LogWithdraw(token, _amt, getId, setIdAmount); bytes32 _eventCodeWithdraw = keccak256("LogWithdraw(address,uint256,uint256,uint256)"); bytes memory _eventParamWithdraw = abi.encode(token, _amt, getId, setIdAmount); diff --git a/contracts/tests/MockSynthetix.sol b/contracts/tests/MockSynthetix.sol new file mode 100644 index 0000000..4fdafc3 --- /dev/null +++ b/contracts/tests/MockSynthetix.sol @@ -0,0 +1,19 @@ +pragma solidity ^0.6.0; + +import { ConnectSynthetixStaking } from "../connectors/synthetix.sol"; + +contract MockSynthetixStaking is ConnectSynthetixStaking{ + // uint public _model; + // uint public _id; + address public synthetixStakingAddr; + + constructor(address _synthetixStakingAddr) public { + // _model = model; + // _id = id; + synthetixStakingAddr = _synthetixStakingAddr; + } + + function getSynthetixStakingAddr(address token) override internal view returns (address){ + return synthetixStakingAddr; + } +} diff --git a/contracts/Mocks.sol b/contracts/tests/Mocks.sol similarity index 100% rename from contracts/Mocks.sol rename to contracts/tests/Mocks.sol diff --git a/migrations/2_deploy_connector.js b/migrations/2_deploy_connector.js index d046267..8744d17 100644 --- a/migrations/2_deploy_connector.js +++ b/migrations/2_deploy_connector.js @@ -1,10 +1,18 @@ // const CurveProtocol = artifacts.require("CurveProtocol"); // const ConnectSBTCCurve = artifacts.require("ConnectSBTCCurve"); const MockContract = artifacts.require("MockContract"); +const MockSynthetixStaking = artifacts.require("MockSynthetixStaking"); + +// const connectorsABI = require("../test/abi/connectors.json"); +// let connectorsAddr = "0xD6A602C01a023B98Ecfb29Df02FBA380d3B21E0c"; +// let connectorInstance = new web3.eth.Contract(connectorsABI, connectorsAddr); module.exports = async function(deployer) { // deployer.deploy(CurveProtocol); - deployer.deploy(MockContract); // let connectorLength = await connectorInstance.methods.connectorLength().call(); - // deployer.deploy(ConnectSBTCCurve, 1, +connectorLength + 1); + deployer.deploy(MockContract).then(function () { + // return deployer.deploy(MockSynthetixStaking, MockContract.address, 1, +connectorLength + 1); + return deployer.deploy(MockSynthetixStaking, MockContract.address); + }); + }; diff --git a/test/SynthetixProtocol.js b/test/SynthetixProtocol.js index 676b7f7..6d968a6 100644 --- a/test/SynthetixProtocol.js +++ b/test/SynthetixProtocol.js @@ -7,13 +7,13 @@ const { } = require('@openzeppelin/test-helpers'); const MockContract = artifacts.require("MockContract"); - -const ConnectSynthetixStaking = artifacts.require('ConnectSynthetixStaking'); +const MockSynthetixStaking = artifacts.require('MockSynthetixStaking'); const erc20ABI = require("./abi/erc20.js"); contract('ConnectSynthetixStaking', async accounts => { const [sender, receiver] = accounts; - const mock = await MockContract.new(); + const mock = await MockContract.deployed(); + const mockSynthetixStaking = await MockSynthetixStaking.deployed(); const crvRenWSBTCContract = new web3.eth.Contract(erc20ABI, mock.address); before(async function () {