-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Increase coverage #342
Increase coverage #342
Changes from 6 commits
4a8d119
d7472ab
32b38eb
0db1661
00811ae
834dd4c
08dba49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
import "./MockRedemptionManager.sol"; | ||
import "../modules/ModuleFactory.sol"; | ||
import "../libraries/Util.sol"; | ||
|
||
/** | ||
* @title Mock Contract Not fit for production environment | ||
*/ | ||
|
||
contract MockBurnFactory is ModuleFactory { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should inherit the main contract in the mock contract and overwrite the functions we need to. This will help the reader understand what exactly we are mocking and why. Same goes for all mock contracts. |
||
|
||
/** | ||
* @notice Constructor | ||
* @param _polyAddress Address of the polytoken | ||
*/ | ||
constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public | ||
ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) | ||
{ | ||
version = "1.0.0"; | ||
name = "Mock"; | ||
title = "Mock Manager"; | ||
description = "MockManager"; | ||
compatibleSTVersionRange["lowerBound"] = VersionUtils.pack(uint8(0), uint8(0), uint8(0)); | ||
compatibleSTVersionRange["upperBound"] = VersionUtils.pack(uint8(0), uint8(0), uint8(0)); | ||
} | ||
|
||
/** | ||
* @notice used to launch the Module with the help of factory | ||
* @return address Contract address of the Module | ||
*/ | ||
function deploy(bytes /*_data*/) external returns(address) { | ||
if(setupCost > 0) | ||
require(polyToken.transferFrom(msg.sender, owner, setupCost), "Unable to pay setup cost"); | ||
//Check valid bytes - can only call module init function | ||
MockRedemptionManager mockRedemptionManager = new MockRedemptionManager(msg.sender, address(polyToken)); | ||
emit GenerateModuleFromFactory(address(mockRedemptionManager), getName(), address(this), msg.sender, setupCost, now); | ||
return address(mockRedemptionManager); | ||
} | ||
|
||
/** | ||
* @notice Type of the Module factory | ||
*/ | ||
function getTypes() external view returns(uint8[]) { | ||
uint8[] memory types = new uint8[](1); | ||
types[0] = 5; | ||
return types; | ||
} | ||
|
||
/** | ||
* @notice Get the name of the Module | ||
*/ | ||
function getName() public view returns(bytes32) { | ||
return name; | ||
} | ||
|
||
/** | ||
* @notice Get the description of the Module | ||
*/ | ||
function getDescription() external view returns(string) { | ||
return description; | ||
} | ||
|
||
/** | ||
* @notice Get the title of the Module | ||
*/ | ||
function getTitle() external view returns(string) { | ||
return title; | ||
} | ||
|
||
/** | ||
* @notice Get the version of the Module | ||
*/ | ||
function getVersion() external view returns(string) { | ||
return version; | ||
} | ||
|
||
/** | ||
* @notice Get the setup cost of the module | ||
*/ | ||
function getSetupCost() external view returns (uint256) { | ||
return setupCost; | ||
} | ||
|
||
/** | ||
* @notice Returns the instructions associated with the module | ||
*/ | ||
function getInstructions() external view returns(string) { | ||
return "Mock Manager - This is mock in nature"; | ||
} | ||
|
||
/** | ||
* @notice Get the tags related to the module factory | ||
*/ | ||
function getTags() external view returns(bytes32[]) { | ||
bytes32[] memory availableTags = new bytes32[](4); | ||
availableTags[0] = "Mock"; | ||
return availableTags; | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
import "../modules/Burn/IBurn.sol"; | ||
import "../modules/Module.sol"; | ||
import "../interfaces/ISecurityToken.sol"; | ||
import "openzeppelin-solidity/contracts/math/SafeMath.sol"; | ||
|
||
/** | ||
* @title Burn module for burning tokens and keeping track of burnt amounts | ||
*/ | ||
contract MockRedemptionManager is IBurn, Module { | ||
using SafeMath for uint256; | ||
|
||
mapping (address => uint256) redeemedTokens; | ||
mapping (address => uint256) tokenToRedeem; | ||
|
||
event Redeemed(address _investor, uint256 _value, uint256 _timestamp); | ||
event RedeemedTokenByOwner(address _investor, address _byWhoom, uint256 _value, uint256 _timestamp); | ||
|
||
/** | ||
* @notice Constructor | ||
* @param _securityToken Address of the security token | ||
* @param _polyAddress Address of the polytoken | ||
*/ | ||
constructor (address _securityToken, address _polyAddress) public | ||
Module(_securityToken, _polyAddress) | ||
{ | ||
} | ||
|
||
/** | ||
* @notice This function returns the signature of configure function | ||
*/ | ||
function getInitFunction() public pure returns (bytes4) { | ||
return bytes4(0); | ||
} | ||
|
||
/** | ||
* @notice Redeem tokens and track redemptions | ||
* @param _value The number of tokens to redeem | ||
*/ | ||
function redeemTokens(uint256 _value) public { | ||
ISecurityToken(securityToken).burnFromWithData(msg.sender, _value, ""); | ||
redeemedTokens[msg.sender] = redeemedTokens[msg.sender].add(_value); | ||
emit Redeemed(msg.sender, _value, now); | ||
} | ||
|
||
/** | ||
* @notice Transfer tokens to Module to burn | ||
* @param _value The number of tokens to redeem | ||
*/ | ||
function transferToRedeem(uint256 _value) public { | ||
require(ISecurityToken(securityToken).transferFrom(msg.sender, address(this), _value), "Insufficient funds"); | ||
tokenToRedeem[msg.sender] = _value; | ||
} | ||
|
||
/** | ||
* @notice use to redeem tokens by the module | ||
* @param _value The number of tokens to redeem | ||
*/ | ||
function redeemTokenByOwner(uint256 _value) public { | ||
require(tokenToRedeem[msg.sender] >= _value); | ||
tokenToRedeem[msg.sender] = tokenToRedeem[msg.sender].sub(_value); | ||
redeemedTokens[msg.sender] = redeemedTokens[msg.sender].add(_value); | ||
ISecurityToken(securityToken).burnWithData(_value, ""); | ||
emit RedeemedTokenByOwner(msg.sender, address(this), _value, now); | ||
} | ||
|
||
/** | ||
* @notice Return the permissions flag that are associated with CountTransferManager | ||
*/ | ||
function getPermissions() public view returns(bytes32[]) { | ||
bytes32[] memory allPermissions = new bytes32[](0); | ||
return allPermissions; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
pragma solidity ^0.4.24; | ||
|
||
import "./MockRedemptionManager.sol"; | ||
import "../modules/ModuleFactory.sol"; | ||
import "../libraries/Util.sol"; | ||
|
||
/** | ||
* @title Mock Contract Not fit for production environment | ||
*/ | ||
|
||
contract MockWrongTypeFactory is ModuleFactory { | ||
|
||
/** | ||
* @notice Constructor | ||
* @param _polyAddress Address of the polytoken | ||
*/ | ||
constructor (address _polyAddress, uint256 _setupCost, uint256 _usageCost, uint256 _subscriptionCost) public | ||
ModuleFactory(_polyAddress, _setupCost, _usageCost, _subscriptionCost) | ||
{ | ||
version = "1.0.0"; | ||
name = "Mock"; | ||
title = "Mock Manager"; | ||
description = "MockManager"; | ||
compatibleSTVersionRange["lowerBound"] = VersionUtils.pack(uint8(0), uint8(0), uint8(0)); | ||
compatibleSTVersionRange["upperBound"] = VersionUtils.pack(uint8(0), uint8(0), uint8(0)); | ||
} | ||
|
||
/** | ||
* @notice used to launch the Module with the help of factory | ||
* @return address Contract address of the Module | ||
*/ | ||
function deploy(bytes /*_data*/) external returns(address) { | ||
if(setupCost > 0) | ||
require(polyToken.transferFrom(msg.sender, owner, setupCost), "Unable to pay setup cost"); | ||
//Check valid bytes - can only call module init function | ||
MockRedemptionManager mockRedemptionManager = new MockRedemptionManager(msg.sender, address(polyToken)); | ||
emit GenerateModuleFromFactory(address(mockRedemptionManager), getName(), address(this), msg.sender, setupCost, now); | ||
return address(mockRedemptionManager); | ||
} | ||
|
||
/** | ||
* @notice Type of the Module factory | ||
*/ | ||
function getTypes() external view returns(uint8[]) { | ||
uint8[] memory types = new uint8[](1); | ||
types[0] = 4; | ||
return types; | ||
} | ||
|
||
/** | ||
* @notice Get the name of the Module | ||
*/ | ||
function getName() public view returns(bytes32) { | ||
return name; | ||
} | ||
|
||
/** | ||
* @notice Get the description of the Module | ||
*/ | ||
function getDescription() external view returns(string) { | ||
return description; | ||
} | ||
|
||
/** | ||
* @notice Get the title of the Module | ||
*/ | ||
function getTitle() external view returns(string) { | ||
return title; | ||
} | ||
|
||
/** | ||
* @notice Get the version of the Module | ||
*/ | ||
function getVersion() external view returns(string) { | ||
return version; | ||
} | ||
|
||
/** | ||
* @notice Get the setup cost of the module | ||
*/ | ||
function getSetupCost() external view returns (uint256) { | ||
return setupCost; | ||
} | ||
|
||
/** | ||
* @notice Returns the instructions associated with the module | ||
*/ | ||
function getInstructions() external view returns(string) { | ||
return "Mock Manager - This is mock in nature"; | ||
} | ||
|
||
/** | ||
* @notice Get the tags related to the module factory | ||
*/ | ||
function getTags() external view returns(bytes32[]) { | ||
bytes32[] memory availableTags = new bytes32[](4); | ||
availableTags[0] = "Mock"; | ||
return availableTags; | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing reason string