diff --git a/contracts/connectors/synthetix.sol b/contracts/connectors/synthetix.sol index 6ee08c0..15d5416 100644 --- a/contracts/connectors/synthetix.sol +++ b/contracts/connectors/synthetix.sol @@ -27,7 +27,7 @@ contract SynthetixStakingHelper is DSMath, Stores { /** * @dev Return InstaDApp Synthetix Mapping Addresses */ - function getMappingAddr() internal pure returns (address) { + function getMappingAddr() virtual internal view returns (address) { return 0xe81F70Cc7C0D46e12d70efc60607F16bbD617E88; // InstaMapping Address } diff --git a/contracts/tests/MockSynthetix.sol b/contracts/tests/MockSynthetix.sol index 33a393e..b2a1dcd 100644 --- a/contracts/tests/MockSynthetix.sol +++ b/contracts/tests/MockSynthetix.sol @@ -1,23 +1,26 @@ pragma solidity ^0.6.0; +pragma experimental ABIEncoderV2; import { ConnectSynthetixStaking } from "../connectors/synthetix.sol"; contract MockSynthetixStaking is ConnectSynthetixStaking{ address public synthetixStakingAddr; + address public instaMappingAddr; - constructor(address _synthetixStakingAddr) public { + constructor(address _synthetixStakingAddr, address _instaMappingAddr) public { synthetixStakingAddr = _synthetixStakingAddr; + instaMappingAddr = _instaMappingAddr; } - // function getSynthetixStakingAddr(address token) override internal returns (address) { - // return synthetixStakingAddr; - // } - function emitEvent(bytes32 eventCode, bytes memory eventData) override internal {} function getSnxAddr() override internal view returns (address) { return synthetixStakingAddr; } + function getMappingAddr() override internal view returns (address) { + return instaMappingAddr; + } + function setUint(uint setId, uint val) override internal {} } diff --git a/test/SynthetixProtocol.js b/test/SynthetixProtocol.js index 978e6fd..378bf7f 100644 --- a/test/SynthetixProtocol.js +++ b/test/SynthetixProtocol.js @@ -20,7 +20,7 @@ contract('ConnectSynthetixStaking', async accounts => { before(async function () { mock = await MockContract.new(); mockInstaMapping = await MockInstaMapping.new(); - mockSynthetixStaking = await MockSynthetixStaking.new(mock.address); + mockSynthetixStaking = await MockSynthetixStaking.new(mock.address, mockInstaMapping.address); stakingContract = new web3.eth.Contract(synthetixStaking, mock.address); token = new web3.eth.Contract(erc20ABI, mock.address); mockInstaMapping.addStakingMapping('snx', mock.address, mock.address); @@ -41,7 +41,7 @@ contract('ConnectSynthetixStaking', async accounts => { await mock.givenMethodReturnBool(stake, "true"); const tx = await mockSynthetixStaking.deposit( - mock.address, + "snx", 10000000, 0, 0 @@ -58,7 +58,7 @@ contract('ConnectSynthetixStaking', async accounts => { await mock.givenMethodReturnBool(reward, "true"); const tx = await mockSynthetixStaking.withdraw( - mock.address, + "snx", 10000000, 0, 111, @@ -73,9 +73,25 @@ contract('ConnectSynthetixStaking', async accounts => { let reward = await stakingContract.methods.getReward().encodeABI(); await mock.givenMethodReturnBool(reward, "true"); const tx = await mockSynthetixStaking.claimReward( - mock.address, + "snx", 112 ) expectEvent(tx, "LogClaimedReward"); }); + + it('cannot deposit if pool removed', async function() { + mockInstaMapping.removeStakingMapping('snx', mock.address); + // mocking stake + let stake = await stakingContract.methods.stake(10000000).encodeABI(); + await mock.givenMethodReturnBool(stake, "true"); + + const tx = mockSynthetixStaking.deposit( + "snx", + 10000000, + 0, + 0 + ) + expectRevert(tx, "Wrong Staking Name"); + }); + })