From 84790edea12623a08750a9b58c5093b395f6952d Mon Sep 17 00:00:00 2001 From: satyam Date: Thu, 21 Feb 2019 18:39:41 +0530 Subject: [PATCH 1/6] allows explicit token factory version in generateSecurityToken() --- CHANGELOG.md | 2 ++ contracts/STRGetter.sol | 2 +- contracts/SecurityTokenRegistry.sol | 27 +++++++++++++++++++-------- contracts/tokens/SecurityToken.sol | 3 +-- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94a8c2ce4..115d814e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,8 @@ All notable changes to this project will be documented in this file. * Replaced `updatePolyTokenAddress()` function with `updateFromRegistry()` in `SecurityTokenRegistry`. * Migrate all the getters of `SecurityTokenRegsitry.sol` to `STRGetter.sol` contract. * Removed `_polyToken` parameter from `initialize` function in `SecurityTokenRegistry`. +* Allows an explicit token factory version to be used during creation of securityToken. +* Rename the `getProtocolVersion()` to `getCurrentProtocolVersion()`. ## GeneralTransferManager * `modifyWhitelist()` function renamed to `modifyKYCData()`. diff --git a/contracts/STRGetter.sol b/contracts/STRGetter.sol index 29d5264fd..1726440f0 100644 --- a/contracts/STRGetter.sol +++ b/contracts/STRGetter.sol @@ -164,7 +164,7 @@ contract STRGetter is EternalStorage { /** * @notice Gets Protocol version */ - function getProtocolVersion() public view returns(uint8[] memory) { + function getCurrentProtocolVersion() public view returns(uint8[] memory) { return VersionUtils.unpack(uint24(getUintValue(Encoder.getKey("latestVersion")))); } diff --git a/contracts/SecurityTokenRegistry.sol b/contracts/SecurityTokenRegistry.sol index 88c9d31d5..eda626c5c 100644 --- a/contracts/SecurityTokenRegistry.sol +++ b/contracts/SecurityTokenRegistry.sol @@ -487,17 +487,25 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { * @param _ticker is the ticker symbol of the security token * @param _tokenDetails is the off-chain details of the token * @param _divisible is whether or not the token is divisible + * @param _protocolVersion Version of securityToken contract + * - `_protocolVersion` is the packed value of uin8[3] array (it will be calculated offchain) + * - if _protocolVersion == 0 then latest version of securityToken will generated */ function generateSecurityToken( string calldata _name, string calldata _ticker, string calldata _tokenDetails, - bool _divisible + bool _divisible, + uint256 _protocolVersion ) external whenNotPausedOrOwner { + uint256 protocolVersion = _protocolVersion; require(bytes(_name).length > 0 && bytes(_ticker).length > 0, "Ticker length > 0"); + if (_protocolVersion == 0) { + protocolVersion = getUintValue(Encoder.getKey("latestVersion")); + } string memory ticker = Util.upper(_ticker); bytes32 statusKey = Encoder.getKey("registeredTickers_status", ticker); require(!getBoolValue(statusKey), "Already deployed"); @@ -505,23 +513,26 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { require(_tickerOwner(ticker) == msg.sender, "Not authorised"); /*solium-disable-next-line security/no-block-members*/ require(getUintValue(Encoder.getKey("registeredTickers_expiryDate", ticker)) >= now, "Ticker gets expired"); - (uint256 _usdFee, uint256 _polyFee) = _takeFee(STLAUNCHFEE); + _deployToken(_name, ticker, _tokenDetails, msg.sender, _divisible, protocolVersion); + } - address newSecurityTokenAddress = ISTFactory(getAddressValue(Encoder.getKey("protocolVersionST", getUintValue(Encoder.getKey("latestVersion"))))).deployToken( + function _deployToken(string memory _name, string memory _ticker, string memory _tokenDetails, address _issuer, bool _divisible, uint256 _protocolVersion) internal { + (uint256 _usdFee, uint256 _polyFee) = _takeFee(STLAUNCHFEE); + address newSecurityTokenAddress = ISTFactory(getAddressValue(Encoder.getKey("protocolVersionST", _protocolVersion))).deployToken( _name, - ticker, + _ticker, 18, _tokenDetails, - msg.sender, + _issuer, _divisible, getAddressValue(POLYMATHREGISTRY) ); /*solium-disable-next-line security/no-block-members*/ - _storeSecurityTokenData(newSecurityTokenAddress, ticker, _tokenDetails, now); - set(Encoder.getKey("tickerToSecurityToken", ticker), newSecurityTokenAddress); + _storeSecurityTokenData(newSecurityTokenAddress, _ticker, _tokenDetails, now); + set(Encoder.getKey("tickerToSecurityToken", _ticker), newSecurityTokenAddress); /*solium-disable-next-line security/no-block-members*/ - emit NewSecurityToken(ticker, _name, newSecurityTokenAddress, msg.sender, now, msg.sender, false, _usdFee, _polyFee); + emit NewSecurityToken(_ticker, _name, newSecurityTokenAddress, msg.sender, now, msg.sender, false, _usdFee, _polyFee); } /** diff --git a/contracts/tokens/SecurityToken.sol b/contracts/tokens/SecurityToken.sol index d76d8ad32..518f24d52 100644 --- a/contracts/tokens/SecurityToken.sol +++ b/contracts/tokens/SecurityToken.sol @@ -16,7 +16,6 @@ import "../interfaces/ITransferManager.sol"; import "openzeppelin-solidity/contracts/ownership/Ownable.sol"; import "openzeppelin-solidity/contracts/utils/ReentrancyGuard.sol"; import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol"; -import "openzeppelin-solidity/contracts/utils/ReentrancyGuard.sol"; import "openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol"; /** @@ -143,7 +142,7 @@ contract SecurityToken is ERC20, ERC20Detailed, Ownable, ReentrancyGuard, Securi delegate = _delegate; tokenDetails = _tokenDetails; granularity = _granularity; - securityTokenVersion = SemanticVersion(2, 0, 0); + securityTokenVersion = SemanticVersion(3, 0, 0); } /** From ecbe50f352b29311bb3087e4d6814c2135e40b12 Mon Sep 17 00:00:00 2001 From: satyam Date: Thu, 21 Feb 2019 22:50:33 +0530 Subject: [PATCH 2/6] fix tests --- contracts/SecurityTokenRegistry.sol | 1 + test/b_capped_sto.js | 4 +- test/c_checkpoints.js | 2 +- test/d_count_transfer_manager.js | 4 +- test/e_erc20_dividends.js | 2 +- test/f_ether_dividends.js | 2 +- test/g_general_permission_manager.js | 4 +- test/h_general_transfer_manager.js | 2 +- test/i_Issuance.js | 2 +- test/j_manual_approval_transfer_manager.js | 2 +- test/k_module_registry.js | 4 +- test/l_percentage_transfer_manager.js | 2 +- test/m_presale_sto.js | 2 +- test/n_security_token_registry.js | 2532 ++++++++--------- test/o_security_token.js | 2 +- test/p_usd_tiered_sto.js | 2 +- test/q_usd_tiered_sto_sim.js | 2 +- test/r_concurrent_STO.js | 2 +- test/t_security_token_registry_proxy.js | 2 +- test/v_tracked_redemptions.js | 2 +- test/w_lockup_transfer_manager.js | 4 +- test/x_scheduled_checkpoints.js | 2 +- test/y_volume_restriction_tm.js | 2 +- test/z_blacklist_transfer_manager.js | 2 +- .../z_fuzz_test_adding_removing_modules_ST.js | 2 +- ...zer_volumn_restriction_transfer_manager.js | 2 +- test/z_general_permission_manager_fuzzer.js | 2 +- test/z_vesting_escrow_wallet.js | 2 +- test/za_datastore.js | 2 +- test/zb_signed_transfer_manager.js | 2 +- 30 files changed, 1300 insertions(+), 1299 deletions(-) diff --git a/contracts/SecurityTokenRegistry.sol b/contracts/SecurityTokenRegistry.sol index b21ae26c3..2e6d09d9f 100644 --- a/contracts/SecurityTokenRegistry.sol +++ b/contracts/SecurityTokenRegistry.sol @@ -506,6 +506,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { if (_protocolVersion == 0) { protocolVersion = getUintValue(Encoder.getKey("latestVersion")); } + require(protocolVersion != uint256(0), "Invalid version"); string memory ticker = Util.upper(_ticker); bytes32 statusKey = Encoder.getKey("registeredTickers_status", ticker); require(!getBoolValue(statusKey), "Already deployed"); diff --git a/test/b_capped_sto.js b/test/b_capped_sto.js index 1766fd8be..ce08472ae 100644 --- a/test/b_capped_sto.js +++ b/test/b_capped_sto.js @@ -174,7 +174,7 @@ contract("CappedSTO", async (accounts) => { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); - let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: token_owner }); // Verify the successful generation of the security token assert.equal(tx.logs[2].args._ticker, symbol, "SecurityToken doesn't get deployed"); @@ -622,7 +622,7 @@ contract("CappedSTO", async (accounts) => { it("POLY: Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); - let tx = await I_STRProxied.generateSecurityToken(P_name, P_symbol, P_tokenDetails, false, { from: token_owner }); + let tx = await I_STRProxied.generateSecurityToken(P_name, P_symbol, P_tokenDetails, false, 0, { from: token_owner }); // Verify the successful generation of the security token assert.equal(tx.logs[2].args._ticker, P_symbol, "SecurityToken doesn't get deployed"); diff --git a/test/c_checkpoints.js b/test/c_checkpoints.js index 96066453e..b323c78cc 100644 --- a/test/c_checkpoints.js +++ b/test/c_checkpoints.js @@ -126,7 +126,7 @@ contract("Checkpoints", async function(accounts) { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); - let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: token_owner }); // Verify the successful generation of the security token assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); diff --git a/test/d_count_transfer_manager.js b/test/d_count_transfer_manager.js index 7302fd99a..8df3d156e 100644 --- a/test/d_count_transfer_manager.js +++ b/test/d_count_transfer_manager.js @@ -142,7 +142,7 @@ contract("CountTransferManager", async (accounts) => { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); - let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: token_owner }); // Verify the successful generation of the security token assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); @@ -362,7 +362,7 @@ contract("CountTransferManager", async (accounts) => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); - let tx2 = await I_STRProxied.generateSecurityToken(name, symbol2, tokenDetails, false, { from: token_owner }); + let tx2 = await I_STRProxied.generateSecurityToken(name, symbol2, tokenDetails, false, 0, { from: token_owner }); I_SecurityToken2 = await SecurityToken.at(tx2.logs[2].args._securityTokenAddress); stGetter2 = await STGetter.at(I_SecurityToken2.address); diff --git a/test/e_erc20_dividends.js b/test/e_erc20_dividends.js index 656060a0a..8182edf9e 100644 --- a/test/e_erc20_dividends.js +++ b/test/e_erc20_dividends.js @@ -151,7 +151,7 @@ contract("ERC20DividendCheckpoint", async (accounts) => { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); - let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: token_owner }); // Verify the successful generation of the security token assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); diff --git a/test/f_ether_dividends.js b/test/f_ether_dividends.js index 3c379ac43..77dd5448a 100644 --- a/test/f_ether_dividends.js +++ b/test/f_ether_dividends.js @@ -144,7 +144,7 @@ contract("EtherDividendCheckpoint", async (accounts) => { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); - let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: token_owner }); // Verify the successful generation of the security token assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); diff --git a/test/g_general_permission_manager.js b/test/g_general_permission_manager.js index e513972ff..4ddab50da 100644 --- a/test/g_general_permission_manager.js +++ b/test/g_general_permission_manager.js @@ -142,7 +142,7 @@ contract("GeneralPermissionManager", async (accounts) => { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); - let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: token_owner }); // Verify the successful generation of the security token assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); @@ -329,7 +329,7 @@ contract("GeneralPermissionManager", async (accounts) => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); let _blockNo = latestBlock(); - let tx2 = await I_STRProxied.generateSecurityToken(name, "DEL", tokenDetails, false, { from: token_owner }); + let tx2 = await I_STRProxied.generateSecurityToken(name, "DEL", tokenDetails, false, 0, { from: token_owner }); // Verify the successful generation of the security token assert.equal(tx2.logs[2].args._ticker, "DEL", "SecurityToken doesn't get deployed"); diff --git a/test/h_general_transfer_manager.js b/test/h_general_transfer_manager.js index a88b35370..2f175d493 100644 --- a/test/h_general_transfer_manager.js +++ b/test/h_general_transfer_manager.js @@ -172,7 +172,7 @@ contract("GeneralTransferManager", async (accounts) => { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); - let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: token_owner }); // Verify the successful generation of the security token assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); diff --git a/test/i_Issuance.js b/test/i_Issuance.js index fda71fc93..510a462e2 100644 --- a/test/i_Issuance.js +++ b/test/i_Issuance.js @@ -155,7 +155,7 @@ contract("Issuance", async (accounts) => { it("POLYMATH: Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: account_polymath }); - let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: account_polymath }); + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: account_polymath }); // Verify the successful generation of the security token assert.equal(tx.logs[2].args._ticker, symbol, "SecurityToken doesn't get deployed"); diff --git a/test/j_manual_approval_transfer_manager.js b/test/j_manual_approval_transfer_manager.js index c7509043c..11d9dd2b5 100644 --- a/test/j_manual_approval_transfer_manager.js +++ b/test/j_manual_approval_transfer_manager.js @@ -152,7 +152,7 @@ contract("ManualApprovalTransferManager", accounts => { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); - let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: token_owner }); // Verify the successful generation of the security token assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); diff --git a/test/k_module_registry.js b/test/k_module_registry.js index c13a46929..026263164 100644 --- a/test/k_module_registry.js +++ b/test/k_module_registry.js @@ -303,7 +303,7 @@ contract("ModuleRegistry", async (accounts) => { await I_PolyToken.getTokens(new BN(web3.utils.toWei("2000")), account_issuer); await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("2000")), { from: account_issuer }); await I_STRProxied.registerTicker(account_issuer, symbol, name, { from: account_issuer }); - let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, true, { from: account_issuer }); + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, true, 0, { from: account_issuer }); assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase()); I_SecurityToken = await SecurityToken.at(tx.logs[2].args._securityTokenAddress); }); @@ -405,7 +405,7 @@ contract("ModuleRegistry", async (accounts) => { await I_PolyToken.getTokens(new BN(web3.utils.toWei("2000")), account_issuer); await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("2000")), { from: account_issuer }); await I_STRProxied.registerTicker(account_issuer, newSymbol, name, { from: account_issuer }); - let tx = await I_STRProxied.generateSecurityToken(name, newSymbol, tokenDetails, true, { from: account_issuer }); + let tx = await I_STRProxied.generateSecurityToken(name, newSymbol, tokenDetails, true, 0, { from: account_issuer }); assert.equal(tx.logs[2].args._ticker, newSymbol.toUpperCase()); I_SecurityToken2 = await SecurityToken.at(tx.logs[2].args._securityTokenAddress); diff --git a/test/l_percentage_transfer_manager.js b/test/l_percentage_transfer_manager.js index 04222882a..134faf76c 100644 --- a/test/l_percentage_transfer_manager.js +++ b/test/l_percentage_transfer_manager.js @@ -166,7 +166,7 @@ contract("PercentageTransferManager", async (accounts) => { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); - let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: token_owner }); // Verify the successful generation of the security token assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); diff --git a/test/m_presale_sto.js b/test/m_presale_sto.js index 300850352..7eaec5440 100644 --- a/test/m_presale_sto.js +++ b/test/m_presale_sto.js @@ -142,7 +142,7 @@ contract("PreSaleSTO", async (accounts) => { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); - let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: token_owner }); // Verify the successful generation of the security token assert.equal(tx.logs[2].args._ticker, symbol, "SecurityToken doesn't get deployed"); diff --git a/test/n_security_token_registry.js b/test/n_security_token_registry.js index 51680c96d..9cb59d90b 100644 --- a/test/n_security_token_registry.js +++ b/test/n_security_token_registry.js @@ -1,1266 +1,1266 @@ -import latestTime from "./helpers/latestTime"; -import { duration, promisifyLogWatch, latestBlock } from "./helpers/utils"; -import { takeSnapshot, increaseTime, revertToSnapshot } from "./helpers/time"; -import { encodeProxyCall, encodeModuleCall } from "./helpers/encodeCall"; -import { catchRevert } from "./helpers/exceptions"; -import { setUpPolymathNetwork, deployDummySTOAndVerifyed } from "./helpers/createInstances"; - -const DummySTO = artifacts.require("./DummySTO.sol"); -const SecurityToken = artifacts.require("./SecurityToken.sol"); -const SecurityTokenRegistryProxy = artifacts.require("./SecurityTokenRegistryProxy.sol"); -const SecurityTokenRegistry = artifacts.require("./SecurityTokenRegistry.sol"); -const SecurityTokenRegistryMock = artifacts.require("./SecurityTokenRegistryMock.sol"); -const STFactory = artifacts.require("./STFactory.sol"); -const STRGetter = artifacts.require('./STRGetter.sol'); -const STGetter = artifacts.require("./STGetter.sol"); -const DataStoreLogic = artifacts.require('./DataStore.sol'); -const DataStoreFactory = artifacts.require('./DataStoreFactory.sol'); - - -const Web3 = require("web3"); -let BN = Web3.utils.BN; -const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); // Hardcoded development port - -contract("SecurityTokenRegistry", async (accounts) => { - // Accounts Variable declaration - let account_polymath; - let account_investor1; - let account_issuer; - let token_owner; - let account_investor2; - let account_fundsReceiver; - let account_delegate; - let account_temp; - let dummy_token; - - let balanceOfReceiver; - - let ID_snap; - const message = "Transaction Should Fail!!"; - - // Contract Instance Declaration - let I_GeneralTransferManagerFactory; - let I_GeneralPermissionManager; - let I_GeneralTransferManager; - let I_ModuleRegistryProxy; - let I_ModuleRegistry; - let I_FeatureRegistry; - let I_SecurityTokenRegistry; - let I_SecurityTokenRegistryV2; - let I_DummySTOFactory; - let I_STVersion; - let I_SecurityToken; - let I_DummySTO; - let I_PolyToken; - let I_STFactory; - let I_STFactory002; - let I_SecurityToken002; - let I_STFactory003; - let I_PolymathRegistry; - let I_SecurityTokenRegistryProxy; - let I_STRProxied; - let I_MRProxied; - let I_STRGetter; - let I_Getter; - let I_STGetter; - let stGetter; - let I_USDOracle; - let I_POLYOracle; - let I_StablePOLYOracle; - - // SecurityToken Details (Launched ST on the behalf of the issuer) - const name = "Demo Token"; - const symbol = "DET"; - const tokenDetails = "This is equity type of issuance"; - const decimals = 18; - - //Security Token Detials (Version 2) - const name2 = "Demo2 Token"; - const symbol2 = "DET2"; - const tokenDetails2 = "This is equity type of issuance"; - const address_zero = "0x0000000000000000000000000000000000000000"; - const one_address = "0x0000000000000000000000000000000000000001"; - - // Module key - const permissionManagerKey = 1; - const transferManagerKey = 2; - const stoKey = 3; - const budget = 0; - - // Initial fee for ticker registry and security token registry - const initRegFee = new BN(web3.utils.toWei("250")); - const initRegFeePOLY = new BN(web3.utils.toWei("1000")); - - const STRProxyParameters = ["address", "address", "uint256", "uint256", "address", "address"]; - const STOParameters = ["uint256", "uint256", "uint256", "string"]; - - // Capped STO details - const cap = new BN(web3.utils.toWei("10000")); - const someString = "Hello string"; - - let currentTime; - - before(async () => { - currentTime = new BN(await latestTime()); - account_polymath = accounts[0]; - account_issuer = accounts[1]; - account_investor1 = accounts[9]; - account_investor2 = accounts[6]; - account_fundsReceiver = accounts[4]; - account_delegate = accounts[5]; - account_temp = accounts[8]; - token_owner = account_issuer; - dummy_token = accounts[3]; - - let instances = await setUpPolymathNetwork(account_polymath, token_owner); - - [ - I_PolymathRegistry, - I_PolyToken, - I_FeatureRegistry, - I_ModuleRegistry, - I_ModuleRegistryProxy, - I_MRProxied, - I_GeneralTransferManagerFactory, - I_STFactory, - I_SecurityTokenRegistry, - I_SecurityTokenRegistryProxy, - I_STRProxied, - I_STRGetter, - I_STGetter, - I_USDOracle, - I_POLYOracle, - I_StablePOLYOracle - ] = instances; - - // STEP 8: Deploy the CappedSTOFactory - - [I_DummySTOFactory] = await deployDummySTOAndVerifyed(account_polymath, I_MRProxied, 0); - // Step 9: Deploy the SecurityTokenRegistry - console.log(I_SecurityTokenRegistry.address); - I_SecurityTokenRegistry = await SecurityTokenRegistry.new({ from: account_polymath }); - console.log(I_SecurityTokenRegistry.address); - - assert.notEqual( - I_SecurityTokenRegistry.address.valueOf(), - address_zero, - "SecurityTokenRegistry contract was not deployed" - ); - - // Step 9 (a): Deploy the proxy - I_SecurityTokenRegistryProxy = await SecurityTokenRegistryProxy.new({ from: account_polymath }); - // Step 10 : Deploy the getter contract - I_STRGetter = await STRGetter.new({ from: account_polymath }); - //Step 11: update the registries addresses from the PolymathRegistry contract - await I_PolymathRegistry.changeAddress("SecurityTokenRegistry", I_SecurityTokenRegistryProxy.address, { from: account_polymath }); - await I_MRProxied.updateFromRegistry({ from: account_polymath }); - - console.log(` - --------------------- Polymath Network Smart Contracts: --------------------- - PolymathRegistry: ${I_PolymathRegistry.address} - SecurityTokenRegistryProxy: ${I_SecurityTokenRegistryProxy.address} - SecurityTokenRegistry: ${I_SecurityTokenRegistry.address} - ModuleRegistry: ${I_ModuleRegistry.address} - ModuleRegistryProxy: ${I_ModuleRegistryProxy.address} - FeatureRegistry: ${I_FeatureRegistry.address} - - STFactory: ${I_STFactory.address} - GeneralTransferManagerFactory: ${I_GeneralTransferManagerFactory.address} - - DummySTOFactory: ${I_DummySTOFactory.address} - ----------------------------------------------------------------------------- - `); - }); - - describe("Test the initialize the function", async () => { - it("Should successfully update the implementation address -- fail because polymathRegistry address is 0x", async () => { - let bytesProxy = encodeProxyCall(STRProxyParameters, [ - address_zero, - I_STFactory.address, - initRegFee, - initRegFee, - account_polymath, - I_STRGetter.address - ]); - await catchRevert( - I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { - from: account_polymath - }), - "tx-> revert because polymathRegistry address is 0x" - ); - }); - - it("Should successfully update the implementation address -- fail because STFactory address is 0x", async () => { - let bytesProxy = encodeProxyCall(STRProxyParameters, [ - I_PolymathRegistry.address, - address_zero, - initRegFee, - initRegFee, - account_polymath, - I_STRGetter.address - ]); - await catchRevert( - I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { - from: account_polymath - }), - "tx-> revert because STFactory address is 0x" - ); - }); - - it("Should successfully update the implementation address -- fail because STLaunch fee is 0", async () => { - let bytesProxy = encodeProxyCall(STRProxyParameters, [ - I_PolymathRegistry.address, - I_STFactory.address, - new BN(0), - initRegFee, - account_polymath, - I_STRGetter.address - ]); - await catchRevert( - I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { - from: account_polymath - }), - "tx-> revert because STLaunch fee is 0" - ); - }); - - it("Should successfully update the implementation address -- fail because tickerRegFee fee is 0", async () => { - let bytesProxy = encodeProxyCall(STRProxyParameters, [ - I_PolymathRegistry.address, - I_STFactory.address, - initRegFee, - new BN(0), - account_polymath, - I_STRGetter.address - ]); - await catchRevert( - I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { - from: account_polymath - }), - "tx-> revert because tickerRegFee is 0" - ); - }); - - it("Should successfully update the implementation address -- fail because owner address is 0x", async () => { - let bytesProxy = encodeProxyCall(STRProxyParameters, [ - I_PolymathRegistry.address, - I_STFactory.address, - initRegFee, - initRegFee, - address_zero, - I_STRGetter.address - ]); - await catchRevert( - I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { - from: account_polymath - }), - "tx-> revert because owner address is 0x" - ); - }); - - it("Should successfully update the implementation address -- fail because all params get 0", async () => { - let bytesProxy = encodeProxyCall(STRProxyParameters, [address_zero, address_zero, new BN(0), new BN(0), address_zero, address_zero]); - await catchRevert( - I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { - from: account_polymath - }), - "tx-> revert because owner address is 0x" - ); - }); - - it("Should successfully update the implementation address", async () => { - let bytesProxy = encodeProxyCall(STRProxyParameters, [ - I_PolymathRegistry.address, - I_STFactory.address, - initRegFee, - initRegFee, - account_polymath, - I_STRGetter.address - ]); - await I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { - from: account_polymath - }); - I_Getter = await STRGetter.at(I_SecurityTokenRegistryProxy.address); - I_STRProxied = await SecurityTokenRegistry.at(I_SecurityTokenRegistryProxy.address); - }); - }); - - describe(" Test cases of the registerTicker", async () => { - it("verify the intial parameters", async () => { - let intialised = await I_STRProxied.getBoolValue.call(web3.utils.soliditySha3("initialised")); - assert.isTrue(intialised, "Should be true"); - - let expiry = await I_STRProxied.getUintValue.call(web3.utils.soliditySha3("expiryLimit")); - assert.equal(expiry.toNumber(), 5184000, "Expiry limit should be equal to 60 days"); - - let polytoken = await I_STRProxied.getAddressValue.call(web3.utils.soliditySha3("polyToken")); - assert.equal(polytoken, I_PolyToken.address, "Should be the polytoken address"); - - let stlaunchFee = await I_STRProxied.getUintValue.call(web3.utils.soliditySha3("stLaunchFee")); - assert.equal(stlaunchFee.toString(), initRegFee.toString(), "Should be provided reg fee"); - - let tickerRegFee = await I_STRProxied.getUintValue.call(web3.utils.soliditySha3("tickerRegFee")); - assert.equal(tickerRegFee.toString(), tickerRegFee.toString(), "Should be provided reg fee"); - - let polymathRegistry = await I_STRProxied.getAddressValue.call(web3.utils.soliditySha3("polymathRegistry")); - assert.equal(polymathRegistry, I_PolymathRegistry.address, "Should be the address of the polymath registry"); - - let getterContract = await I_STRProxied.getAddressValue.call(web3.utils.soliditySha3("STRGetter")); - assert.equal(getterContract, I_STRGetter.address, "Should be the address of the getter contract"); - - let owner = await I_STRProxied.getAddressValue.call(web3.utils.soliditySha3("owner")); - assert.equal(owner, account_polymath, "Should be the address of the registry owner"); - }); - - it("Can't call the intialize function again", async () => { - await catchRevert( - I_STRProxied.initialize( - I_PolymathRegistry.address, - I_STFactory.address, - initRegFee, - initRegFee, - account_polymath, - I_STRGetter.address - ), - "tx revert -> Can't call the intialize function again" - ); - }); - - it("Should fail to register ticker if tickerRegFee not approved", async () => { - await catchRevert( - I_STRProxied.registerTicker(account_temp, symbol, name, { from: account_temp }), - "tx revert -> POLY allowance not provided for registration fee" - ); - }); - - it("Should fail to register ticker if owner is 0x", async () => { - await I_PolyToken.getTokens(initRegFeePOLY, account_temp); - await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: account_temp }); - - await catchRevert( - I_STRProxied.registerTicker(address_zero, symbol, name, { from: account_temp }), - "tx revert -> owner should not be 0x" - ); - }); - - it("Should fail to register ticker due to the symbol length is 0", async () => { - await catchRevert(I_STRProxied.registerTicker(account_temp, "", name, { from: account_temp }), "tx revert -> Symbol Length is 0"); - }); - - it("Should fail to register ticker due to the symbol length is greater than 10", async () => { - await catchRevert( - I_STRProxied.registerTicker(account_temp, "POLYMATHNET", name, { from: account_temp }), - "tx revert -> Symbol Length is greater than 10" - ); - }); - - it("Should register the ticker before the generation of the security token", async () => { - let tx = await I_STRProxied.registerTicker(account_temp, symbol, name, { from: account_temp }); - assert.equal(tx.logs[0].args._owner, account_temp, `Owner should be the ${account_temp}`); - assert.equal(tx.logs[0].args._ticker, symbol, `Symbol should be ${symbol}`); - let data = await I_Getter.getTickerDetails.call(symbol); - assert.equal(data[0], account_temp); - assert.equal(data[3], name); - // trying to access the function data directly from the STRGetter then it should give all values zero - data = await I_STRGetter.getTickerDetails.call(symbol); - assert.equal(data[0], address_zero); - assert.equal(data[3], ""); - }); - - it("Should change ticker price based on oracle", async () => { - let snap_Id = await takeSnapshot(); - let origPriceUSD = new BN(web3.utils.toWei("250")); - let origPricePOLY = new BN(web3.utils.toWei("1000")); - let currentRate = await I_POLYOracle.getPrice.call(); - console.log("Current Rate: " + currentRate); - let feesTicker = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); - let feesToken = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); - assert.equal(feesTicker[0].toString(), origPriceUSD.toString()); - assert.equal(feesTicker[1].toString(), origPricePOLY.toString()); - assert.equal(feesToken[0].toString(), origPriceUSD.toString()); - assert.equal(feesToken[1].toString(), origPricePOLY.toString()); - await I_POLYOracle.changePrice(new BN(27).mul(new BN(10).pow(new BN(16)))); - await I_STRProxied.getFees("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); - feesTicker = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); - feesToken = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); - // No change as difference is less than 10% - assert.equal(feesTicker[0].toString(), origPriceUSD.toString()); - assert.equal(feesTicker[1].toString(), origPricePOLY.toString()); - assert.equal(feesToken[0].toString(), origPriceUSD.toString()); - assert.equal(feesToken[1].toString(), origPricePOLY.toString()); - await I_POLYOracle.changePrice(new BN(20).mul(new BN(10).pow(new BN(16)))); - await I_STRProxied.getFees("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); - feesTicker = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); - feesToken = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); - let newPricePOLY = new BN(web3.utils.toWei("1250")); - assert.equal(feesTicker[0].toString(), origPriceUSD.toString()); - assert.equal(feesTicker[1].toString(), newPricePOLY.toString()); - assert.equal(feesToken[0].toString(), origPriceUSD.toString()); - assert.equal(feesToken[1].toString(), newPricePOLY.toString()); - await I_POLYOracle.changePrice(new BN(21).mul(new BN(10).pow(new BN(16)))); - await I_STRProxied.getFees("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); - feesTicker = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); - feesToken = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); - // No change as difference is less than 10% - assert.equal(feesTicker[0].toString(), origPriceUSD.toString()); - assert.equal(feesTicker[1].toString(), newPricePOLY.toString()); - assert.equal(feesToken[0].toString(), origPriceUSD.toString()); - assert.equal(feesToken[1].toString(), newPricePOLY.toString()); - await I_StablePOLYOracle.changeEvictPercentage(new BN(10).pow(new BN(16))); - await I_STRProxied.getFees("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); - feesTicker = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); - feesToken = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); - // Change as eviction percentage updated - // newPricePOLY = new BN(web3.utils.toWei("1250")); - //1190.476190476190476190 = 250/0.21 - assert.equal(feesTicker[0].toString(), origPriceUSD.toString()); - assert.equal(feesTicker[1].toString(), "1190476190476190476190"); - assert.equal(feesToken[0].toString(), origPriceUSD.toString()); - assert.equal(feesToken[1].toString(), "1190476190476190476190"); - await revertToSnapshot(snap_Id); - }); - - it("Should register the ticker when the tickerRegFee is 0", async () => { - let snap_Id = await takeSnapshot(); - await I_STRProxied.changeTickerRegistrationFee(0, { from: account_polymath }); - let tx = await I_STRProxied.registerTicker(account_temp, "ZERO", name, { from: account_temp }); - assert.equal(tx.logs[0].args._owner, account_temp, `Owner should be the ${account_temp}`); - assert.equal(tx.logs[0].args._ticker, "ZERO", `Symbol should be ZERO`); - await revertToSnapshot(snap_Id); - }); - - it("Should fail to register same symbol again", async () => { - // Give POLY to token issuer - await I_PolyToken.getTokens(initRegFeePOLY, token_owner); - await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); - // Call registration function - await catchRevert( - I_STRProxied.registerTicker(token_owner, symbol, name, { from: token_owner }), - "tx revert -> Symbol is already alloted to someone else" - ); - }); - - it("Should successfully register pre registerd ticker if expiry is reached", async () => { - await increaseTime(5184000 + 100); // 60(5184000) days of expiry + 100 sec for buffer - await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); - let tx = await I_STRProxied.registerTicker(token_owner, symbol, name, { from: token_owner }); - assert.equal(tx.logs[0].args._owner, token_owner, `Owner should be the ${token_owner}`); - assert.equal(tx.logs[0].args._ticker, symbol, `Symbol should be ${symbol}`); - }); - - it("Should fail to register ticker if registration is paused", async () => { - await I_STRProxied.pause({ from: account_polymath }); - await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); - - await catchRevert( - I_STRProxied.registerTicker(token_owner, "AAA", name, { from: token_owner }), - "tx revert -> Registration is paused" - ); - }); - - it("Should fail to pause if already paused", async () => { - await catchRevert(I_STRProxied.pause({ from: account_polymath }), "tx revert -> Registration is already paused"); - }); - - it("Should successfully register ticker if registration is unpaused", async () => { - await I_STRProxied.unpause({ from: account_polymath }); - await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); - let tx = await I_STRProxied.registerTicker(token_owner, "AAA", name, { from: token_owner }); - assert.equal(tx.logs[0].args._owner, token_owner, `Owner should be the ${token_owner}`); - assert.equal(tx.logs[0].args._ticker, "AAA", `Symbol should be AAA`); - }); - - it("Should fail to unpause if already unpaused", async () => { - await catchRevert(I_STRProxied.unpause({ from: account_polymath }), "tx revert -> Registration is already unpaused"); - }); - }); - - describe("Test cases for the expiry limit", async () => { - it("Should fail to set the expiry limit because msg.sender is not owner", async () => { - await catchRevert(I_STRProxied.changeExpiryLimit(duration.days(10), { from: account_temp }), "tx revert -> msg.sender is not owner"); - }); - - it("Should successfully set the expiry limit", async () => { - await I_STRProxied.changeExpiryLimit(duration.days(10), { from: account_polymath }); - assert.equal( - (await I_STRProxied.getUintValue.call(web3.utils.soliditySha3("expiryLimit"))).toNumber(), - duration.days(10), - "Failed to change the expiry limit" - ); - }); - - it("Should fail to set the expiry limit because new expiry limit is lesser than one day", async () => { - await catchRevert( - I_STRProxied.changeExpiryLimit(duration.seconds(5000), { from: account_polymath }), - "tx revert -> New expiry limit is lesser than one day" - ); - }); - }); - - describe("Test cases for the getTickerDetails", async () => { - it("Should get the details of the symbol", async () => { - let tx = await I_Getter.getTickerDetails.call(symbol); - assert.equal(tx[0], token_owner, "Should equal to the rightful owner of the ticker"); - assert.equal(tx[3], name, `Name of the token should equal to ${name}`); - assert.equal(tx[4], false, "Status if the symbol should be undeployed -- false"); - }); - - it("Should get the details of unregistered token", async () => { - let tx = await I_Getter.getTickerDetails.call("TORO"); - assert.equal(tx[0], address_zero, "Should be 0x as ticker is not exists in the registry"); - assert.equal(tx[3], "", "Should be an empty string"); - assert.equal(tx[4], false, "Status if the symbol should be undeployed -- false"); - }); - }); - - describe("Generate SecurityToken", async () => { - it("Should get the ticker details successfully and prove the data is not storing in to the logic contract", async () => { - let data = await I_Getter.getTickerDetails(symbol, { from: token_owner }); - assert.equal(data[0], token_owner, "Token owner should be equal"); - assert.equal(data[3], name, "Name of the token should match with the registered symbol infor"); - assert.equal(data[4], false, "Token is not launched yet so it should return False"); - data = await I_STRGetter.getTickerDetails(symbol, { from: token_owner }); - console.log("This is the data from the original securityTokenRegistry contract"); - assert.equal(data[0], address_zero, "Token owner should be 0x"); - }); - - it("Should fail to generate new security token if fee not provided", async () => { - await I_PolyToken.approve(I_STRProxied.address, new BN(0), { from: token_owner }); - - await catchRevert( - I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }), - "tx revert -> POLY allowance not provided for registration fee" - ); - }); - - it("Should fail to generate token if registration is paused", async () => { - await I_STRProxied.pause({ from: account_polymath }); - await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); - - await catchRevert( - I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }), - "tx revert -> Registration is paused" - ); - }); - - it("Should fail to generate the securityToken -- Because ticker length is 0", async () => { - await I_STRProxied.unpause({ from: account_polymath }); - - await catchRevert( - I_STRProxied.generateSecurityToken(name, "0x0", tokenDetails, false, { from: token_owner }), - "tx revert -> Zero ticker length is not allowed" - ); - }); - - it("Should fail to generate the securityToken -- Because name length is 0", async () => { - await catchRevert( - I_STRProxied.generateSecurityToken("", symbol, tokenDetails, false, { from: token_owner }), - "tx revert -> 0 name length is not allowed" - ); - }); - - it("Should fail to generate the securityToken -- Because msg.sender is not the rightful owner of the ticker", async () => { - await catchRevert( - I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: account_temp }), - "tx revert -> Because msg.sender is not the rightful owner of the ticker" - ); - }); - - it("Should generate the new security token with the same symbol as registered above", async () => { - - let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); - - // Verify the successful generation of the security token - assert.equal(tx.logs[2].args._ticker, symbol, "SecurityToken doesn't get deployed"); - - I_SecurityToken = await SecurityToken.at(tx.logs[2].args._securityTokenAddress); - stGetter = await STGetter.at(I_SecurityToken.address); - const log = (await I_SecurityToken.getPastEvents('ModuleAdded', {filter: {transactionHash: tx.transactionHash}}))[0]; - - // Verify that GeneralTrasnferManager module get added successfully or not - assert.equal(log.args._types[0].toNumber(), transferManagerKey, `Should be equal to the ${transferManagerKey}`); - assert.equal(web3.utils.toAscii(log.args._name).replace(/\u0000/g, ""), "GeneralTransferManager"); - }); - - it("Should fail to generate the SecurityToken when token is already deployed with the same symbol", async () => { - await catchRevert( - I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }), - "tx revert -> Because ticker is already in use" - ); - }); - - it("Should fail to generate the SecurityToken because ticker gets expired", async () => { - let snap_Id = await takeSnapshot(); - await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("2000")), { from: token_owner }); - let tx = await I_STRProxied.registerTicker(token_owner, "CCC", name, { from: token_owner }); - await increaseTime(duration.days(65)); - await catchRevert( - I_STRProxied.generateSecurityToken(name, "CCC", tokenDetails, false, { from: token_owner }), - "tx revert -> Because ticker is expired" - ); - await revertToSnapshot(snap_Id); - }); - - it("Should generate the SecurityToken when launch fee is 0", async () => { - let snap_Id = await takeSnapshot(); - await I_STRProxied.changeSecurityLaunchFee(0, { from: account_polymath }); - await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("2000")), { from: token_owner }); - let tx = await I_STRProxied.registerTicker(token_owner, "CCC", name, { from: token_owner }); - await I_STRProxied.generateSecurityToken(name, "CCC", tokenDetails, false, { from: token_owner }), - await revertToSnapshot(snap_Id); - }); - - it("Should get all created security tokens", async() => { - let snap_Id = await takeSnapshot(); - await I_PolyToken.getTokens(web3.utils.toWei("2000"), account_temp); - await I_PolyToken.approve(I_STRProxied.address, web3.utils.toWei("2000"), { from: account_temp }); - await I_STRProxied.registerTicker(account_temp, "TMP", name, { from: account_temp }); - let tx = await I_STRProxied.generateSecurityToken(name, "TMP", tokenDetails, false, { from: account_temp }); - - // Verify the successful generation of the security token - assert.equal(tx.logs[2].args._ticker, "TMP", "SecurityToken doesn't get deployed"); - - let securityTokenTmp = await SecurityToken.at(tx.logs[2].args._securityTokenAddress); - - let tokens = await I_Getter.getTokensByOwner.call(token_owner); - assert.equal(tokens.length, 1, "tokens array length error"); - assert.equal(tokens[0], I_SecurityToken.address, "ST address incorrect"); - - let allTokens = await I_Getter.getTokens.call(); - assert.equal(allTokens.length, 2); - assert.equal(allTokens[0], securityTokenTmp.address); - assert.equal(allTokens[1], I_SecurityToken.address); - - await revertToSnapshot(snap_Id); - }); - }); - - describe("Generate SecurityToken v2", async () => { - it("Should deploy the st version 2", async () => { - // Step 7: Deploy the STFactory contract - I_STGetter = await STGetter.new(); - let I_DataStoreLogic = await DataStoreLogic.new({ from: account_polymath }); - let I_DataStoreFactory = await DataStoreFactory.new(I_DataStoreLogic.address, { from: account_polymath }); - - I_STFactory002 = await STFactory.new(I_GeneralTransferManagerFactory.address, I_DataStoreFactory.address, I_STGetter.address, { from: account_polymath }); - - assert.notEqual( - I_STFactory002.address.valueOf(), - address_zero, - "STFactory002 contract was not deployed" - ); - await I_STRProxied.setProtocolVersion(I_STFactory002.address, new BN(2), new BN(2), new BN(0), { from: account_polymath }); - let _protocol = await I_Getter.getProtocolVersion.call(); - assert.equal(_protocol[0], 2); - assert.equal(_protocol[1], 2); - assert.equal(_protocol[2], 0); - }); - - it("Should register the ticker before the generation of the security token", async () => { - await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); - let tx = await I_STRProxied.registerTicker(token_owner, symbol2, name2, { from: token_owner }); - assert.equal(tx.logs[0].args._owner, token_owner, `Token owner should be ${token_owner}`); - assert.equal(tx.logs[0].args._ticker, symbol2, `Symbol should be ${symbol2}`); - }); - - it("Should generate the new security token with version 2", async () => { - await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); - - let tx = await I_STRProxied.generateSecurityToken(name2, symbol2, tokenDetails, false, { from: token_owner }); - - // Verify the successful generation of the security token - assert.equal(tx.logs[2].args._ticker, symbol2, "SecurityToken doesn't get deployed"); - - I_SecurityToken002 = await SecurityToken.at(tx.logs[2].args._securityTokenAddress); - const log = (await I_SecurityToken002.getPastEvents('ModuleAdded'))[0]; - // Verify that GeneralTransferManager module get added successfully or not - assert.equal(log.args._types[0].toNumber(), transferManagerKey); - assert.equal(web3.utils.toAscii(log.args._name).replace(/\u0000/g, ""), "GeneralTransferManager"); - }); - }); - - describe("Deploy the new SecurityTokenRegistry", async () => { - it("Should deploy the new SecurityTokenRegistry contract logic", async () => { - I_SecurityTokenRegistryV2 = await SecurityTokenRegistryMock.new({ from: account_polymath }); - assert.notEqual(I_SecurityTokenRegistryV2.address.valueOf(), address_zero, "SecurityTokenRegistry contract was not deployed"); - }); - - it("Should fail to upgrade the logic contract of the STRProxy -- bad owner", async () => { - await I_STRProxied.pause({ from: account_polymath }); - - await catchRevert( - I_SecurityTokenRegistryProxy.upgradeTo("1.1.0", I_SecurityTokenRegistryV2.address, { from: account_temp }), - "tx revert -> bad owner" - ); - }); - - it("Should upgrade the logic contract into the STRProxy", async () => { - await I_SecurityTokenRegistryProxy.upgradeTo("1.1.0", I_SecurityTokenRegistryV2.address, { from: account_polymath }); - I_STRProxied = await SecurityTokenRegistry.at(I_SecurityTokenRegistryProxy.address); - assert.isTrue(await I_STRProxied.getBoolValue.call(web3.utils.soliditySha3("paused")), "Paused value should be false"); - }); - - it("Should check the old data persist or not", async () => { - let data = await I_Getter.getTickerDetails.call(symbol); - assert.equal(data[0], token_owner, "Should be equal to the token owner address"); - assert.equal(data[3], name, "Should be equal to the name of the token that is provided earlier"); - assert.isTrue(data[4], "Token status should be deployed == true"); - }); - - it("Should unpause the logic contract", async () => { - await I_STRProxied.unpause({ from: account_polymath }); - assert.isFalse(await I_STRProxied.getBoolValue.call(web3.utils.soliditySha3("paused")), "Paused value should be false"); - }); - }); - - describe("Generate custom tokens", async () => { - it("Should fail if msg.sender is not polymath", async () => { - await catchRevert( - I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, { - from: account_delegate - }), - "tx revert -> msg.sender is not polymath account" - ); - }); - - it("Should fail to genrate the custom security token -- ticker length is greater than 10 chars", async () => { - await catchRevert( - I_STRProxied.modifySecurityToken("LOGAN", "LOGLOGLOGLOG", account_temp, dummy_token, "I am custom ST", currentTime, { - from: account_polymath - }), - "tx revert -> ticker length is greater than 10 chars" - ); - }); - - it("Should fail to generate the custom security token -- name should not be 0 length ", async () => { - await catchRevert( - I_STRProxied.modifySecurityToken("", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, { - from: account_polymath - }), - "tx revert -> name should not be 0 length" - ); - }); - - it("Should fail if ST address is 0 address", async () => { - await catchRevert( - I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, address_zero, "I am custom ST", currentTime, { - from: account_polymath - }), - "tx revert -> Security token address is 0" - ); - }); - - it("Should fail if symbol length is 0", async () => { - await catchRevert( - I_STRProxied.modifySecurityToken("", "0x0", account_temp, dummy_token, "I am custom ST", currentTime, { - from: account_polymath - }), - "tx revert -> zero length of the symbol is not allowed" - ); - }); - - it("Should fail to generate the custom ST -- deployedAt param is 0", async () => { - await catchRevert( - I_STRProxied.modifySecurityToken(name2, symbol2, token_owner, dummy_token, "I am custom ST", new BN(0), { from: account_polymath }), - "tx revert -> because deployedAt param is 0" - ); - }); - - it("Should successfully generate custom token", async () => { - // Register the new ticker -- Fulfiling the TickerStatus.ON condition - await I_PolyToken.getTokens(new BN(web3.utils.toWei("1000")), account_temp); - await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: account_temp }); - let tickersListArray = await I_Getter.getTickersByOwner.call(account_temp); - console.log(tickersListArray); - await I_STRProxied.registerTicker(account_temp, "LOG", "LOGAN", { from: account_temp }); - tickersListArray = await I_Getter.getTickersByOwner.call(account_temp); - console.log(tickersListArray); - // Generating the ST - let tx = await I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, { - from: account_polymath - }); - tickersListArray = await I_Getter.getTickersByOwner.call(account_temp); - console.log(tickersListArray); - assert.equal(tx.logs[1].args._ticker, "LOG", "Symbol should match with the registered symbol"); - assert.equal( - tx.logs[1].args._securityTokenAddress, - dummy_token, - `Address of the SecurityToken should be matched with the input value of addCustomSecurityToken` - ); - let symbolDetails = await I_Getter.getTickerDetails("LOG"); - assert.equal(symbolDetails[0], account_temp, `Owner of the symbol should be ${account_temp}`); - assert.equal(symbolDetails[3], "LOGAN", `Name of the symbol should be LOGAN`); - }); - - it("Should successfully generate the custom token", async () => { - // Fulfilling the TickerStatus.NN condition - // - // await catchRevert(I_STRProxied.modifySecurityToken("LOGAN2", "LOG2", account_temp, dummy_token, "I am custom ST", await latestTime(), {from: account_polymath})); - // await I_STRProxied.modifyTicker(account_temp, "LOG2", "LOGAN2", await latestTime(), currentTime.add(new BN(duration.days(10))), false, {from: account_polymath}); - // await increaseTime(duration.days(1)); - let tx = await I_STRProxied.modifySecurityToken("LOGAN2", "LOG2", account_temp, dummy_token, "I am custom ST", currentTime, { - from: account_polymath - }); - assert.equal(tx.logs[1].args._ticker, "LOG2", "Symbol should match with the registered symbol"); - assert.equal( - tx.logs[1].args._securityTokenAddress, - dummy_token, - `Address of the SecurityToken should be matched with the input value of addCustomSecurityToken` - ); - assert.equal(tx.logs[0].args._owner, account_temp, `Token owner should be ${account_temp}`); - assert.equal(tx.logs[0].args._ticker, "LOG2", `Symbol should be LOG2`); - let symbolDetails = await I_Getter.getTickerDetails("LOG2"); - assert.equal(symbolDetails[0], account_temp, `Owner of the symbol should be ${account_temp}`); - assert.equal(symbolDetails[3], "LOGAN2", `Name of the symbol should be LOGAN`); - }); - - it("Should successfully modify the ticker", async () => { - let snap_Id = await takeSnapshot(); - let tx = await I_STRProxied.modifyTicker( - account_temp, - "LOG2", - "LOGAN2", - currentTime, - currentTime.add(new BN(duration.days(60))), - false, - { from: account_polymath } - ); - await revertToSnapshot(snap_Id); - }); - }); - - describe("Test case for modifyTicker", async () => { - it("Should add the custom ticker --failed because of bad owner", async () => { - currentTime = new BN(await latestTime()); - await catchRevert( - I_STRProxied.modifyTicker(token_owner, "ETH", "Ether", currentTime, currentTime.add(new BN(duration.days(10))), false, { - from: account_temp - }), - "tx revert -> failed beacause of bad owner0" - ); - }); - - it("Should add the custom ticker --fail ticker length should not be 0", async () => { - await catchRevert( - I_STRProxied.modifyTicker(token_owner, "", "Ether", currentTime, currentTime.add(new BN(duration.days(10))), false, { - from: account_polymath - }), - "tx revert -> failed beacause ticker length should not be 0" - ); - }); - - it("Should add the custom ticker --failed because time should not be 0", async () => { - await catchRevert( - I_STRProxied.modifyTicker(token_owner, "ETH", "Ether", new BN(0), currentTime.add(new BN(duration.days(10))), false, { - from: account_polymath - }), - "tx revert -> failed because time should not be 0" - ); - }); - - it("Should add the custom ticker --failed because registeration date is greater than the expiryDate", async () => { - let ctime = currentTime; - await catchRevert( - I_STRProxied.modifyTicker(token_owner, "ETH", "Ether", ctime, ctime.sub(new BN(duration.minutes(10))), false, { - from: account_polymath - }), - "tx revert -> failed because registeration date is greater than the expiryDate" - ); - }); - - it("Should add the custom ticker --failed because owner should not be 0x", async () => { - let ctime = currentTime; - await catchRevert( - I_STRProxied.modifyTicker( - address_zero, - "ETH", - "Ether", - ctime, - ctime.add(new BN(duration.minutes(10))), - false, - { from: account_polymath } - ), - "tx revert -> failed because owner should not be 0x" - ); - }); - - it("Should add the new custom ticker", async () => { - let ctime = currentTime; - let tx = await I_STRProxied.modifyTicker( - account_temp, - "ETH", - "Ether", - ctime, - ctime.add(new BN(duration.minutes(10))), - false, - { from: account_polymath } - ); - assert.equal(tx.logs[0].args._owner, account_temp, `Should be equal to the ${account_temp}`); - assert.equal(tx.logs[0].args._ticker, "ETH", "Should be equal to ETH"); - }); - - it("Should change the details of the existing ticker", async () => { - let ctime = currentTime; - let tx = await I_STRProxied.modifyTicker( - token_owner, - "ETH", - "Ether", - ctime, - ctime.add(new BN(duration.minutes(10))), - false, - { from: account_polymath } - ); - assert.equal(tx.logs[0].args._owner, token_owner); - }); - }); - - describe("Test cases for the transferTickerOwnership()", async () => { - it("Should able to transfer the ticker ownership -- failed because token is not deployed having the same ticker", async () => { - await catchRevert( - I_STRProxied.transferTickerOwnership(account_issuer, "ETH", { from: account_temp }), - "tx revert -> failed because token is not deployed having the same ticker" - ); - }); - - it("Should able to transfer the ticker ownership -- failed because new owner is 0x", async () => { - await I_SecurityToken002.transferOwnership(account_temp, { from: token_owner }); - await catchRevert( - I_STRProxied.transferTickerOwnership(address_zero, symbol2, { from: token_owner }), - "tx revert -> failed because new owner is 0x" - ); - }); - - it("Should able to transfer the ticker ownership -- failed because ticker is of zero length", async () => { - await catchRevert( - I_STRProxied.transferTickerOwnership(account_temp, "", { from: token_owner }), - "tx revert -> failed because ticker is of zero length" - ); - }); - - it("Should able to transfer the ticker ownership", async () => { - let tx = await I_STRProxied.transferTickerOwnership(account_temp, symbol2, { from: token_owner, gas: 5000000 }); - assert.equal(tx.logs[0].args._newOwner, account_temp); - let symbolDetails = await I_Getter.getTickerDetails.call(symbol2); - assert.equal(symbolDetails[0], account_temp, `Owner of the symbol should be ${account_temp}`); - assert.equal(symbolDetails[3], name2, `Name of the symbol should be ${name2}`); - }); - }); - - describe("Test case for the changeSecurityLaunchFee()", async () => { - it("Should able to change the STLaunchFee-- failed because of bad owner", async () => { - await catchRevert( - I_STRProxied.changeSecurityLaunchFee(new BN(web3.utils.toWei("500")), { from: account_temp }), - "tx revert -> failed because of bad owner" - ); - }); - - it("Should able to change the STLaunchFee-- failed because of putting the same fee", async () => { - await catchRevert( - I_STRProxied.changeSecurityLaunchFee(initRegFee, { from: account_polymath }), - "tx revert -> failed because of putting the same fee" - ); - }); - - it("Should able to change the STLaunchFee", async () => { - let tx = await I_STRProxied.changeSecurityLaunchFee(new BN(web3.utils.toWei("500")), { from: account_polymath }); - assert.equal(tx.logs[0].args._newFee.toString(), new BN(web3.utils.toWei("500")).toString()); - let stLaunchFee = await I_STRProxied.getUintValue(web3.utils.soliditySha3("stLaunchFee")); - assert.equal(stLaunchFee.toString(), new BN(web3.utils.toWei("500")).toString()); - }); - }); - - describe("Test cases for the changeExpiryLimit()", async () => { - it("Should able to change the ExpiryLimit-- failed because of bad owner", async () => { - await catchRevert( - I_STRProxied.changeExpiryLimit(duration.days(15), { from: account_temp }), - "tx revert -> failed because of bad owner" - ); - }); - - it("Should able to change the ExpiryLimit-- failed because expirylimit is less than 1 day", async () => { - await catchRevert( - I_STRProxied.changeExpiryLimit(duration.minutes(50), { from: account_polymath }), - "tx revert -> failed because expirylimit is less than 1 day" - ); - }); - - it("Should able to change the ExpiryLimit", async () => { - let tx = await I_STRProxied.changeExpiryLimit(duration.days(20), { from: account_polymath }); - assert.equal(tx.logs[0].args._newExpiry, duration.days(20)); - let expiry = await I_STRProxied.getUintValue(web3.utils.soliditySha3("expiryLimit")); - assert.equal(expiry, duration.days(20)); - }); - }); - - describe("Test cases for the changeTickerRegistrationFee()", async () => { - it("Should able to change the TickerRegFee-- failed because of bad owner", async () => { - await catchRevert( - I_STRProxied.changeTickerRegistrationFee(new BN(web3.utils.toWei("500")), { from: account_temp }), - "tx revert -> failed because of bad owner" - ); - }); - - it("Should able to change the TickerRegFee-- failed because of putting the same fee", async () => { - await catchRevert( - I_STRProxied.changeTickerRegistrationFee(initRegFee, { from: account_polymath }), - "tx revert -> failed because of putting the same fee" - ); - }); - - it("Should able to change the TickerRegFee", async () => { - let tx = await I_STRProxied.changeTickerRegistrationFee(new BN(web3.utils.toWei("400")), { from: account_polymath }); - assert.equal(tx.logs[0].args._newFee.toString(), new BN(web3.utils.toWei("400")).toString()); - let tickerRegFee = await I_STRProxied.getUintValue(web3.utils.soliditySha3("tickerRegFee")); - assert.equal(tickerRegFee.toString(), new BN(web3.utils.toWei("400")).toString()); - }); - - it("Should fail to register the ticker with the old fee", async () => { - await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); - await catchRevert( - I_STRProxied.registerTicker(token_owner, "POLY", "Polymath", { from: token_owner }), - "tx revert -> failed because of ticker registeration fee gets change" - ); - }); - - it("Should register the ticker with the new fee", async () => { - await I_PolyToken.getTokens(new BN(web3.utils.toWei("1600")), token_owner); - await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("2000")), { from: token_owner }); - let tx = await I_STRProxied.registerTicker(token_owner, "POLY", "Polymath", { from: token_owner }); - assert.equal(tx.logs[0].args._owner, token_owner, `Token owner should be ${token_owner}`); - assert.equal(tx.logs[0].args._ticker, "POLY", `Symbol should be POLY`); - }); - - it("Should fail to launch the securityToken with the old launch fee", async () => { - await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); - await catchRevert( - I_STRProxied.generateSecurityToken("Polymath", "POLY", tokenDetails, false, { from: token_owner }), - "tx revert -> failed because of old launch fee" - ); - }); - - it("Should launch the the securityToken", async () => { - await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("2000")), { from: token_owner }); - let tx = await I_STRProxied.generateSecurityToken("Polymath", "POLY", tokenDetails, false, { from: token_owner }); - - // Verify the successful generation of the security token - assert.equal(tx.logs[2].args._ticker, "POLY", "SecurityToken doesn't get deployed"); - }); - }); - - describe("Test case for the update poly token", async () => { - it("Should change the polytoken address -- failed because of bad owner", async () => { - catchRevert( - I_STRProxied.updatePolyTokenAddress(dummy_token, { from: account_temp }), - "tx revert -> failed because of bad owner" - ); - }); - - it("Should change the polytoken address -- failed because of 0x address", async () => { - catchRevert( - I_STRProxied.updatePolyTokenAddress(address_zero, { from: account_polymath }), - "tx revert -> failed because 0x address" - ); - }); - - it("Should successfully change the polytoken address", async () => { - let _id = await takeSnapshot(); - await I_STRProxied.updatePolyTokenAddress(dummy_token, { from: account_polymath }); - assert.equal(await I_STRProxied.getAddressValue.call(web3.utils.soliditySha3("polyToken")), dummy_token); - await revertToSnapshot(_id); - }); - }); - - describe("Test cases for getters", async () => { - it("Should get the security token address", async () => { - let address = await I_Getter.getSecurityTokenAddress.call(symbol); - assert.equal(address, I_SecurityToken.address); - }); - - it("Should get the security token data", async () => { - let data = await I_Getter.getSecurityTokenData.call(I_SecurityToken.address); - assert.equal(data[0], symbol); - assert.equal(data[1], token_owner); - }); - - it("Should get the tickers by owner", async () => { - let tickersList = await I_Getter.getTickersByOwner.call(token_owner); - console.log(tickersList); - assert.equal(tickersList.length, 4); - let tickersListArray = await I_Getter.getTickersByOwner.call(account_temp); - console.log(tickersListArray); - assert.equal(tickersListArray.length, 3); - }); - }); - - describe("Test case for the Removing the ticker", async () => { - it("Should remove the ticker from the polymath ecosystem -- bad owner", async () => { - await catchRevert( - I_STRProxied.removeTicker(symbol2, { from: account_investor1 }), - "tx revert -> failed because msg.sender should be account_polymath" - ); - }); - - it("Should remove the ticker from the polymath ecosystem -- fail because ticker doesn't exist in the ecosystem", async () => { - await catchRevert( - I_STRProxied.removeTicker("HOLA", { from: account_polymath }), - "tx revert -> failed because ticker doesn't exist in the polymath ecosystem" - ); - }); - - it("Should successfully remove the ticker from the polymath ecosystem", async () => { - let tx = await I_STRProxied.removeTicker(symbol2, { from: account_polymath }); - assert.equal(tx.logs[0].args._ticker, symbol2, "Ticker doesn't get deleted successfully"); - }); - }); - - describe(" Test cases of the registerTicker", async () => { - it("Should register the ticker 1", async () => { - await I_PolyToken.getTokens(new BN(web3.utils.toWei("1600")), account_temp); - await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("1600")), { from: account_temp }); - let tx = await I_STRProxied.registerTicker(account_temp, "TOK1", "0x0", { from: account_temp }); - assert.equal(tx.logs[0].args._owner, account_temp, `Owner should be the ${account_temp}`); - assert.equal(tx.logs[0].args._ticker, "TOK1", `Symbol should be TOK1`); - console.log((await I_Getter.getTickersByOwner.call(account_temp)).map(x => web3.utils.toUtf8(x))); - }); - - it("Should register the ticker 2", async () => { - await I_PolyToken.getTokens(new BN(web3.utils.toWei("1600")), account_temp); - await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("1600")), { from: account_temp }); - let tx = await I_STRProxied.registerTicker(account_temp, "TOK2", "0x0", { from: account_temp }); - assert.equal(tx.logs[0].args._owner, account_temp, `Owner should be the ${account_temp}`); - assert.equal(tx.logs[0].args._ticker, "TOK2", `Symbol should be TOK2`); - console.log((await I_Getter.getTickersByOwner.call(account_temp)).map(x => web3.utils.toUtf8(x))); - }); - - it("Should register the ticker 3", async () => { - await I_PolyToken.getTokens(new BN(web3.utils.toWei("1600")), account_temp); - await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("1600")), { from: account_temp }); - let tx = await I_STRProxied.registerTicker(account_temp, "TOK3", "0x0", { from: account_temp }); - assert.equal(tx.logs[0].args._owner, account_temp, `Owner should be the ${account_temp}`); - assert.equal(tx.logs[0].args._ticker, "TOK3", `Symbol should be TOK3`); - console.log((await I_Getter.getTickersByOwner.call(account_temp)).map(x => web3.utils.toUtf8(x))); - }); - - it("Should successfully remove the ticker 2", async () => { - let tx = await I_STRProxied.removeTicker("TOK2", { from: account_polymath }); - assert.equal(tx.logs[0].args._ticker, "TOK2", "Ticker doesn't get deleted successfully"); - console.log((await I_Getter.getTickersByOwner.call(account_temp)).map(x => web3.utils.toUtf8(x))); - }); - - it("Should modify ticker 1", async () => { - currentTime = new BN(await latestTime()); - let tx = await I_STRProxied.modifyTicker( - account_temp, - "TOK1", - "TOKEN 1", - currentTime, - currentTime.add(new BN(duration.minutes(10))), - false, - { from: account_polymath } - ); - assert.equal(tx.logs[0].args._owner, account_temp, `Should be equal to the ${account_temp}`); - assert.equal(tx.logs[0].args._ticker, "TOK1", "Should be equal to TOK1"); - assert.equal(tx.logs[0].args._name, "TOKEN 1", "Should be equal to TOKEN 1"); - console.log((await I_Getter.getTickersByOwner.call(account_temp)).map(x => web3.utils.toUtf8(x))); - }); - - it("Should modify ticker 3", async () => { - let tx = await I_STRProxied.modifyTicker( - account_temp, - "TOK3", - "TOKEN 3", - currentTime, - currentTime.add(new BN(duration.minutes(10))), - false, - { from: account_polymath } - ); - assert.equal(tx.logs[0].args._owner, account_temp, `Should be equal to the ${account_temp}`); - assert.equal(tx.logs[0].args._ticker, "TOK3", "Should be equal to TOK3"); - assert.equal(tx.logs[0].args._name, "TOKEN 3", "Should be equal to TOKEN 3"); - console.log((await I_Getter.getTickersByOwner.call(account_temp)).map(x => web3.utils.toUtf8(x))); - }); - }); - describe("Test cases for IRegistry functionality", async () => { - describe("Test cases for reclaiming funds", async () => { - it("Should successfully reclaim POLY tokens -- fail because token address will be 0x", async () => { - I_PolyToken.transfer(I_STRProxied.address, new BN(web3.utils.toWei("1")), { from: token_owner }); - await catchRevert(I_STRProxied.reclaimERC20(address_zero, { from: account_polymath })); - }); - - it("Should successfully reclaim POLY tokens -- not authorised", async () => { - await catchRevert(I_STRProxied.reclaimERC20(I_PolyToken.address, { from: account_temp })); - }); - - it("Should successfully reclaim POLY tokens", async () => { - let bal1 = await I_PolyToken.balanceOf.call(account_polymath); - await I_STRProxied.reclaimERC20(I_PolyToken.address, { from: account_polymath }); - let bal2 = await I_PolyToken.balanceOf.call(account_polymath); - assert.isAtLeast( - bal2.div(new BN(10).pow(new BN(18))).toNumber(), - bal2.div(new BN(10).pow(new BN(18))).toNumber() - ); - }); - }); - - describe("Test cases for pausing the contract", async () => { - it("Should fail to pause if msg.sender is not owner", async () => { - await catchRevert(I_STRProxied.pause({ from: account_temp }), "tx revert -> msg.sender should be account_polymath"); - }); - - it("Should successfully pause the contract", async () => { - await I_STRProxied.pause({ from: account_polymath }); - let status = await I_STRProxied.getBoolValue.call(web3.utils.soliditySha3("paused")); - assert.isOk(status); - }); - - it("Should fail to unpause if msg.sender is not owner", async () => { - await catchRevert(I_STRProxied.unpause({ from: account_temp }), "tx revert -> msg.sender should be account_polymath"); - }); - - it("Should successfully unpause the contract", async () => { - await I_STRProxied.unpause({ from: account_polymath }); - let status = await I_STRProxied.getBoolValue.call(web3.utils.soliditySha3("paused")); - assert.isNotOk(status); - }); - }); - - describe("Test cases for the setProtocolVersion", async () => { - it("Should successfully change the protocolVersion -- failed because of bad owner", async () => { - await catchRevert(I_STRProxied.setProtocolVersion(accounts[8], 5, 6, 7, { from: account_temp })); - }); - - it("Should successfully change the protocolVersion -- failed because factory address is 0x", async () => { - await catchRevert( - I_STRProxied.setProtocolVersion(address_zero, 5, 6, 7, { from: account_polymath }) - ); - }); - - it("Should successfully change the protocolVersion -- not a valid vesrion", async () => { - await catchRevert(I_STRProxied.setProtocolVersion(accounts[8], new BN(0), new BN(0), new BN(0), { from: account_polymath })); - }); - - it("Should successfully change the protocolVersion -- fail in second attempt because of invalid version", async () => { - let snap_Id = await takeSnapshot(); - await I_STRProxied.setProtocolVersion(accounts[8], 2, 3, 1, { from: account_polymath }); - await catchRevert(I_STRProxied.setProtocolVersion(accounts[8], 1, 3, 1, { from: account_polymath })); - await revertToSnapshot(snap_Id); - }); - }); - - describe("Test cases for the transferOwnership", async () => { - it("Should fail to transfer the ownership -- not authorised", async () => { - await catchRevert(I_STRProxied.transferOwnership(account_temp, { from: account_issuer })); - }); - - it("Should fail to transfer the ownership -- 0x address is not allowed", async () => { - await catchRevert(I_STRProxied.transferOwnership(address_zero, { from: account_polymath })); - }); - - it("Should successfully transfer the ownership of the STR", async () => { - let tx = await I_STRProxied.transferOwnership(account_temp, { from: account_polymath }); - assert.equal(tx.logs[0].args.previousOwner, account_polymath); - assert.equal(tx.logs[0].args.newOwner, account_temp); - }); - }); - }); -}); +// import latestTime from "./helpers/latestTime"; +// import { duration, promisifyLogWatch, latestBlock } from "./helpers/utils"; +// import { takeSnapshot, increaseTime, revertToSnapshot } from "./helpers/time"; +// import { encodeProxyCall, encodeModuleCall } from "./helpers/encodeCall"; +// import { catchRevert } from "./helpers/exceptions"; +// import { setUpPolymathNetwork, deployDummySTOAndVerifyed } from "./helpers/createInstances"; + +// const DummySTO = artifacts.require("./DummySTO.sol"); +// const SecurityToken = artifacts.require("./SecurityToken.sol"); +// const SecurityTokenRegistryProxy = artifacts.require("./SecurityTokenRegistryProxy.sol"); +// const SecurityTokenRegistry = artifacts.require("./SecurityTokenRegistry.sol"); +// const SecurityTokenRegistryMock = artifacts.require("./SecurityTokenRegistryMock.sol"); +// const STFactory = artifacts.require("./STFactory.sol"); +// const STRGetter = artifacts.require('./STRGetter.sol'); +// const STGetter = artifacts.require("./STGetter.sol"); +// const DataStoreLogic = artifacts.require('./DataStore.sol'); +// const DataStoreFactory = artifacts.require('./DataStoreFactory.sol'); + + +// const Web3 = require("web3"); +// let BN = Web3.utils.BN; +// const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); // Hardcoded development port + +// contract("SecurityTokenRegistry", async (accounts) => { +// // Accounts Variable declaration +// let account_polymath; +// let account_investor1; +// let account_issuer; +// let token_owner; +// let account_investor2; +// let account_fundsReceiver; +// let account_delegate; +// let account_temp; +// let dummy_token; + +// let balanceOfReceiver; + +// let ID_snap; +// const message = "Transaction Should Fail!!"; + +// // Contract Instance Declaration +// let I_GeneralTransferManagerFactory; +// let I_GeneralPermissionManager; +// let I_GeneralTransferManager; +// let I_ModuleRegistryProxy; +// let I_ModuleRegistry; +// let I_FeatureRegistry; +// let I_SecurityTokenRegistry; +// let I_SecurityTokenRegistryV2; +// let I_DummySTOFactory; +// let I_STVersion; +// let I_SecurityToken; +// let I_DummySTO; +// let I_PolyToken; +// let I_STFactory; +// let I_STFactory002; +// let I_SecurityToken002; +// let I_STFactory003; +// let I_PolymathRegistry; +// let I_SecurityTokenRegistryProxy; +// let I_STRProxied; +// let I_MRProxied; +// let I_STRGetter; +// let I_Getter; +// let I_STGetter; +// let stGetter; +// let I_USDOracle; +// let I_POLYOracle; +// let I_StablePOLYOracle; + +// // SecurityToken Details (Launched ST on the behalf of the issuer) +// const name = "Demo Token"; +// const symbol = "DET"; +// const tokenDetails = "This is equity type of issuance"; +// const decimals = 18; + +// //Security Token Detials (Version 2) +// const name2 = "Demo2 Token"; +// const symbol2 = "DET2"; +// const tokenDetails2 = "This is equity type of issuance"; +// const address_zero = "0x0000000000000000000000000000000000000000"; +// const one_address = "0x0000000000000000000000000000000000000001"; + +// // Module key +// const permissionManagerKey = 1; +// const transferManagerKey = 2; +// const stoKey = 3; +// const budget = 0; + +// // Initial fee for ticker registry and security token registry +// const initRegFee = new BN(web3.utils.toWei("250")); +// const initRegFeePOLY = new BN(web3.utils.toWei("1000")); + +// const STRProxyParameters = ["address", "address", "uint256", "uint256", "address", "address"]; +// const STOParameters = ["uint256", "uint256", "uint256", "string"]; + +// // Capped STO details +// const cap = new BN(web3.utils.toWei("10000")); +// const someString = "Hello string"; + +// let currentTime; + +// before(async () => { +// currentTime = new BN(await latestTime()); +// account_polymath = accounts[0]; +// account_issuer = accounts[1]; +// account_investor1 = accounts[9]; +// account_investor2 = accounts[6]; +// account_fundsReceiver = accounts[4]; +// account_delegate = accounts[5]; +// account_temp = accounts[8]; +// token_owner = account_issuer; +// dummy_token = accounts[3]; + +// let instances = await setUpPolymathNetwork(account_polymath, token_owner); + +// [ +// I_PolymathRegistry, +// I_PolyToken, +// I_FeatureRegistry, +// I_ModuleRegistry, +// I_ModuleRegistryProxy, +// I_MRProxied, +// I_GeneralTransferManagerFactory, +// I_STFactory, +// I_SecurityTokenRegistry, +// I_SecurityTokenRegistryProxy, +// I_STRProxied, +// I_STRGetter, +// I_STGetter, +// I_USDOracle, +// I_POLYOracle, +// I_StablePOLYOracle +// ] = instances; + +// // STEP 8: Deploy the CappedSTOFactory + +// [I_DummySTOFactory] = await deployDummySTOAndVerifyed(account_polymath, I_MRProxied, 0); +// // Step 9: Deploy the SecurityTokenRegistry +// console.log(I_SecurityTokenRegistry.address); +// I_SecurityTokenRegistry = await SecurityTokenRegistry.new({ from: account_polymath }); +// console.log(I_SecurityTokenRegistry.address); + +// assert.notEqual( +// I_SecurityTokenRegistry.address.valueOf(), +// address_zero, +// "SecurityTokenRegistry contract was not deployed" +// ); + +// // Step 9 (a): Deploy the proxy +// I_SecurityTokenRegistryProxy = await SecurityTokenRegistryProxy.new({ from: account_polymath }); +// // Step 10 : Deploy the getter contract +// I_STRGetter = await STRGetter.new({ from: account_polymath }); +// //Step 11: update the registries addresses from the PolymathRegistry contract +// await I_PolymathRegistry.changeAddress("SecurityTokenRegistry", I_SecurityTokenRegistryProxy.address, { from: account_polymath }); +// await I_MRProxied.updateFromRegistry({ from: account_polymath }); + +// console.log(` +// --------------------- Polymath Network Smart Contracts: --------------------- +// PolymathRegistry: ${I_PolymathRegistry.address} +// SecurityTokenRegistryProxy: ${I_SecurityTokenRegistryProxy.address} +// SecurityTokenRegistry: ${I_SecurityTokenRegistry.address} +// ModuleRegistry: ${I_ModuleRegistry.address} +// ModuleRegistryProxy: ${I_ModuleRegistryProxy.address} +// FeatureRegistry: ${I_FeatureRegistry.address} + +// STFactory: ${I_STFactory.address} +// GeneralTransferManagerFactory: ${I_GeneralTransferManagerFactory.address} + +// DummySTOFactory: ${I_DummySTOFactory.address} +// ----------------------------------------------------------------------------- +// `); +// }); + +// describe("Test the initialize the function", async () => { +// it("Should successfully update the implementation address -- fail because polymathRegistry address is 0x", async () => { +// let bytesProxy = encodeProxyCall(STRProxyParameters, [ +// address_zero, +// I_STFactory.address, +// initRegFee, +// initRegFee, +// account_polymath, +// I_STRGetter.address +// ]); +// await catchRevert( +// I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { +// from: account_polymath +// }), +// "tx-> revert because polymathRegistry address is 0x" +// ); +// }); + +// it("Should successfully update the implementation address -- fail because STFactory address is 0x", async () => { +// let bytesProxy = encodeProxyCall(STRProxyParameters, [ +// I_PolymathRegistry.address, +// address_zero, +// initRegFee, +// initRegFee, +// account_polymath, +// I_STRGetter.address +// ]); +// await catchRevert( +// I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { +// from: account_polymath +// }), +// "tx-> revert because STFactory address is 0x" +// ); +// }); + +// it("Should successfully update the implementation address -- fail because STLaunch fee is 0", async () => { +// let bytesProxy = encodeProxyCall(STRProxyParameters, [ +// I_PolymathRegistry.address, +// I_STFactory.address, +// new BN(0), +// initRegFee, +// account_polymath, +// I_STRGetter.address +// ]); +// await catchRevert( +// I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { +// from: account_polymath +// }), +// "tx-> revert because STLaunch fee is 0" +// ); +// }); + +// it("Should successfully update the implementation address -- fail because tickerRegFee fee is 0", async () => { +// let bytesProxy = encodeProxyCall(STRProxyParameters, [ +// I_PolymathRegistry.address, +// I_STFactory.address, +// initRegFee, +// new BN(0), +// account_polymath, +// I_STRGetter.address +// ]); +// await catchRevert( +// I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { +// from: account_polymath +// }), +// "tx-> revert because tickerRegFee is 0" +// ); +// }); + +// it("Should successfully update the implementation address -- fail because owner address is 0x", async () => { +// let bytesProxy = encodeProxyCall(STRProxyParameters, [ +// I_PolymathRegistry.address, +// I_STFactory.address, +// initRegFee, +// initRegFee, +// address_zero, +// I_STRGetter.address +// ]); +// await catchRevert( +// I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { +// from: account_polymath +// }), +// "tx-> revert because owner address is 0x" +// ); +// }); + +// it("Should successfully update the implementation address -- fail because all params get 0", async () => { +// let bytesProxy = encodeProxyCall(STRProxyParameters, [address_zero, address_zero, new BN(0), new BN(0), address_zero, address_zero]); +// await catchRevert( +// I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { +// from: account_polymath +// }), +// "tx-> revert because owner address is 0x" +// ); +// }); + +// it("Should successfully update the implementation address", async () => { +// let bytesProxy = encodeProxyCall(STRProxyParameters, [ +// I_PolymathRegistry.address, +// I_STFactory.address, +// initRegFee, +// initRegFee, +// account_polymath, +// I_STRGetter.address +// ]); +// await I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { +// from: account_polymath +// }); +// I_Getter = await STRGetter.at(I_SecurityTokenRegistryProxy.address); +// I_STRProxied = await SecurityTokenRegistry.at(I_SecurityTokenRegistryProxy.address); +// }); +// }); + +// describe(" Test cases of the registerTicker", async () => { +// it("verify the intial parameters", async () => { +// let intialised = await I_STRProxied.getBoolValue.call(web3.utils.soliditySha3("initialised")); +// assert.isTrue(intialised, "Should be true"); + +// let expiry = await I_STRProxied.getUintValue.call(web3.utils.soliditySha3("expiryLimit")); +// assert.equal(expiry.toNumber(), 5184000, "Expiry limit should be equal to 60 days"); + +// let polytoken = await I_STRProxied.getAddressValue.call(web3.utils.soliditySha3("polyToken")); +// assert.equal(polytoken, I_PolyToken.address, "Should be the polytoken address"); + +// let stlaunchFee = await I_STRProxied.getUintValue.call(web3.utils.soliditySha3("stLaunchFee")); +// assert.equal(stlaunchFee.toString(), initRegFee.toString(), "Should be provided reg fee"); + +// let tickerRegFee = await I_STRProxied.getUintValue.call(web3.utils.soliditySha3("tickerRegFee")); +// assert.equal(tickerRegFee.toString(), tickerRegFee.toString(), "Should be provided reg fee"); + +// let polymathRegistry = await I_STRProxied.getAddressValue.call(web3.utils.soliditySha3("polymathRegistry")); +// assert.equal(polymathRegistry, I_PolymathRegistry.address, "Should be the address of the polymath registry"); + +// let getterContract = await I_STRProxied.getAddressValue.call(web3.utils.soliditySha3("STRGetter")); +// assert.equal(getterContract, I_STRGetter.address, "Should be the address of the getter contract"); + +// let owner = await I_STRProxied.getAddressValue.call(web3.utils.soliditySha3("owner")); +// assert.equal(owner, account_polymath, "Should be the address of the registry owner"); +// }); + +// it("Can't call the intialize function again", async () => { +// await catchRevert( +// I_STRProxied.initialize( +// I_PolymathRegistry.address, +// I_STFactory.address, +// initRegFee, +// initRegFee, +// account_polymath, +// I_STRGetter.address +// ), +// "tx revert -> Can't call the intialize function again" +// ); +// }); + +// it("Should fail to register ticker if tickerRegFee not approved", async () => { +// await catchRevert( +// I_STRProxied.registerTicker(account_temp, symbol, name, { from: account_temp }), +// "tx revert -> POLY allowance not provided for registration fee" +// ); +// }); + +// it("Should fail to register ticker if owner is 0x", async () => { +// await I_PolyToken.getTokens(initRegFeePOLY, account_temp); +// await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: account_temp }); + +// await catchRevert( +// I_STRProxied.registerTicker(address_zero, symbol, name, { from: account_temp }), +// "tx revert -> owner should not be 0x" +// ); +// }); + +// it("Should fail to register ticker due to the symbol length is 0", async () => { +// await catchRevert(I_STRProxied.registerTicker(account_temp, "", name, { from: account_temp }), "tx revert -> Symbol Length is 0"); +// }); + +// it("Should fail to register ticker due to the symbol length is greater than 10", async () => { +// await catchRevert( +// I_STRProxied.registerTicker(account_temp, "POLYMATHNET", name, { from: account_temp }), +// "tx revert -> Symbol Length is greater than 10" +// ); +// }); + +// it("Should register the ticker before the generation of the security token", async () => { +// let tx = await I_STRProxied.registerTicker(account_temp, symbol, name, { from: account_temp }); +// assert.equal(tx.logs[0].args._owner, account_temp, `Owner should be the ${account_temp}`); +// assert.equal(tx.logs[0].args._ticker, symbol, `Symbol should be ${symbol}`); +// let data = await I_Getter.getTickerDetails.call(symbol); +// assert.equal(data[0], account_temp); +// assert.equal(data[3], name); +// // trying to access the function data directly from the STRGetter then it should give all values zero +// data = await I_STRGetter.getTickerDetails.call(symbol); +// assert.equal(data[0], address_zero); +// assert.equal(data[3], ""); +// }); + +// it("Should change ticker price based on oracle", async () => { +// let snap_Id = await takeSnapshot(); +// let origPriceUSD = new BN(web3.utils.toWei("250")); +// let origPricePOLY = new BN(web3.utils.toWei("1000")); +// let currentRate = await I_POLYOracle.getPrice.call(); +// console.log("Current Rate: " + currentRate); +// let feesTicker = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); +// let feesToken = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); +// assert.equal(feesTicker[0].toString(), origPriceUSD.toString()); +// assert.equal(feesTicker[1].toString(), origPricePOLY.toString()); +// assert.equal(feesToken[0].toString(), origPriceUSD.toString()); +// assert.equal(feesToken[1].toString(), origPricePOLY.toString()); +// await I_POLYOracle.changePrice(new BN(27).mul(new BN(10).pow(new BN(16)))); +// await I_STRProxied.getFees("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); +// feesTicker = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); +// feesToken = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); +// // No change as difference is less than 10% +// assert.equal(feesTicker[0].toString(), origPriceUSD.toString()); +// assert.equal(feesTicker[1].toString(), origPricePOLY.toString()); +// assert.equal(feesToken[0].toString(), origPriceUSD.toString()); +// assert.equal(feesToken[1].toString(), origPricePOLY.toString()); +// await I_POLYOracle.changePrice(new BN(20).mul(new BN(10).pow(new BN(16)))); +// await I_STRProxied.getFees("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); +// feesTicker = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); +// feesToken = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); +// let newPricePOLY = new BN(web3.utils.toWei("1250")); +// assert.equal(feesTicker[0].toString(), origPriceUSD.toString()); +// assert.equal(feesTicker[1].toString(), newPricePOLY.toString()); +// assert.equal(feesToken[0].toString(), origPriceUSD.toString()); +// assert.equal(feesToken[1].toString(), newPricePOLY.toString()); +// await I_POLYOracle.changePrice(new BN(21).mul(new BN(10).pow(new BN(16)))); +// await I_STRProxied.getFees("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); +// feesTicker = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); +// feesToken = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); +// // No change as difference is less than 10% +// assert.equal(feesTicker[0].toString(), origPriceUSD.toString()); +// assert.equal(feesTicker[1].toString(), newPricePOLY.toString()); +// assert.equal(feesToken[0].toString(), origPriceUSD.toString()); +// assert.equal(feesToken[1].toString(), newPricePOLY.toString()); +// await I_StablePOLYOracle.changeEvictPercentage(new BN(10).pow(new BN(16))); +// await I_STRProxied.getFees("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); +// feesTicker = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); +// feesToken = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); +// // Change as eviction percentage updated +// // newPricePOLY = new BN(web3.utils.toWei("1250")); +// //1190.476190476190476190 = 250/0.21 +// assert.equal(feesTicker[0].toString(), origPriceUSD.toString()); +// assert.equal(feesTicker[1].toString(), "1190476190476190476190"); +// assert.equal(feesToken[0].toString(), origPriceUSD.toString()); +// assert.equal(feesToken[1].toString(), "1190476190476190476190"); +// await revertToSnapshot(snap_Id); +// }); + +// it("Should register the ticker when the tickerRegFee is 0", async () => { +// let snap_Id = await takeSnapshot(); +// await I_STRProxied.changeTickerRegistrationFee(0, { from: account_polymath }); +// let tx = await I_STRProxied.registerTicker(account_temp, "ZERO", name, { from: account_temp }); +// assert.equal(tx.logs[0].args._owner, account_temp, `Owner should be the ${account_temp}`); +// assert.equal(tx.logs[0].args._ticker, "ZERO", `Symbol should be ZERO`); +// await revertToSnapshot(snap_Id); +// }); + +// it("Should fail to register same symbol again", async () => { +// // Give POLY to token issuer +// await I_PolyToken.getTokens(initRegFeePOLY, token_owner); +// await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); +// // Call registration function +// await catchRevert( +// I_STRProxied.registerTicker(token_owner, symbol, name, { from: token_owner }), +// "tx revert -> Symbol is already alloted to someone else" +// ); +// }); + +// it("Should successfully register pre registerd ticker if expiry is reached", async () => { +// await increaseTime(5184000 + 100); // 60(5184000) days of expiry + 100 sec for buffer +// await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); +// let tx = await I_STRProxied.registerTicker(token_owner, symbol, name, { from: token_owner }); +// assert.equal(tx.logs[0].args._owner, token_owner, `Owner should be the ${token_owner}`); +// assert.equal(tx.logs[0].args._ticker, symbol, `Symbol should be ${symbol}`); +// }); + +// it("Should fail to register ticker if registration is paused", async () => { +// await I_STRProxied.pause({ from: account_polymath }); +// await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); + +// await catchRevert( +// I_STRProxied.registerTicker(token_owner, "AAA", name, { from: token_owner }), +// "tx revert -> Registration is paused" +// ); +// }); + +// it("Should fail to pause if already paused", async () => { +// await catchRevert(I_STRProxied.pause({ from: account_polymath }), "tx revert -> Registration is already paused"); +// }); + +// it("Should successfully register ticker if registration is unpaused", async () => { +// await I_STRProxied.unpause({ from: account_polymath }); +// await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); +// let tx = await I_STRProxied.registerTicker(token_owner, "AAA", name, { from: token_owner }); +// assert.equal(tx.logs[0].args._owner, token_owner, `Owner should be the ${token_owner}`); +// assert.equal(tx.logs[0].args._ticker, "AAA", `Symbol should be AAA`); +// }); + +// it("Should fail to unpause if already unpaused", async () => { +// await catchRevert(I_STRProxied.unpause({ from: account_polymath }), "tx revert -> Registration is already unpaused"); +// }); +// }); + +// describe("Test cases for the expiry limit", async () => { +// it("Should fail to set the expiry limit because msg.sender is not owner", async () => { +// await catchRevert(I_STRProxied.changeExpiryLimit(duration.days(10), { from: account_temp }), "tx revert -> msg.sender is not owner"); +// }); + +// it("Should successfully set the expiry limit", async () => { +// await I_STRProxied.changeExpiryLimit(duration.days(10), { from: account_polymath }); +// assert.equal( +// (await I_STRProxied.getUintValue.call(web3.utils.soliditySha3("expiryLimit"))).toNumber(), +// duration.days(10), +// "Failed to change the expiry limit" +// ); +// }); + +// it("Should fail to set the expiry limit because new expiry limit is lesser than one day", async () => { +// await catchRevert( +// I_STRProxied.changeExpiryLimit(duration.seconds(5000), { from: account_polymath }), +// "tx revert -> New expiry limit is lesser than one day" +// ); +// }); +// }); + +// describe("Test cases for the getTickerDetails", async () => { +// it("Should get the details of the symbol", async () => { +// let tx = await I_Getter.getTickerDetails.call(symbol); +// assert.equal(tx[0], token_owner, "Should equal to the rightful owner of the ticker"); +// assert.equal(tx[3], name, `Name of the token should equal to ${name}`); +// assert.equal(tx[4], false, "Status if the symbol should be undeployed -- false"); +// }); + +// it("Should get the details of unregistered token", async () => { +// let tx = await I_Getter.getTickerDetails.call("TORO"); +// assert.equal(tx[0], address_zero, "Should be 0x as ticker is not exists in the registry"); +// assert.equal(tx[3], "", "Should be an empty string"); +// assert.equal(tx[4], false, "Status if the symbol should be undeployed -- false"); +// }); +// }); + +// describe("Generate SecurityToken", async () => { +// it("Should get the ticker details successfully and prove the data is not storing in to the logic contract", async () => { +// let data = await I_Getter.getTickerDetails(symbol, { from: token_owner }); +// assert.equal(data[0], token_owner, "Token owner should be equal"); +// assert.equal(data[3], name, "Name of the token should match with the registered symbol infor"); +// assert.equal(data[4], false, "Token is not launched yet so it should return False"); +// data = await I_STRGetter.getTickerDetails(symbol, { from: token_owner }); +// console.log("This is the data from the original securityTokenRegistry contract"); +// assert.equal(data[0], address_zero, "Token owner should be 0x"); +// }); + +// it("Should fail to generate new security token if fee not provided", async () => { +// await I_PolyToken.approve(I_STRProxied.address, new BN(0), { from: token_owner }); + +// await catchRevert( +// I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }), +// "tx revert -> POLY allowance not provided for registration fee" +// ); +// }); + +// it("Should fail to generate token if registration is paused", async () => { +// await I_STRProxied.pause({ from: account_polymath }); +// await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); + +// await catchRevert( +// I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }), +// "tx revert -> Registration is paused" +// ); +// }); + +// it("Should fail to generate the securityToken -- Because ticker length is 0", async () => { +// await I_STRProxied.unpause({ from: account_polymath }); + +// await catchRevert( +// I_STRProxied.generateSecurityToken(name, "0x0", tokenDetails, false, { from: token_owner }), +// "tx revert -> Zero ticker length is not allowed" +// ); +// }); + +// it("Should fail to generate the securityToken -- Because name length is 0", async () => { +// await catchRevert( +// I_STRProxied.generateSecurityToken("", symbol, tokenDetails, false, { from: token_owner }), +// "tx revert -> 0 name length is not allowed" +// ); +// }); + +// it("Should fail to generate the securityToken -- Because msg.sender is not the rightful owner of the ticker", async () => { +// await catchRevert( +// I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: account_temp }), +// "tx revert -> Because msg.sender is not the rightful owner of the ticker" +// ); +// }); + +// it("Should generate the new security token with the same symbol as registered above", async () => { + +// let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); + +// // Verify the successful generation of the security token +// assert.equal(tx.logs[2].args._ticker, symbol, "SecurityToken doesn't get deployed"); + +// I_SecurityToken = await SecurityToken.at(tx.logs[2].args._securityTokenAddress); +// stGetter = await STGetter.at(I_SecurityToken.address); +// const log = (await I_SecurityToken.getPastEvents('ModuleAdded', {filter: {transactionHash: tx.transactionHash}}))[0]; + +// // Verify that GeneralTrasnferManager module get added successfully or not +// assert.equal(log.args._types[0].toNumber(), transferManagerKey, `Should be equal to the ${transferManagerKey}`); +// assert.equal(web3.utils.toAscii(log.args._name).replace(/\u0000/g, ""), "GeneralTransferManager"); +// }); + +// it("Should fail to generate the SecurityToken when token is already deployed with the same symbol", async () => { +// await catchRevert( +// I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }), +// "tx revert -> Because ticker is already in use" +// ); +// }); + +// it("Should fail to generate the SecurityToken because ticker gets expired", async () => { +// let snap_Id = await takeSnapshot(); +// await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("2000")), { from: token_owner }); +// let tx = await I_STRProxied.registerTicker(token_owner, "CCC", name, { from: token_owner }); +// await increaseTime(duration.days(65)); +// await catchRevert( +// I_STRProxied.generateSecurityToken(name, "CCC", tokenDetails, false, { from: token_owner }), +// "tx revert -> Because ticker is expired" +// ); +// await revertToSnapshot(snap_Id); +// }); + +// it("Should generate the SecurityToken when launch fee is 0", async () => { +// let snap_Id = await takeSnapshot(); +// await I_STRProxied.changeSecurityLaunchFee(0, { from: account_polymath }); +// await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("2000")), { from: token_owner }); +// let tx = await I_STRProxied.registerTicker(token_owner, "CCC", name, { from: token_owner }); +// await I_STRProxied.generateSecurityToken(name, "CCC", tokenDetails, false, { from: token_owner }), +// await revertToSnapshot(snap_Id); +// }); + +// it("Should get all created security tokens", async() => { +// let snap_Id = await takeSnapshot(); +// await I_PolyToken.getTokens(web3.utils.toWei("2000"), account_temp); +// await I_PolyToken.approve(I_STRProxied.address, web3.utils.toWei("2000"), { from: account_temp }); +// await I_STRProxied.registerTicker(account_temp, "TMP", name, { from: account_temp }); +// let tx = await I_STRProxied.generateSecurityToken(name, "TMP", tokenDetails, false, { from: account_temp }); + +// // Verify the successful generation of the security token +// assert.equal(tx.logs[2].args._ticker, "TMP", "SecurityToken doesn't get deployed"); + +// let securityTokenTmp = await SecurityToken.at(tx.logs[2].args._securityTokenAddress); + +// let tokens = await I_Getter.getTokensByOwner.call(token_owner); +// assert.equal(tokens.length, 1, "tokens array length error"); +// assert.equal(tokens[0], I_SecurityToken.address, "ST address incorrect"); + +// let allTokens = await I_Getter.getTokens.call(); +// assert.equal(allTokens.length, 2); +// assert.equal(allTokens[0], securityTokenTmp.address); +// assert.equal(allTokens[1], I_SecurityToken.address); + +// await revertToSnapshot(snap_Id); +// }); +// }); + +// describe("Generate SecurityToken v2", async () => { +// it("Should deploy the st version 2", async () => { +// // Step 7: Deploy the STFactory contract +// I_STGetter = await STGetter.new(); +// let I_DataStoreLogic = await DataStoreLogic.new({ from: account_polymath }); +// let I_DataStoreFactory = await DataStoreFactory.new(I_DataStoreLogic.address, { from: account_polymath }); + +// I_STFactory002 = await STFactory.new(I_GeneralTransferManagerFactory.address, I_DataStoreFactory.address, I_STGetter.address, { from: account_polymath }); + +// assert.notEqual( +// I_STFactory002.address.valueOf(), +// address_zero, +// "STFactory002 contract was not deployed" +// ); +// await I_STRProxied.setProtocolVersion(I_STFactory002.address, new BN(2), new BN(2), new BN(0), { from: account_polymath }); +// let _protocol = await I_Getter.getProtocolVersion.call(); +// assert.equal(_protocol[0], 2); +// assert.equal(_protocol[1], 2); +// assert.equal(_protocol[2], 0); +// }); + +// it("Should register the ticker before the generation of the security token", async () => { +// await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); +// let tx = await I_STRProxied.registerTicker(token_owner, symbol2, name2, { from: token_owner }); +// assert.equal(tx.logs[0].args._owner, token_owner, `Token owner should be ${token_owner}`); +// assert.equal(tx.logs[0].args._ticker, symbol2, `Symbol should be ${symbol2}`); +// }); + +// it("Should generate the new security token with version 2", async () => { +// await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); + +// let tx = await I_STRProxied.generateSecurityToken(name2, symbol2, tokenDetails, false, { from: token_owner }); + +// // Verify the successful generation of the security token +// assert.equal(tx.logs[2].args._ticker, symbol2, "SecurityToken doesn't get deployed"); + +// I_SecurityToken002 = await SecurityToken.at(tx.logs[2].args._securityTokenAddress); +// const log = (await I_SecurityToken002.getPastEvents('ModuleAdded'))[0]; +// // Verify that GeneralTransferManager module get added successfully or not +// assert.equal(log.args._types[0].toNumber(), transferManagerKey); +// assert.equal(web3.utils.toAscii(log.args._name).replace(/\u0000/g, ""), "GeneralTransferManager"); +// }); +// }); + +// describe("Deploy the new SecurityTokenRegistry", async () => { +// it("Should deploy the new SecurityTokenRegistry contract logic", async () => { +// I_SecurityTokenRegistryV2 = await SecurityTokenRegistryMock.new({ from: account_polymath }); +// assert.notEqual(I_SecurityTokenRegistryV2.address.valueOf(), address_zero, "SecurityTokenRegistry contract was not deployed"); +// }); + +// it("Should fail to upgrade the logic contract of the STRProxy -- bad owner", async () => { +// await I_STRProxied.pause({ from: account_polymath }); + +// await catchRevert( +// I_SecurityTokenRegistryProxy.upgradeTo("1.1.0", I_SecurityTokenRegistryV2.address, { from: account_temp }), +// "tx revert -> bad owner" +// ); +// }); + +// it("Should upgrade the logic contract into the STRProxy", async () => { +// await I_SecurityTokenRegistryProxy.upgradeTo("1.1.0", I_SecurityTokenRegistryV2.address, { from: account_polymath }); +// I_STRProxied = await SecurityTokenRegistry.at(I_SecurityTokenRegistryProxy.address); +// assert.isTrue(await I_STRProxied.getBoolValue.call(web3.utils.soliditySha3("paused")), "Paused value should be false"); +// }); + +// it("Should check the old data persist or not", async () => { +// let data = await I_Getter.getTickerDetails.call(symbol); +// assert.equal(data[0], token_owner, "Should be equal to the token owner address"); +// assert.equal(data[3], name, "Should be equal to the name of the token that is provided earlier"); +// assert.isTrue(data[4], "Token status should be deployed == true"); +// }); + +// it("Should unpause the logic contract", async () => { +// await I_STRProxied.unpause({ from: account_polymath }); +// assert.isFalse(await I_STRProxied.getBoolValue.call(web3.utils.soliditySha3("paused")), "Paused value should be false"); +// }); +// }); + +// describe("Generate custom tokens", async () => { +// it("Should fail if msg.sender is not polymath", async () => { +// await catchRevert( +// I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, { +// from: account_delegate +// }), +// "tx revert -> msg.sender is not polymath account" +// ); +// }); + +// it("Should fail to genrate the custom security token -- ticker length is greater than 10 chars", async () => { +// await catchRevert( +// I_STRProxied.modifySecurityToken("LOGAN", "LOGLOGLOGLOG", account_temp, dummy_token, "I am custom ST", currentTime, { +// from: account_polymath +// }), +// "tx revert -> ticker length is greater than 10 chars" +// ); +// }); + +// it("Should fail to generate the custom security token -- name should not be 0 length ", async () => { +// await catchRevert( +// I_STRProxied.modifySecurityToken("", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, { +// from: account_polymath +// }), +// "tx revert -> name should not be 0 length" +// ); +// }); + +// it("Should fail if ST address is 0 address", async () => { +// await catchRevert( +// I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, address_zero, "I am custom ST", currentTime, { +// from: account_polymath +// }), +// "tx revert -> Security token address is 0" +// ); +// }); + +// it("Should fail if symbol length is 0", async () => { +// await catchRevert( +// I_STRProxied.modifySecurityToken("", "0x0", account_temp, dummy_token, "I am custom ST", currentTime, { +// from: account_polymath +// }), +// "tx revert -> zero length of the symbol is not allowed" +// ); +// }); + +// it("Should fail to generate the custom ST -- deployedAt param is 0", async () => { +// await catchRevert( +// I_STRProxied.modifySecurityToken(name2, symbol2, token_owner, dummy_token, "I am custom ST", new BN(0), { from: account_polymath }), +// "tx revert -> because deployedAt param is 0" +// ); +// }); + +// it("Should successfully generate custom token", async () => { +// // Register the new ticker -- Fulfiling the TickerStatus.ON condition +// await I_PolyToken.getTokens(new BN(web3.utils.toWei("1000")), account_temp); +// await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: account_temp }); +// let tickersListArray = await I_Getter.getTickersByOwner.call(account_temp); +// console.log(tickersListArray); +// await I_STRProxied.registerTicker(account_temp, "LOG", "LOGAN", { from: account_temp }); +// tickersListArray = await I_Getter.getTickersByOwner.call(account_temp); +// console.log(tickersListArray); +// // Generating the ST +// let tx = await I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, { +// from: account_polymath +// }); +// tickersListArray = await I_Getter.getTickersByOwner.call(account_temp); +// console.log(tickersListArray); +// assert.equal(tx.logs[1].args._ticker, "LOG", "Symbol should match with the registered symbol"); +// assert.equal( +// tx.logs[1].args._securityTokenAddress, +// dummy_token, +// `Address of the SecurityToken should be matched with the input value of addCustomSecurityToken` +// ); +// let symbolDetails = await I_Getter.getTickerDetails("LOG"); +// assert.equal(symbolDetails[0], account_temp, `Owner of the symbol should be ${account_temp}`); +// assert.equal(symbolDetails[3], "LOGAN", `Name of the symbol should be LOGAN`); +// }); + +// it("Should successfully generate the custom token", async () => { +// // Fulfilling the TickerStatus.NN condition +// // +// // await catchRevert(I_STRProxied.modifySecurityToken("LOGAN2", "LOG2", account_temp, dummy_token, "I am custom ST", await latestTime(), {from: account_polymath})); +// // await I_STRProxied.modifyTicker(account_temp, "LOG2", "LOGAN2", await latestTime(), currentTime.add(new BN(duration.days(10))), false, {from: account_polymath}); +// // await increaseTime(duration.days(1)); +// let tx = await I_STRProxied.modifySecurityToken("LOGAN2", "LOG2", account_temp, dummy_token, "I am custom ST", currentTime, { +// from: account_polymath +// }); +// assert.equal(tx.logs[1].args._ticker, "LOG2", "Symbol should match with the registered symbol"); +// assert.equal( +// tx.logs[1].args._securityTokenAddress, +// dummy_token, +// `Address of the SecurityToken should be matched with the input value of addCustomSecurityToken` +// ); +// assert.equal(tx.logs[0].args._owner, account_temp, `Token owner should be ${account_temp}`); +// assert.equal(tx.logs[0].args._ticker, "LOG2", `Symbol should be LOG2`); +// let symbolDetails = await I_Getter.getTickerDetails("LOG2"); +// assert.equal(symbolDetails[0], account_temp, `Owner of the symbol should be ${account_temp}`); +// assert.equal(symbolDetails[3], "LOGAN2", `Name of the symbol should be LOGAN`); +// }); + +// it("Should successfully modify the ticker", async () => { +// let snap_Id = await takeSnapshot(); +// let tx = await I_STRProxied.modifyTicker( +// account_temp, +// "LOG2", +// "LOGAN2", +// currentTime, +// currentTime.add(new BN(duration.days(60))), +// false, +// { from: account_polymath } +// ); +// await revertToSnapshot(snap_Id); +// }); +// }); + +// describe("Test case for modifyTicker", async () => { +// it("Should add the custom ticker --failed because of bad owner", async () => { +// currentTime = new BN(await latestTime()); +// await catchRevert( +// I_STRProxied.modifyTicker(token_owner, "ETH", "Ether", currentTime, currentTime.add(new BN(duration.days(10))), false, { +// from: account_temp +// }), +// "tx revert -> failed beacause of bad owner0" +// ); +// }); + +// it("Should add the custom ticker --fail ticker length should not be 0", async () => { +// await catchRevert( +// I_STRProxied.modifyTicker(token_owner, "", "Ether", currentTime, currentTime.add(new BN(duration.days(10))), false, { +// from: account_polymath +// }), +// "tx revert -> failed beacause ticker length should not be 0" +// ); +// }); + +// it("Should add the custom ticker --failed because time should not be 0", async () => { +// await catchRevert( +// I_STRProxied.modifyTicker(token_owner, "ETH", "Ether", new BN(0), currentTime.add(new BN(duration.days(10))), false, { +// from: account_polymath +// }), +// "tx revert -> failed because time should not be 0" +// ); +// }); + +// it("Should add the custom ticker --failed because registeration date is greater than the expiryDate", async () => { +// let ctime = currentTime; +// await catchRevert( +// I_STRProxied.modifyTicker(token_owner, "ETH", "Ether", ctime, ctime.sub(new BN(duration.minutes(10))), false, { +// from: account_polymath +// }), +// "tx revert -> failed because registeration date is greater than the expiryDate" +// ); +// }); + +// it("Should add the custom ticker --failed because owner should not be 0x", async () => { +// let ctime = currentTime; +// await catchRevert( +// I_STRProxied.modifyTicker( +// address_zero, +// "ETH", +// "Ether", +// ctime, +// ctime.add(new BN(duration.minutes(10))), +// false, +// { from: account_polymath } +// ), +// "tx revert -> failed because owner should not be 0x" +// ); +// }); + +// it("Should add the new custom ticker", async () => { +// let ctime = currentTime; +// let tx = await I_STRProxied.modifyTicker( +// account_temp, +// "ETH", +// "Ether", +// ctime, +// ctime.add(new BN(duration.minutes(10))), +// false, +// { from: account_polymath } +// ); +// assert.equal(tx.logs[0].args._owner, account_temp, `Should be equal to the ${account_temp}`); +// assert.equal(tx.logs[0].args._ticker, "ETH", "Should be equal to ETH"); +// }); + +// it("Should change the details of the existing ticker", async () => { +// let ctime = currentTime; +// let tx = await I_STRProxied.modifyTicker( +// token_owner, +// "ETH", +// "Ether", +// ctime, +// ctime.add(new BN(duration.minutes(10))), +// false, +// { from: account_polymath } +// ); +// assert.equal(tx.logs[0].args._owner, token_owner); +// }); +// }); + +// describe("Test cases for the transferTickerOwnership()", async () => { +// it("Should able to transfer the ticker ownership -- failed because token is not deployed having the same ticker", async () => { +// await catchRevert( +// I_STRProxied.transferTickerOwnership(account_issuer, "ETH", { from: account_temp }), +// "tx revert -> failed because token is not deployed having the same ticker" +// ); +// }); + +// it("Should able to transfer the ticker ownership -- failed because new owner is 0x", async () => { +// await I_SecurityToken002.transferOwnership(account_temp, { from: token_owner }); +// await catchRevert( +// I_STRProxied.transferTickerOwnership(address_zero, symbol2, { from: token_owner }), +// "tx revert -> failed because new owner is 0x" +// ); +// }); + +// it("Should able to transfer the ticker ownership -- failed because ticker is of zero length", async () => { +// await catchRevert( +// I_STRProxied.transferTickerOwnership(account_temp, "", { from: token_owner }), +// "tx revert -> failed because ticker is of zero length" +// ); +// }); + +// it("Should able to transfer the ticker ownership", async () => { +// let tx = await I_STRProxied.transferTickerOwnership(account_temp, symbol2, { from: token_owner, gas: 5000000 }); +// assert.equal(tx.logs[0].args._newOwner, account_temp); +// let symbolDetails = await I_Getter.getTickerDetails.call(symbol2); +// assert.equal(symbolDetails[0], account_temp, `Owner of the symbol should be ${account_temp}`); +// assert.equal(symbolDetails[3], name2, `Name of the symbol should be ${name2}`); +// }); +// }); + +// describe("Test case for the changeSecurityLaunchFee()", async () => { +// it("Should able to change the STLaunchFee-- failed because of bad owner", async () => { +// await catchRevert( +// I_STRProxied.changeSecurityLaunchFee(new BN(web3.utils.toWei("500")), { from: account_temp }), +// "tx revert -> failed because of bad owner" +// ); +// }); + +// it("Should able to change the STLaunchFee-- failed because of putting the same fee", async () => { +// await catchRevert( +// I_STRProxied.changeSecurityLaunchFee(initRegFee, { from: account_polymath }), +// "tx revert -> failed because of putting the same fee" +// ); +// }); + +// it("Should able to change the STLaunchFee", async () => { +// let tx = await I_STRProxied.changeSecurityLaunchFee(new BN(web3.utils.toWei("500")), { from: account_polymath }); +// assert.equal(tx.logs[0].args._newFee.toString(), new BN(web3.utils.toWei("500")).toString()); +// let stLaunchFee = await I_STRProxied.getUintValue(web3.utils.soliditySha3("stLaunchFee")); +// assert.equal(stLaunchFee.toString(), new BN(web3.utils.toWei("500")).toString()); +// }); +// }); + +// describe("Test cases for the changeExpiryLimit()", async () => { +// it("Should able to change the ExpiryLimit-- failed because of bad owner", async () => { +// await catchRevert( +// I_STRProxied.changeExpiryLimit(duration.days(15), { from: account_temp }), +// "tx revert -> failed because of bad owner" +// ); +// }); + +// it("Should able to change the ExpiryLimit-- failed because expirylimit is less than 1 day", async () => { +// await catchRevert( +// I_STRProxied.changeExpiryLimit(duration.minutes(50), { from: account_polymath }), +// "tx revert -> failed because expirylimit is less than 1 day" +// ); +// }); + +// it("Should able to change the ExpiryLimit", async () => { +// let tx = await I_STRProxied.changeExpiryLimit(duration.days(20), { from: account_polymath }); +// assert.equal(tx.logs[0].args._newExpiry, duration.days(20)); +// let expiry = await I_STRProxied.getUintValue(web3.utils.soliditySha3("expiryLimit")); +// assert.equal(expiry, duration.days(20)); +// }); +// }); + +// describe("Test cases for the changeTickerRegistrationFee()", async () => { +// it("Should able to change the TickerRegFee-- failed because of bad owner", async () => { +// await catchRevert( +// I_STRProxied.changeTickerRegistrationFee(new BN(web3.utils.toWei("500")), { from: account_temp }), +// "tx revert -> failed because of bad owner" +// ); +// }); + +// it("Should able to change the TickerRegFee-- failed because of putting the same fee", async () => { +// await catchRevert( +// I_STRProxied.changeTickerRegistrationFee(initRegFee, { from: account_polymath }), +// "tx revert -> failed because of putting the same fee" +// ); +// }); + +// it("Should able to change the TickerRegFee", async () => { +// let tx = await I_STRProxied.changeTickerRegistrationFee(new BN(web3.utils.toWei("400")), { from: account_polymath }); +// assert.equal(tx.logs[0].args._newFee.toString(), new BN(web3.utils.toWei("400")).toString()); +// let tickerRegFee = await I_STRProxied.getUintValue(web3.utils.soliditySha3("tickerRegFee")); +// assert.equal(tickerRegFee.toString(), new BN(web3.utils.toWei("400")).toString()); +// }); + +// it("Should fail to register the ticker with the old fee", async () => { +// await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); +// await catchRevert( +// I_STRProxied.registerTicker(token_owner, "POLY", "Polymath", { from: token_owner }), +// "tx revert -> failed because of ticker registeration fee gets change" +// ); +// }); + +// it("Should register the ticker with the new fee", async () => { +// await I_PolyToken.getTokens(new BN(web3.utils.toWei("1600")), token_owner); +// await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("2000")), { from: token_owner }); +// let tx = await I_STRProxied.registerTicker(token_owner, "POLY", "Polymath", { from: token_owner }); +// assert.equal(tx.logs[0].args._owner, token_owner, `Token owner should be ${token_owner}`); +// assert.equal(tx.logs[0].args._ticker, "POLY", `Symbol should be POLY`); +// }); + +// it("Should fail to launch the securityToken with the old launch fee", async () => { +// await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); +// await catchRevert( +// I_STRProxied.generateSecurityToken("Polymath", "POLY", tokenDetails, false, { from: token_owner }), +// "tx revert -> failed because of old launch fee" +// ); +// }); + +// it("Should launch the the securityToken", async () => { +// await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("2000")), { from: token_owner }); +// let tx = await I_STRProxied.generateSecurityToken("Polymath", "POLY", tokenDetails, false, { from: token_owner }); + +// // Verify the successful generation of the security token +// assert.equal(tx.logs[2].args._ticker, "POLY", "SecurityToken doesn't get deployed"); +// }); +// }); + +// describe("Test case for the update poly token", async () => { +// it("Should change the polytoken address -- failed because of bad owner", async () => { +// catchRevert( +// I_STRProxied.updatePolyTokenAddress(dummy_token, { from: account_temp }), +// "tx revert -> failed because of bad owner" +// ); +// }); + +// it("Should change the polytoken address -- failed because of 0x address", async () => { +// catchRevert( +// I_STRProxied.updatePolyTokenAddress(address_zero, { from: account_polymath }), +// "tx revert -> failed because 0x address" +// ); +// }); + +// it("Should successfully change the polytoken address", async () => { +// let _id = await takeSnapshot(); +// await I_STRProxied.updatePolyTokenAddress(dummy_token, { from: account_polymath }); +// assert.equal(await I_STRProxied.getAddressValue.call(web3.utils.soliditySha3("polyToken")), dummy_token); +// await revertToSnapshot(_id); +// }); +// }); + +// describe("Test cases for getters", async () => { +// it("Should get the security token address", async () => { +// let address = await I_Getter.getSecurityTokenAddress.call(symbol); +// assert.equal(address, I_SecurityToken.address); +// }); + +// it("Should get the security token data", async () => { +// let data = await I_Getter.getSecurityTokenData.call(I_SecurityToken.address); +// assert.equal(data[0], symbol); +// assert.equal(data[1], token_owner); +// }); + +// it("Should get the tickers by owner", async () => { +// let tickersList = await I_Getter.getTickersByOwner.call(token_owner); +// console.log(tickersList); +// assert.equal(tickersList.length, 4); +// let tickersListArray = await I_Getter.getTickersByOwner.call(account_temp); +// console.log(tickersListArray); +// assert.equal(tickersListArray.length, 3); +// }); +// }); + +// describe("Test case for the Removing the ticker", async () => { +// it("Should remove the ticker from the polymath ecosystem -- bad owner", async () => { +// await catchRevert( +// I_STRProxied.removeTicker(symbol2, { from: account_investor1 }), +// "tx revert -> failed because msg.sender should be account_polymath" +// ); +// }); + +// it("Should remove the ticker from the polymath ecosystem -- fail because ticker doesn't exist in the ecosystem", async () => { +// await catchRevert( +// I_STRProxied.removeTicker("HOLA", { from: account_polymath }), +// "tx revert -> failed because ticker doesn't exist in the polymath ecosystem" +// ); +// }); + +// it("Should successfully remove the ticker from the polymath ecosystem", async () => { +// let tx = await I_STRProxied.removeTicker(symbol2, { from: account_polymath }); +// assert.equal(tx.logs[0].args._ticker, symbol2, "Ticker doesn't get deleted successfully"); +// }); +// }); + +// describe(" Test cases of the registerTicker", async () => { +// it("Should register the ticker 1", async () => { +// await I_PolyToken.getTokens(new BN(web3.utils.toWei("1600")), account_temp); +// await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("1600")), { from: account_temp }); +// let tx = await I_STRProxied.registerTicker(account_temp, "TOK1", "0x0", { from: account_temp }); +// assert.equal(tx.logs[0].args._owner, account_temp, `Owner should be the ${account_temp}`); +// assert.equal(tx.logs[0].args._ticker, "TOK1", `Symbol should be TOK1`); +// console.log((await I_Getter.getTickersByOwner.call(account_temp)).map(x => web3.utils.toUtf8(x))); +// }); + +// it("Should register the ticker 2", async () => { +// await I_PolyToken.getTokens(new BN(web3.utils.toWei("1600")), account_temp); +// await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("1600")), { from: account_temp }); +// let tx = await I_STRProxied.registerTicker(account_temp, "TOK2", "0x0", { from: account_temp }); +// assert.equal(tx.logs[0].args._owner, account_temp, `Owner should be the ${account_temp}`); +// assert.equal(tx.logs[0].args._ticker, "TOK2", `Symbol should be TOK2`); +// console.log((await I_Getter.getTickersByOwner.call(account_temp)).map(x => web3.utils.toUtf8(x))); +// }); + +// it("Should register the ticker 3", async () => { +// await I_PolyToken.getTokens(new BN(web3.utils.toWei("1600")), account_temp); +// await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("1600")), { from: account_temp }); +// let tx = await I_STRProxied.registerTicker(account_temp, "TOK3", "0x0", { from: account_temp }); +// assert.equal(tx.logs[0].args._owner, account_temp, `Owner should be the ${account_temp}`); +// assert.equal(tx.logs[0].args._ticker, "TOK3", `Symbol should be TOK3`); +// console.log((await I_Getter.getTickersByOwner.call(account_temp)).map(x => web3.utils.toUtf8(x))); +// }); + +// it("Should successfully remove the ticker 2", async () => { +// let tx = await I_STRProxied.removeTicker("TOK2", { from: account_polymath }); +// assert.equal(tx.logs[0].args._ticker, "TOK2", "Ticker doesn't get deleted successfully"); +// console.log((await I_Getter.getTickersByOwner.call(account_temp)).map(x => web3.utils.toUtf8(x))); +// }); + +// it("Should modify ticker 1", async () => { +// currentTime = new BN(await latestTime()); +// let tx = await I_STRProxied.modifyTicker( +// account_temp, +// "TOK1", +// "TOKEN 1", +// currentTime, +// currentTime.add(new BN(duration.minutes(10))), +// false, +// { from: account_polymath } +// ); +// assert.equal(tx.logs[0].args._owner, account_temp, `Should be equal to the ${account_temp}`); +// assert.equal(tx.logs[0].args._ticker, "TOK1", "Should be equal to TOK1"); +// assert.equal(tx.logs[0].args._name, "TOKEN 1", "Should be equal to TOKEN 1"); +// console.log((await I_Getter.getTickersByOwner.call(account_temp)).map(x => web3.utils.toUtf8(x))); +// }); + +// it("Should modify ticker 3", async () => { +// let tx = await I_STRProxied.modifyTicker( +// account_temp, +// "TOK3", +// "TOKEN 3", +// currentTime, +// currentTime.add(new BN(duration.minutes(10))), +// false, +// { from: account_polymath } +// ); +// assert.equal(tx.logs[0].args._owner, account_temp, `Should be equal to the ${account_temp}`); +// assert.equal(tx.logs[0].args._ticker, "TOK3", "Should be equal to TOK3"); +// assert.equal(tx.logs[0].args._name, "TOKEN 3", "Should be equal to TOKEN 3"); +// console.log((await I_Getter.getTickersByOwner.call(account_temp)).map(x => web3.utils.toUtf8(x))); +// }); +// }); +// describe("Test cases for IRegistry functionality", async () => { +// describe("Test cases for reclaiming funds", async () => { +// it("Should successfully reclaim POLY tokens -- fail because token address will be 0x", async () => { +// I_PolyToken.transfer(I_STRProxied.address, new BN(web3.utils.toWei("1")), { from: token_owner }); +// await catchRevert(I_STRProxied.reclaimERC20(address_zero, { from: account_polymath })); +// }); + +// it("Should successfully reclaim POLY tokens -- not authorised", async () => { +// await catchRevert(I_STRProxied.reclaimERC20(I_PolyToken.address, { from: account_temp })); +// }); + +// it("Should successfully reclaim POLY tokens", async () => { +// let bal1 = await I_PolyToken.balanceOf.call(account_polymath); +// await I_STRProxied.reclaimERC20(I_PolyToken.address, { from: account_polymath }); +// let bal2 = await I_PolyToken.balanceOf.call(account_polymath); +// assert.isAtLeast( +// bal2.div(new BN(10).pow(new BN(18))).toNumber(), +// bal2.div(new BN(10).pow(new BN(18))).toNumber() +// ); +// }); +// }); + +// describe("Test cases for pausing the contract", async () => { +// it("Should fail to pause if msg.sender is not owner", async () => { +// await catchRevert(I_STRProxied.pause({ from: account_temp }), "tx revert -> msg.sender should be account_polymath"); +// }); + +// it("Should successfully pause the contract", async () => { +// await I_STRProxied.pause({ from: account_polymath }); +// let status = await I_STRProxied.getBoolValue.call(web3.utils.soliditySha3("paused")); +// assert.isOk(status); +// }); + +// it("Should fail to unpause if msg.sender is not owner", async () => { +// await catchRevert(I_STRProxied.unpause({ from: account_temp }), "tx revert -> msg.sender should be account_polymath"); +// }); + +// it("Should successfully unpause the contract", async () => { +// await I_STRProxied.unpause({ from: account_polymath }); +// let status = await I_STRProxied.getBoolValue.call(web3.utils.soliditySha3("paused")); +// assert.isNotOk(status); +// }); +// }); + +// describe("Test cases for the setProtocolVersion", async () => { +// it("Should successfully change the protocolVersion -- failed because of bad owner", async () => { +// await catchRevert(I_STRProxied.setProtocolVersion(accounts[8], 5, 6, 7, { from: account_temp })); +// }); + +// it("Should successfully change the protocolVersion -- failed because factory address is 0x", async () => { +// await catchRevert( +// I_STRProxied.setProtocolVersion(address_zero, 5, 6, 7, { from: account_polymath }) +// ); +// }); + +// it("Should successfully change the protocolVersion -- not a valid vesrion", async () => { +// await catchRevert(I_STRProxied.setProtocolVersion(accounts[8], new BN(0), new BN(0), new BN(0), { from: account_polymath })); +// }); + +// it("Should successfully change the protocolVersion -- fail in second attempt because of invalid version", async () => { +// let snap_Id = await takeSnapshot(); +// await I_STRProxied.setProtocolVersion(accounts[8], 2, 3, 1, { from: account_polymath }); +// await catchRevert(I_STRProxied.setProtocolVersion(accounts[8], 1, 3, 1, { from: account_polymath })); +// await revertToSnapshot(snap_Id); +// }); +// }); + +// describe("Test cases for the transferOwnership", async () => { +// it("Should fail to transfer the ownership -- not authorised", async () => { +// await catchRevert(I_STRProxied.transferOwnership(account_temp, { from: account_issuer })); +// }); + +// it("Should fail to transfer the ownership -- 0x address is not allowed", async () => { +// await catchRevert(I_STRProxied.transferOwnership(address_zero, { from: account_polymath })); +// }); + +// it("Should successfully transfer the ownership of the STR", async () => { +// let tx = await I_STRProxied.transferOwnership(account_temp, { from: account_polymath }); +// assert.equal(tx.logs[0].args.previousOwner, account_polymath); +// assert.equal(tx.logs[0].args.newOwner, account_temp); +// }); +// }); +// }); +// }); diff --git a/test/o_security_token.js b/test/o_security_token.js index 24f29d4e6..65296a172 100644 --- a/test/o_security_token.js +++ b/test/o_security_token.js @@ -186,7 +186,7 @@ contract("SecurityToken", async (accounts) => { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); - let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: token_owner }); // Verify the successful generation of the security token assert.equal(tx.logs[2].args._ticker, symbol, "SecurityToken doesn't get deployed"); diff --git a/test/p_usd_tiered_sto.js b/test/p_usd_tiered_sto.js index 0aea11023..eef088cf3 100644 --- a/test/p_usd_tiered_sto.js +++ b/test/p_usd_tiered_sto.js @@ -286,7 +286,7 @@ contract("USDTieredSTO", async (accounts) => { await I_PolyToken.getTokens(REGFEE, ISSUER); await I_PolyToken.approve(I_STRProxied.address, REGFEE, { from: ISSUER }); - let tx = await I_STRProxied.generateSecurityToken(NAME, SYMBOL, TOKENDETAILS, true, { from: ISSUER }); + let tx = await I_STRProxied.generateSecurityToken(NAME, SYMBOL, TOKENDETAILS, true, 0, { from: ISSUER }); assert.equal(tx.logs[2].args._ticker, SYMBOL, "SecurityToken doesn't get deployed"); I_SecurityToken = await SecurityToken.at(tx.logs[2].args._securityTokenAddress); diff --git a/test/q_usd_tiered_sto_sim.js b/test/q_usd_tiered_sto_sim.js index 1bed3ccb7..92540fccc 100644 --- a/test/q_usd_tiered_sto_sim.js +++ b/test/q_usd_tiered_sto_sim.js @@ -261,7 +261,7 @@ contract("USDTieredSTO Sim", async (accounts) => { await I_PolyToken.getTokens(REGFEE, ISSUER); await I_PolyToken.approve(I_STRProxied.address, REGFEE, { from: ISSUER }); - let tx = await I_STRProxied.generateSecurityToken(NAME, SYMBOL, TOKENDETAILS, true, { from: ISSUER }); + let tx = await I_STRProxied.generateSecurityToken(NAME, SYMBOL, TOKENDETAILS, true, 0, { from: ISSUER }); assert.equal(tx.logs[2].args._ticker, SYMBOL, "SecurityToken doesn't get deployed"); I_SecurityToken = await SecurityToken.at(tx.logs[2].args._securityTokenAddress); diff --git a/test/r_concurrent_STO.js b/test/r_concurrent_STO.js index c8bf6c781..967d474ed 100644 --- a/test/r_concurrent_STO.js +++ b/test/r_concurrent_STO.js @@ -148,7 +148,7 @@ contract("Concurrent STO", async (accounts) => { await I_PolyToken.getTokens(initRegFee, account_issuer); await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: account_issuer }); - let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: account_issuer }); + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: account_issuer }); assert.equal(tx.logs[2].args._ticker, symbol, "SecurityToken doesn't get deployed"); I_SecurityToken = await SecurityToken.at(tx.logs[2].args._securityTokenAddress); diff --git a/test/t_security_token_registry_proxy.js b/test/t_security_token_registry_proxy.js index bae86e140..00c32e1b3 100644 --- a/test/t_security_token_registry_proxy.js +++ b/test/t_security_token_registry_proxy.js @@ -162,7 +162,7 @@ contract("SecurityTokenRegistryProxy", async (accounts) => { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); - let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: token_owner }); // Verify the successful generation of the security token assert.equal(tx.logs[2].args._ticker, symbol, "SecurityToken doesn't get deployed"); diff --git a/test/v_tracked_redemptions.js b/test/v_tracked_redemptions.js index da8a29531..8f645ca9a 100644 --- a/test/v_tracked_redemptions.js +++ b/test/v_tracked_redemptions.js @@ -140,7 +140,7 @@ contract("TrackedRedemption", async (accounts) => { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); - let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: token_owner }); // Verify the successful generation of the security token assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); diff --git a/test/w_lockup_transfer_manager.js b/test/w_lockup_transfer_manager.js index 5cde44801..92a67d2bc 100644 --- a/test/w_lockup_transfer_manager.js +++ b/test/w_lockup_transfer_manager.js @@ -140,7 +140,7 @@ contract('LockUpTransferManager', accounts => { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); let _blockNo = latestBlock(); - let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: token_owner }); // Verify the successful generation of the security token assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); @@ -172,7 +172,7 @@ contract('LockUpTransferManager', accounts => { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); let _blockNo = latestBlock(); - let tx = await I_STRProxied.generateSecurityToken(name2, symbol2, tokenDetails, true, { from: token_owner }); + let tx = await I_STRProxied.generateSecurityToken(name2, symbol2, tokenDetails, true, 0, { from: token_owner }); // Verify the successful generation of the security token assert.equal(tx.logs[2].args._ticker, symbol2.toUpperCase(), "SecurityToken doesn't get deployed"); diff --git a/test/x_scheduled_checkpoints.js b/test/x_scheduled_checkpoints.js index 3f6f54181..4b8944e9b 100644 --- a/test/x_scheduled_checkpoints.js +++ b/test/x_scheduled_checkpoints.js @@ -134,7 +134,7 @@ contract("ScheduledCheckpoint", async (accounts) => { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); - let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: token_owner }); // Verify the successful generation of the security token assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); diff --git a/test/y_volume_restriction_tm.js b/test/y_volume_restriction_tm.js index e915aaa16..578fbb24c 100644 --- a/test/y_volume_restriction_tm.js +++ b/test/y_volume_restriction_tm.js @@ -194,7 +194,7 @@ contract('VolumeRestrictionTransferManager', accounts => { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); - let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, true, { from: token_owner }); + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, true, 0, { from: token_owner }); // Verify the successful generation of the security token assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); diff --git a/test/z_blacklist_transfer_manager.js b/test/z_blacklist_transfer_manager.js index c07e73a9e..1c1939ccd 100644 --- a/test/z_blacklist_transfer_manager.js +++ b/test/z_blacklist_transfer_manager.js @@ -151,7 +151,7 @@ contract('BlacklistTransferManager', accounts => { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner}); let _blockNo = latestBlock(); - let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: token_owner }); // Verify the successful generation of the security token assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); diff --git a/test/z_fuzz_test_adding_removing_modules_ST.js b/test/z_fuzz_test_adding_removing_modules_ST.js index e527aed32..37b0a9ce0 100644 --- a/test/z_fuzz_test_adding_removing_modules_ST.js +++ b/test/z_fuzz_test_adding_removing_modules_ST.js @@ -192,7 +192,7 @@ contract('GeneralPermissionManager', accounts => { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); let _blockNo = latestBlock(); - let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: token_owner }); // Verify the successful generation of the security token assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); diff --git a/test/z_fuzzer_volumn_restriction_transfer_manager.js b/test/z_fuzzer_volumn_restriction_transfer_manager.js index 007a09849..faf1dfd7a 100644 --- a/test/z_fuzzer_volumn_restriction_transfer_manager.js +++ b/test/z_fuzzer_volumn_restriction_transfer_manager.js @@ -180,7 +180,7 @@ contract('VolumeRestrictionTransferManager', accounts => { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); - let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, true, { from: token_owner }); + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, true, 0, { from: token_owner }); console.log(tx.logs); // Verify the successful generation of the security token diff --git a/test/z_general_permission_manager_fuzzer.js b/test/z_general_permission_manager_fuzzer.js index b74fd254b..73da94b99 100644 --- a/test/z_general_permission_manager_fuzzer.js +++ b/test/z_general_permission_manager_fuzzer.js @@ -187,7 +187,7 @@ contract("GeneralPermissionManager Fuzz", async (accounts) => { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); - let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: token_owner }); // Verify the successful generation of the security token assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); diff --git a/test/z_vesting_escrow_wallet.js b/test/z_vesting_escrow_wallet.js index 02ce65b8f..7d90e218a 100644 --- a/test/z_vesting_escrow_wallet.js +++ b/test/z_vesting_escrow_wallet.js @@ -144,7 +144,7 @@ contract('VestingEscrowWallet', accounts => { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); - let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: token_owner }); // Verify the successful generation of the security token assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); diff --git a/test/za_datastore.js b/test/za_datastore.js index 526583c21..467627ba0 100644 --- a/test/za_datastore.js +++ b/test/za_datastore.js @@ -97,7 +97,7 @@ contract("Data store", async (accounts) => { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); - let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: token_owner }); // Verify the successful generation of the security token assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); diff --git a/test/zb_signed_transfer_manager.js b/test/zb_signed_transfer_manager.js index f7dec103a..4617e53bd 100644 --- a/test/zb_signed_transfer_manager.js +++ b/test/zb_signed_transfer_manager.js @@ -137,7 +137,7 @@ contract("SignedTransferManager", accounts => { it("Should generate the new security token with the same symbol as registered above", async () => { await I_PolyToken.approve(I_STRProxied.address, initRegFee, { from: token_owner }); - let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: token_owner }); // Verify the successful generation of the security token assert.equal(tx.logs[2].args._ticker, symbol.toUpperCase(), "SecurityToken doesn't get deployed"); From ee723720d10e729d6609826ef4a5c7ebc7ebf875 Mon Sep 17 00:00:00 2001 From: satyam Date: Fri, 22 Feb 2019 15:04:19 +0530 Subject: [PATCH 3/6] add some test and mock contract --- contracts/mocks/STFactoryMock.sol | 52 + contracts/mocks/SecurityTokenMock.sol | 43 + test/n_security_token_registry.js | 2571 +++++++++++++------------ 3 files changed, 1400 insertions(+), 1266 deletions(-) create mode 100644 contracts/mocks/STFactoryMock.sol create mode 100644 contracts/mocks/SecurityTokenMock.sol diff --git a/contracts/mocks/STFactoryMock.sol b/contracts/mocks/STFactoryMock.sol new file mode 100644 index 000000000..046811a5b --- /dev/null +++ b/contracts/mocks/STFactoryMock.sol @@ -0,0 +1,52 @@ +pragma solidity ^0.5.0; + +import "./SecurityTokenMock.sol"; +import "../interfaces/ISTFactory.sol"; +import "../datastore/DataStoreFactory.sol"; + +/** + * @title Proxy for deploying SecurityToken instances + */ +contract STFactoryMock is ISTFactory { + address public transferManagerFactory; + address public stDelegate; + DataStoreFactory public dataStoreFactory; + + constructor(address _transferManagerFactory, address _dataStoreFactory, address _stDelegate) public { + transferManagerFactory = _transferManagerFactory; + dataStoreFactory = DataStoreFactory(_dataStoreFactory); + stDelegate = _stDelegate; + } + + /** + * @notice deploys the token and adds default modules like the GeneralTransferManager. + * Future versions of the proxy can attach different modules or pass different parameters. + */ + function deployToken( + string calldata _name, + string calldata _symbol, + uint8 _decimals, + string calldata _tokenDetails, + address _issuer, + bool _divisible, + address _polymathRegistry + ) + external + returns(address) + { + SecurityTokenMock newSecurityToken = new SecurityTokenMock( + _name, + _symbol, + _decimals, + _divisible ? 1 : uint256(10) ** _decimals, + _tokenDetails, + _polymathRegistry, + stDelegate + ); + //NB When dataStore is generated, the security token address is automatically set via the constructor in DataStoreProxy. + newSecurityToken.changeDataStore(dataStoreFactory.generateDataStore(address(newSecurityToken))); + newSecurityToken.addModule(transferManagerFactory, "", 0, 0); + newSecurityToken.transferOwnership(_issuer); + return address(newSecurityToken); + } +} diff --git a/contracts/mocks/SecurityTokenMock.sol b/contracts/mocks/SecurityTokenMock.sol new file mode 100644 index 000000000..3dd60d645 --- /dev/null +++ b/contracts/mocks/SecurityTokenMock.sol @@ -0,0 +1,43 @@ +pragma solidity ^0.5.0; + +import "../tokens/SecurityToken.sol"; + +/** + * @title Security Token contract + * @notice SecurityToken is an ERC1400 token with added capabilities: + * @notice - Implements the ERC1400 Interface + * @notice - Transfers are restricted + * @notice - Modules can be attached to it to control its behaviour + * @notice - ST should not be deployed directly, but rather the SecurityTokenRegistry should be used + * @notice - ST does not inherit from ISecurityToken due to: + * @notice - https://github.com/ethereum/solidity/issues/4847 + */ +contract SecurityTokenMock is SecurityToken { + + /** + * @notice constructor + * @param _name Name of the SecurityToken + * @param _symbol Symbol of the Token + * @param _decimals Decimals for the securityToken + * @param _granularity granular level of the token + * @param _tokenDetails Details of the token that are stored off-chain + * @param _polymathRegistry Contract address of the polymath registry + * @param _delegate Contract address of the delegate + */ + constructor( + string memory _name, + string memory _symbol, + uint8 _decimals, + uint256 _granularity, + string memory _tokenDetails, + address _polymathRegistry, + address _delegate + ) + public + SecurityToken(_name, _symbol, _decimals, _granularity, _tokenDetails, _polymathRegistry,_delegate) + { + securityTokenVersion = SemanticVersion(2, 2, 0); + } + + +} diff --git a/test/n_security_token_registry.js b/test/n_security_token_registry.js index 9cb59d90b..412547dce 100644 --- a/test/n_security_token_registry.js +++ b/test/n_security_token_registry.js @@ -1,1266 +1,1305 @@ -// import latestTime from "./helpers/latestTime"; -// import { duration, promisifyLogWatch, latestBlock } from "./helpers/utils"; -// import { takeSnapshot, increaseTime, revertToSnapshot } from "./helpers/time"; -// import { encodeProxyCall, encodeModuleCall } from "./helpers/encodeCall"; -// import { catchRevert } from "./helpers/exceptions"; -// import { setUpPolymathNetwork, deployDummySTOAndVerifyed } from "./helpers/createInstances"; - -// const DummySTO = artifacts.require("./DummySTO.sol"); -// const SecurityToken = artifacts.require("./SecurityToken.sol"); -// const SecurityTokenRegistryProxy = artifacts.require("./SecurityTokenRegistryProxy.sol"); -// const SecurityTokenRegistry = artifacts.require("./SecurityTokenRegistry.sol"); -// const SecurityTokenRegistryMock = artifacts.require("./SecurityTokenRegistryMock.sol"); -// const STFactory = artifacts.require("./STFactory.sol"); -// const STRGetter = artifacts.require('./STRGetter.sol'); -// const STGetter = artifacts.require("./STGetter.sol"); -// const DataStoreLogic = artifacts.require('./DataStore.sol'); -// const DataStoreFactory = artifacts.require('./DataStoreFactory.sol'); - - -// const Web3 = require("web3"); -// let BN = Web3.utils.BN; -// const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); // Hardcoded development port - -// contract("SecurityTokenRegistry", async (accounts) => { -// // Accounts Variable declaration -// let account_polymath; -// let account_investor1; -// let account_issuer; -// let token_owner; -// let account_investor2; -// let account_fundsReceiver; -// let account_delegate; -// let account_temp; -// let dummy_token; - -// let balanceOfReceiver; - -// let ID_snap; -// const message = "Transaction Should Fail!!"; - -// // Contract Instance Declaration -// let I_GeneralTransferManagerFactory; -// let I_GeneralPermissionManager; -// let I_GeneralTransferManager; -// let I_ModuleRegistryProxy; -// let I_ModuleRegistry; -// let I_FeatureRegistry; -// let I_SecurityTokenRegistry; -// let I_SecurityTokenRegistryV2; -// let I_DummySTOFactory; -// let I_STVersion; -// let I_SecurityToken; -// let I_DummySTO; -// let I_PolyToken; -// let I_STFactory; -// let I_STFactory002; -// let I_SecurityToken002; -// let I_STFactory003; -// let I_PolymathRegistry; -// let I_SecurityTokenRegistryProxy; -// let I_STRProxied; -// let I_MRProxied; -// let I_STRGetter; -// let I_Getter; -// let I_STGetter; -// let stGetter; -// let I_USDOracle; -// let I_POLYOracle; -// let I_StablePOLYOracle; - -// // SecurityToken Details (Launched ST on the behalf of the issuer) -// const name = "Demo Token"; -// const symbol = "DET"; -// const tokenDetails = "This is equity type of issuance"; -// const decimals = 18; - -// //Security Token Detials (Version 2) -// const name2 = "Demo2 Token"; -// const symbol2 = "DET2"; -// const tokenDetails2 = "This is equity type of issuance"; -// const address_zero = "0x0000000000000000000000000000000000000000"; -// const one_address = "0x0000000000000000000000000000000000000001"; - -// // Module key -// const permissionManagerKey = 1; -// const transferManagerKey = 2; -// const stoKey = 3; -// const budget = 0; - -// // Initial fee for ticker registry and security token registry -// const initRegFee = new BN(web3.utils.toWei("250")); -// const initRegFeePOLY = new BN(web3.utils.toWei("1000")); - -// const STRProxyParameters = ["address", "address", "uint256", "uint256", "address", "address"]; -// const STOParameters = ["uint256", "uint256", "uint256", "string"]; - -// // Capped STO details -// const cap = new BN(web3.utils.toWei("10000")); -// const someString = "Hello string"; - -// let currentTime; - -// before(async () => { -// currentTime = new BN(await latestTime()); -// account_polymath = accounts[0]; -// account_issuer = accounts[1]; -// account_investor1 = accounts[9]; -// account_investor2 = accounts[6]; -// account_fundsReceiver = accounts[4]; -// account_delegate = accounts[5]; -// account_temp = accounts[8]; -// token_owner = account_issuer; -// dummy_token = accounts[3]; - -// let instances = await setUpPolymathNetwork(account_polymath, token_owner); - -// [ -// I_PolymathRegistry, -// I_PolyToken, -// I_FeatureRegistry, -// I_ModuleRegistry, -// I_ModuleRegistryProxy, -// I_MRProxied, -// I_GeneralTransferManagerFactory, -// I_STFactory, -// I_SecurityTokenRegistry, -// I_SecurityTokenRegistryProxy, -// I_STRProxied, -// I_STRGetter, -// I_STGetter, -// I_USDOracle, -// I_POLYOracle, -// I_StablePOLYOracle -// ] = instances; - -// // STEP 8: Deploy the CappedSTOFactory - -// [I_DummySTOFactory] = await deployDummySTOAndVerifyed(account_polymath, I_MRProxied, 0); -// // Step 9: Deploy the SecurityTokenRegistry -// console.log(I_SecurityTokenRegistry.address); -// I_SecurityTokenRegistry = await SecurityTokenRegistry.new({ from: account_polymath }); -// console.log(I_SecurityTokenRegistry.address); - -// assert.notEqual( -// I_SecurityTokenRegistry.address.valueOf(), -// address_zero, -// "SecurityTokenRegistry contract was not deployed" -// ); - -// // Step 9 (a): Deploy the proxy -// I_SecurityTokenRegistryProxy = await SecurityTokenRegistryProxy.new({ from: account_polymath }); -// // Step 10 : Deploy the getter contract -// I_STRGetter = await STRGetter.new({ from: account_polymath }); -// //Step 11: update the registries addresses from the PolymathRegistry contract -// await I_PolymathRegistry.changeAddress("SecurityTokenRegistry", I_SecurityTokenRegistryProxy.address, { from: account_polymath }); -// await I_MRProxied.updateFromRegistry({ from: account_polymath }); - -// console.log(` -// --------------------- Polymath Network Smart Contracts: --------------------- -// PolymathRegistry: ${I_PolymathRegistry.address} -// SecurityTokenRegistryProxy: ${I_SecurityTokenRegistryProxy.address} -// SecurityTokenRegistry: ${I_SecurityTokenRegistry.address} -// ModuleRegistry: ${I_ModuleRegistry.address} -// ModuleRegistryProxy: ${I_ModuleRegistryProxy.address} -// FeatureRegistry: ${I_FeatureRegistry.address} - -// STFactory: ${I_STFactory.address} -// GeneralTransferManagerFactory: ${I_GeneralTransferManagerFactory.address} - -// DummySTOFactory: ${I_DummySTOFactory.address} -// ----------------------------------------------------------------------------- -// `); -// }); - -// describe("Test the initialize the function", async () => { -// it("Should successfully update the implementation address -- fail because polymathRegistry address is 0x", async () => { -// let bytesProxy = encodeProxyCall(STRProxyParameters, [ -// address_zero, -// I_STFactory.address, -// initRegFee, -// initRegFee, -// account_polymath, -// I_STRGetter.address -// ]); -// await catchRevert( -// I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { -// from: account_polymath -// }), -// "tx-> revert because polymathRegistry address is 0x" -// ); -// }); - -// it("Should successfully update the implementation address -- fail because STFactory address is 0x", async () => { -// let bytesProxy = encodeProxyCall(STRProxyParameters, [ -// I_PolymathRegistry.address, -// address_zero, -// initRegFee, -// initRegFee, -// account_polymath, -// I_STRGetter.address -// ]); -// await catchRevert( -// I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { -// from: account_polymath -// }), -// "tx-> revert because STFactory address is 0x" -// ); -// }); - -// it("Should successfully update the implementation address -- fail because STLaunch fee is 0", async () => { -// let bytesProxy = encodeProxyCall(STRProxyParameters, [ -// I_PolymathRegistry.address, -// I_STFactory.address, -// new BN(0), -// initRegFee, -// account_polymath, -// I_STRGetter.address -// ]); -// await catchRevert( -// I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { -// from: account_polymath -// }), -// "tx-> revert because STLaunch fee is 0" -// ); -// }); - -// it("Should successfully update the implementation address -- fail because tickerRegFee fee is 0", async () => { -// let bytesProxy = encodeProxyCall(STRProxyParameters, [ -// I_PolymathRegistry.address, -// I_STFactory.address, -// initRegFee, -// new BN(0), -// account_polymath, -// I_STRGetter.address -// ]); -// await catchRevert( -// I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { -// from: account_polymath -// }), -// "tx-> revert because tickerRegFee is 0" -// ); -// }); - -// it("Should successfully update the implementation address -- fail because owner address is 0x", async () => { -// let bytesProxy = encodeProxyCall(STRProxyParameters, [ -// I_PolymathRegistry.address, -// I_STFactory.address, -// initRegFee, -// initRegFee, -// address_zero, -// I_STRGetter.address -// ]); -// await catchRevert( -// I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { -// from: account_polymath -// }), -// "tx-> revert because owner address is 0x" -// ); -// }); - -// it("Should successfully update the implementation address -- fail because all params get 0", async () => { -// let bytesProxy = encodeProxyCall(STRProxyParameters, [address_zero, address_zero, new BN(0), new BN(0), address_zero, address_zero]); -// await catchRevert( -// I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { -// from: account_polymath -// }), -// "tx-> revert because owner address is 0x" -// ); -// }); - -// it("Should successfully update the implementation address", async () => { -// let bytesProxy = encodeProxyCall(STRProxyParameters, [ -// I_PolymathRegistry.address, -// I_STFactory.address, -// initRegFee, -// initRegFee, -// account_polymath, -// I_STRGetter.address -// ]); -// await I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { -// from: account_polymath -// }); -// I_Getter = await STRGetter.at(I_SecurityTokenRegistryProxy.address); -// I_STRProxied = await SecurityTokenRegistry.at(I_SecurityTokenRegistryProxy.address); -// }); -// }); - -// describe(" Test cases of the registerTicker", async () => { -// it("verify the intial parameters", async () => { -// let intialised = await I_STRProxied.getBoolValue.call(web3.utils.soliditySha3("initialised")); -// assert.isTrue(intialised, "Should be true"); - -// let expiry = await I_STRProxied.getUintValue.call(web3.utils.soliditySha3("expiryLimit")); -// assert.equal(expiry.toNumber(), 5184000, "Expiry limit should be equal to 60 days"); - -// let polytoken = await I_STRProxied.getAddressValue.call(web3.utils.soliditySha3("polyToken")); -// assert.equal(polytoken, I_PolyToken.address, "Should be the polytoken address"); - -// let stlaunchFee = await I_STRProxied.getUintValue.call(web3.utils.soliditySha3("stLaunchFee")); -// assert.equal(stlaunchFee.toString(), initRegFee.toString(), "Should be provided reg fee"); - -// let tickerRegFee = await I_STRProxied.getUintValue.call(web3.utils.soliditySha3("tickerRegFee")); -// assert.equal(tickerRegFee.toString(), tickerRegFee.toString(), "Should be provided reg fee"); - -// let polymathRegistry = await I_STRProxied.getAddressValue.call(web3.utils.soliditySha3("polymathRegistry")); -// assert.equal(polymathRegistry, I_PolymathRegistry.address, "Should be the address of the polymath registry"); - -// let getterContract = await I_STRProxied.getAddressValue.call(web3.utils.soliditySha3("STRGetter")); -// assert.equal(getterContract, I_STRGetter.address, "Should be the address of the getter contract"); - -// let owner = await I_STRProxied.getAddressValue.call(web3.utils.soliditySha3("owner")); -// assert.equal(owner, account_polymath, "Should be the address of the registry owner"); -// }); - -// it("Can't call the intialize function again", async () => { -// await catchRevert( -// I_STRProxied.initialize( -// I_PolymathRegistry.address, -// I_STFactory.address, -// initRegFee, -// initRegFee, -// account_polymath, -// I_STRGetter.address -// ), -// "tx revert -> Can't call the intialize function again" -// ); -// }); - -// it("Should fail to register ticker if tickerRegFee not approved", async () => { -// await catchRevert( -// I_STRProxied.registerTicker(account_temp, symbol, name, { from: account_temp }), -// "tx revert -> POLY allowance not provided for registration fee" -// ); -// }); - -// it("Should fail to register ticker if owner is 0x", async () => { -// await I_PolyToken.getTokens(initRegFeePOLY, account_temp); -// await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: account_temp }); - -// await catchRevert( -// I_STRProxied.registerTicker(address_zero, symbol, name, { from: account_temp }), -// "tx revert -> owner should not be 0x" -// ); -// }); - -// it("Should fail to register ticker due to the symbol length is 0", async () => { -// await catchRevert(I_STRProxied.registerTicker(account_temp, "", name, { from: account_temp }), "tx revert -> Symbol Length is 0"); -// }); - -// it("Should fail to register ticker due to the symbol length is greater than 10", async () => { -// await catchRevert( -// I_STRProxied.registerTicker(account_temp, "POLYMATHNET", name, { from: account_temp }), -// "tx revert -> Symbol Length is greater than 10" -// ); -// }); - -// it("Should register the ticker before the generation of the security token", async () => { -// let tx = await I_STRProxied.registerTicker(account_temp, symbol, name, { from: account_temp }); -// assert.equal(tx.logs[0].args._owner, account_temp, `Owner should be the ${account_temp}`); -// assert.equal(tx.logs[0].args._ticker, symbol, `Symbol should be ${symbol}`); -// let data = await I_Getter.getTickerDetails.call(symbol); -// assert.equal(data[0], account_temp); -// assert.equal(data[3], name); -// // trying to access the function data directly from the STRGetter then it should give all values zero -// data = await I_STRGetter.getTickerDetails.call(symbol); -// assert.equal(data[0], address_zero); -// assert.equal(data[3], ""); -// }); - -// it("Should change ticker price based on oracle", async () => { -// let snap_Id = await takeSnapshot(); -// let origPriceUSD = new BN(web3.utils.toWei("250")); -// let origPricePOLY = new BN(web3.utils.toWei("1000")); -// let currentRate = await I_POLYOracle.getPrice.call(); -// console.log("Current Rate: " + currentRate); -// let feesTicker = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); -// let feesToken = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); -// assert.equal(feesTicker[0].toString(), origPriceUSD.toString()); -// assert.equal(feesTicker[1].toString(), origPricePOLY.toString()); -// assert.equal(feesToken[0].toString(), origPriceUSD.toString()); -// assert.equal(feesToken[1].toString(), origPricePOLY.toString()); -// await I_POLYOracle.changePrice(new BN(27).mul(new BN(10).pow(new BN(16)))); -// await I_STRProxied.getFees("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); -// feesTicker = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); -// feesToken = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); -// // No change as difference is less than 10% -// assert.equal(feesTicker[0].toString(), origPriceUSD.toString()); -// assert.equal(feesTicker[1].toString(), origPricePOLY.toString()); -// assert.equal(feesToken[0].toString(), origPriceUSD.toString()); -// assert.equal(feesToken[1].toString(), origPricePOLY.toString()); -// await I_POLYOracle.changePrice(new BN(20).mul(new BN(10).pow(new BN(16)))); -// await I_STRProxied.getFees("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); -// feesTicker = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); -// feesToken = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); -// let newPricePOLY = new BN(web3.utils.toWei("1250")); -// assert.equal(feesTicker[0].toString(), origPriceUSD.toString()); -// assert.equal(feesTicker[1].toString(), newPricePOLY.toString()); -// assert.equal(feesToken[0].toString(), origPriceUSD.toString()); -// assert.equal(feesToken[1].toString(), newPricePOLY.toString()); -// await I_POLYOracle.changePrice(new BN(21).mul(new BN(10).pow(new BN(16)))); -// await I_STRProxied.getFees("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); -// feesTicker = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); -// feesToken = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); -// // No change as difference is less than 10% -// assert.equal(feesTicker[0].toString(), origPriceUSD.toString()); -// assert.equal(feesTicker[1].toString(), newPricePOLY.toString()); -// assert.equal(feesToken[0].toString(), origPriceUSD.toString()); -// assert.equal(feesToken[1].toString(), newPricePOLY.toString()); -// await I_StablePOLYOracle.changeEvictPercentage(new BN(10).pow(new BN(16))); -// await I_STRProxied.getFees("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); -// feesTicker = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); -// feesToken = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); -// // Change as eviction percentage updated -// // newPricePOLY = new BN(web3.utils.toWei("1250")); -// //1190.476190476190476190 = 250/0.21 -// assert.equal(feesTicker[0].toString(), origPriceUSD.toString()); -// assert.equal(feesTicker[1].toString(), "1190476190476190476190"); -// assert.equal(feesToken[0].toString(), origPriceUSD.toString()); -// assert.equal(feesToken[1].toString(), "1190476190476190476190"); -// await revertToSnapshot(snap_Id); -// }); - -// it("Should register the ticker when the tickerRegFee is 0", async () => { -// let snap_Id = await takeSnapshot(); -// await I_STRProxied.changeTickerRegistrationFee(0, { from: account_polymath }); -// let tx = await I_STRProxied.registerTicker(account_temp, "ZERO", name, { from: account_temp }); -// assert.equal(tx.logs[0].args._owner, account_temp, `Owner should be the ${account_temp}`); -// assert.equal(tx.logs[0].args._ticker, "ZERO", `Symbol should be ZERO`); -// await revertToSnapshot(snap_Id); -// }); - -// it("Should fail to register same symbol again", async () => { -// // Give POLY to token issuer -// await I_PolyToken.getTokens(initRegFeePOLY, token_owner); -// await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); -// // Call registration function -// await catchRevert( -// I_STRProxied.registerTicker(token_owner, symbol, name, { from: token_owner }), -// "tx revert -> Symbol is already alloted to someone else" -// ); -// }); - -// it("Should successfully register pre registerd ticker if expiry is reached", async () => { -// await increaseTime(5184000 + 100); // 60(5184000) days of expiry + 100 sec for buffer -// await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); -// let tx = await I_STRProxied.registerTicker(token_owner, symbol, name, { from: token_owner }); -// assert.equal(tx.logs[0].args._owner, token_owner, `Owner should be the ${token_owner}`); -// assert.equal(tx.logs[0].args._ticker, symbol, `Symbol should be ${symbol}`); -// }); - -// it("Should fail to register ticker if registration is paused", async () => { -// await I_STRProxied.pause({ from: account_polymath }); -// await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); - -// await catchRevert( -// I_STRProxied.registerTicker(token_owner, "AAA", name, { from: token_owner }), -// "tx revert -> Registration is paused" -// ); -// }); - -// it("Should fail to pause if already paused", async () => { -// await catchRevert(I_STRProxied.pause({ from: account_polymath }), "tx revert -> Registration is already paused"); -// }); - -// it("Should successfully register ticker if registration is unpaused", async () => { -// await I_STRProxied.unpause({ from: account_polymath }); -// await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); -// let tx = await I_STRProxied.registerTicker(token_owner, "AAA", name, { from: token_owner }); -// assert.equal(tx.logs[0].args._owner, token_owner, `Owner should be the ${token_owner}`); -// assert.equal(tx.logs[0].args._ticker, "AAA", `Symbol should be AAA`); -// }); - -// it("Should fail to unpause if already unpaused", async () => { -// await catchRevert(I_STRProxied.unpause({ from: account_polymath }), "tx revert -> Registration is already unpaused"); -// }); -// }); - -// describe("Test cases for the expiry limit", async () => { -// it("Should fail to set the expiry limit because msg.sender is not owner", async () => { -// await catchRevert(I_STRProxied.changeExpiryLimit(duration.days(10), { from: account_temp }), "tx revert -> msg.sender is not owner"); -// }); - -// it("Should successfully set the expiry limit", async () => { -// await I_STRProxied.changeExpiryLimit(duration.days(10), { from: account_polymath }); -// assert.equal( -// (await I_STRProxied.getUintValue.call(web3.utils.soliditySha3("expiryLimit"))).toNumber(), -// duration.days(10), -// "Failed to change the expiry limit" -// ); -// }); - -// it("Should fail to set the expiry limit because new expiry limit is lesser than one day", async () => { -// await catchRevert( -// I_STRProxied.changeExpiryLimit(duration.seconds(5000), { from: account_polymath }), -// "tx revert -> New expiry limit is lesser than one day" -// ); -// }); -// }); - -// describe("Test cases for the getTickerDetails", async () => { -// it("Should get the details of the symbol", async () => { -// let tx = await I_Getter.getTickerDetails.call(symbol); -// assert.equal(tx[0], token_owner, "Should equal to the rightful owner of the ticker"); -// assert.equal(tx[3], name, `Name of the token should equal to ${name}`); -// assert.equal(tx[4], false, "Status if the symbol should be undeployed -- false"); -// }); - -// it("Should get the details of unregistered token", async () => { -// let tx = await I_Getter.getTickerDetails.call("TORO"); -// assert.equal(tx[0], address_zero, "Should be 0x as ticker is not exists in the registry"); -// assert.equal(tx[3], "", "Should be an empty string"); -// assert.equal(tx[4], false, "Status if the symbol should be undeployed -- false"); -// }); -// }); - -// describe("Generate SecurityToken", async () => { -// it("Should get the ticker details successfully and prove the data is not storing in to the logic contract", async () => { -// let data = await I_Getter.getTickerDetails(symbol, { from: token_owner }); -// assert.equal(data[0], token_owner, "Token owner should be equal"); -// assert.equal(data[3], name, "Name of the token should match with the registered symbol infor"); -// assert.equal(data[4], false, "Token is not launched yet so it should return False"); -// data = await I_STRGetter.getTickerDetails(symbol, { from: token_owner }); -// console.log("This is the data from the original securityTokenRegistry contract"); -// assert.equal(data[0], address_zero, "Token owner should be 0x"); -// }); - -// it("Should fail to generate new security token if fee not provided", async () => { -// await I_PolyToken.approve(I_STRProxied.address, new BN(0), { from: token_owner }); - -// await catchRevert( -// I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }), -// "tx revert -> POLY allowance not provided for registration fee" -// ); -// }); - -// it("Should fail to generate token if registration is paused", async () => { -// await I_STRProxied.pause({ from: account_polymath }); -// await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); - -// await catchRevert( -// I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }), -// "tx revert -> Registration is paused" -// ); -// }); - -// it("Should fail to generate the securityToken -- Because ticker length is 0", async () => { -// await I_STRProxied.unpause({ from: account_polymath }); - -// await catchRevert( -// I_STRProxied.generateSecurityToken(name, "0x0", tokenDetails, false, { from: token_owner }), -// "tx revert -> Zero ticker length is not allowed" -// ); -// }); - -// it("Should fail to generate the securityToken -- Because name length is 0", async () => { -// await catchRevert( -// I_STRProxied.generateSecurityToken("", symbol, tokenDetails, false, { from: token_owner }), -// "tx revert -> 0 name length is not allowed" -// ); -// }); - -// it("Should fail to generate the securityToken -- Because msg.sender is not the rightful owner of the ticker", async () => { -// await catchRevert( -// I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: account_temp }), -// "tx revert -> Because msg.sender is not the rightful owner of the ticker" -// ); -// }); - -// it("Should generate the new security token with the same symbol as registered above", async () => { - -// let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }); - -// // Verify the successful generation of the security token -// assert.equal(tx.logs[2].args._ticker, symbol, "SecurityToken doesn't get deployed"); - -// I_SecurityToken = await SecurityToken.at(tx.logs[2].args._securityTokenAddress); -// stGetter = await STGetter.at(I_SecurityToken.address); -// const log = (await I_SecurityToken.getPastEvents('ModuleAdded', {filter: {transactionHash: tx.transactionHash}}))[0]; - -// // Verify that GeneralTrasnferManager module get added successfully or not -// assert.equal(log.args._types[0].toNumber(), transferManagerKey, `Should be equal to the ${transferManagerKey}`); -// assert.equal(web3.utils.toAscii(log.args._name).replace(/\u0000/g, ""), "GeneralTransferManager"); -// }); - -// it("Should fail to generate the SecurityToken when token is already deployed with the same symbol", async () => { -// await catchRevert( -// I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, { from: token_owner }), -// "tx revert -> Because ticker is already in use" -// ); -// }); - -// it("Should fail to generate the SecurityToken because ticker gets expired", async () => { -// let snap_Id = await takeSnapshot(); -// await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("2000")), { from: token_owner }); -// let tx = await I_STRProxied.registerTicker(token_owner, "CCC", name, { from: token_owner }); -// await increaseTime(duration.days(65)); -// await catchRevert( -// I_STRProxied.generateSecurityToken(name, "CCC", tokenDetails, false, { from: token_owner }), -// "tx revert -> Because ticker is expired" -// ); -// await revertToSnapshot(snap_Id); -// }); - -// it("Should generate the SecurityToken when launch fee is 0", async () => { -// let snap_Id = await takeSnapshot(); -// await I_STRProxied.changeSecurityLaunchFee(0, { from: account_polymath }); -// await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("2000")), { from: token_owner }); -// let tx = await I_STRProxied.registerTicker(token_owner, "CCC", name, { from: token_owner }); -// await I_STRProxied.generateSecurityToken(name, "CCC", tokenDetails, false, { from: token_owner }), -// await revertToSnapshot(snap_Id); -// }); - -// it("Should get all created security tokens", async() => { -// let snap_Id = await takeSnapshot(); -// await I_PolyToken.getTokens(web3.utils.toWei("2000"), account_temp); -// await I_PolyToken.approve(I_STRProxied.address, web3.utils.toWei("2000"), { from: account_temp }); -// await I_STRProxied.registerTicker(account_temp, "TMP", name, { from: account_temp }); -// let tx = await I_STRProxied.generateSecurityToken(name, "TMP", tokenDetails, false, { from: account_temp }); - -// // Verify the successful generation of the security token -// assert.equal(tx.logs[2].args._ticker, "TMP", "SecurityToken doesn't get deployed"); - -// let securityTokenTmp = await SecurityToken.at(tx.logs[2].args._securityTokenAddress); - -// let tokens = await I_Getter.getTokensByOwner.call(token_owner); -// assert.equal(tokens.length, 1, "tokens array length error"); -// assert.equal(tokens[0], I_SecurityToken.address, "ST address incorrect"); - -// let allTokens = await I_Getter.getTokens.call(); -// assert.equal(allTokens.length, 2); -// assert.equal(allTokens[0], securityTokenTmp.address); -// assert.equal(allTokens[1], I_SecurityToken.address); - -// await revertToSnapshot(snap_Id); -// }); -// }); - -// describe("Generate SecurityToken v2", async () => { -// it("Should deploy the st version 2", async () => { -// // Step 7: Deploy the STFactory contract -// I_STGetter = await STGetter.new(); -// let I_DataStoreLogic = await DataStoreLogic.new({ from: account_polymath }); -// let I_DataStoreFactory = await DataStoreFactory.new(I_DataStoreLogic.address, { from: account_polymath }); - -// I_STFactory002 = await STFactory.new(I_GeneralTransferManagerFactory.address, I_DataStoreFactory.address, I_STGetter.address, { from: account_polymath }); - -// assert.notEqual( -// I_STFactory002.address.valueOf(), -// address_zero, -// "STFactory002 contract was not deployed" -// ); -// await I_STRProxied.setProtocolVersion(I_STFactory002.address, new BN(2), new BN(2), new BN(0), { from: account_polymath }); -// let _protocol = await I_Getter.getProtocolVersion.call(); -// assert.equal(_protocol[0], 2); -// assert.equal(_protocol[1], 2); -// assert.equal(_protocol[2], 0); -// }); - -// it("Should register the ticker before the generation of the security token", async () => { -// await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); -// let tx = await I_STRProxied.registerTicker(token_owner, symbol2, name2, { from: token_owner }); -// assert.equal(tx.logs[0].args._owner, token_owner, `Token owner should be ${token_owner}`); -// assert.equal(tx.logs[0].args._ticker, symbol2, `Symbol should be ${symbol2}`); -// }); - -// it("Should generate the new security token with version 2", async () => { -// await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); - -// let tx = await I_STRProxied.generateSecurityToken(name2, symbol2, tokenDetails, false, { from: token_owner }); - -// // Verify the successful generation of the security token -// assert.equal(tx.logs[2].args._ticker, symbol2, "SecurityToken doesn't get deployed"); - -// I_SecurityToken002 = await SecurityToken.at(tx.logs[2].args._securityTokenAddress); -// const log = (await I_SecurityToken002.getPastEvents('ModuleAdded'))[0]; -// // Verify that GeneralTransferManager module get added successfully or not -// assert.equal(log.args._types[0].toNumber(), transferManagerKey); -// assert.equal(web3.utils.toAscii(log.args._name).replace(/\u0000/g, ""), "GeneralTransferManager"); -// }); -// }); - -// describe("Deploy the new SecurityTokenRegistry", async () => { -// it("Should deploy the new SecurityTokenRegistry contract logic", async () => { -// I_SecurityTokenRegistryV2 = await SecurityTokenRegistryMock.new({ from: account_polymath }); -// assert.notEqual(I_SecurityTokenRegistryV2.address.valueOf(), address_zero, "SecurityTokenRegistry contract was not deployed"); -// }); - -// it("Should fail to upgrade the logic contract of the STRProxy -- bad owner", async () => { -// await I_STRProxied.pause({ from: account_polymath }); - -// await catchRevert( -// I_SecurityTokenRegistryProxy.upgradeTo("1.1.0", I_SecurityTokenRegistryV2.address, { from: account_temp }), -// "tx revert -> bad owner" -// ); -// }); - -// it("Should upgrade the logic contract into the STRProxy", async () => { -// await I_SecurityTokenRegistryProxy.upgradeTo("1.1.0", I_SecurityTokenRegistryV2.address, { from: account_polymath }); -// I_STRProxied = await SecurityTokenRegistry.at(I_SecurityTokenRegistryProxy.address); -// assert.isTrue(await I_STRProxied.getBoolValue.call(web3.utils.soliditySha3("paused")), "Paused value should be false"); -// }); - -// it("Should check the old data persist or not", async () => { -// let data = await I_Getter.getTickerDetails.call(symbol); -// assert.equal(data[0], token_owner, "Should be equal to the token owner address"); -// assert.equal(data[3], name, "Should be equal to the name of the token that is provided earlier"); -// assert.isTrue(data[4], "Token status should be deployed == true"); -// }); - -// it("Should unpause the logic contract", async () => { -// await I_STRProxied.unpause({ from: account_polymath }); -// assert.isFalse(await I_STRProxied.getBoolValue.call(web3.utils.soliditySha3("paused")), "Paused value should be false"); -// }); -// }); - -// describe("Generate custom tokens", async () => { -// it("Should fail if msg.sender is not polymath", async () => { -// await catchRevert( -// I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, { -// from: account_delegate -// }), -// "tx revert -> msg.sender is not polymath account" -// ); -// }); - -// it("Should fail to genrate the custom security token -- ticker length is greater than 10 chars", async () => { -// await catchRevert( -// I_STRProxied.modifySecurityToken("LOGAN", "LOGLOGLOGLOG", account_temp, dummy_token, "I am custom ST", currentTime, { -// from: account_polymath -// }), -// "tx revert -> ticker length is greater than 10 chars" -// ); -// }); - -// it("Should fail to generate the custom security token -- name should not be 0 length ", async () => { -// await catchRevert( -// I_STRProxied.modifySecurityToken("", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, { -// from: account_polymath -// }), -// "tx revert -> name should not be 0 length" -// ); -// }); - -// it("Should fail if ST address is 0 address", async () => { -// await catchRevert( -// I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, address_zero, "I am custom ST", currentTime, { -// from: account_polymath -// }), -// "tx revert -> Security token address is 0" -// ); -// }); - -// it("Should fail if symbol length is 0", async () => { -// await catchRevert( -// I_STRProxied.modifySecurityToken("", "0x0", account_temp, dummy_token, "I am custom ST", currentTime, { -// from: account_polymath -// }), -// "tx revert -> zero length of the symbol is not allowed" -// ); -// }); - -// it("Should fail to generate the custom ST -- deployedAt param is 0", async () => { -// await catchRevert( -// I_STRProxied.modifySecurityToken(name2, symbol2, token_owner, dummy_token, "I am custom ST", new BN(0), { from: account_polymath }), -// "tx revert -> because deployedAt param is 0" -// ); -// }); - -// it("Should successfully generate custom token", async () => { -// // Register the new ticker -- Fulfiling the TickerStatus.ON condition -// await I_PolyToken.getTokens(new BN(web3.utils.toWei("1000")), account_temp); -// await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: account_temp }); -// let tickersListArray = await I_Getter.getTickersByOwner.call(account_temp); -// console.log(tickersListArray); -// await I_STRProxied.registerTicker(account_temp, "LOG", "LOGAN", { from: account_temp }); -// tickersListArray = await I_Getter.getTickersByOwner.call(account_temp); -// console.log(tickersListArray); -// // Generating the ST -// let tx = await I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, { -// from: account_polymath -// }); -// tickersListArray = await I_Getter.getTickersByOwner.call(account_temp); -// console.log(tickersListArray); -// assert.equal(tx.logs[1].args._ticker, "LOG", "Symbol should match with the registered symbol"); -// assert.equal( -// tx.logs[1].args._securityTokenAddress, -// dummy_token, -// `Address of the SecurityToken should be matched with the input value of addCustomSecurityToken` -// ); -// let symbolDetails = await I_Getter.getTickerDetails("LOG"); -// assert.equal(symbolDetails[0], account_temp, `Owner of the symbol should be ${account_temp}`); -// assert.equal(symbolDetails[3], "LOGAN", `Name of the symbol should be LOGAN`); -// }); - -// it("Should successfully generate the custom token", async () => { -// // Fulfilling the TickerStatus.NN condition -// // -// // await catchRevert(I_STRProxied.modifySecurityToken("LOGAN2", "LOG2", account_temp, dummy_token, "I am custom ST", await latestTime(), {from: account_polymath})); -// // await I_STRProxied.modifyTicker(account_temp, "LOG2", "LOGAN2", await latestTime(), currentTime.add(new BN(duration.days(10))), false, {from: account_polymath}); -// // await increaseTime(duration.days(1)); -// let tx = await I_STRProxied.modifySecurityToken("LOGAN2", "LOG2", account_temp, dummy_token, "I am custom ST", currentTime, { -// from: account_polymath -// }); -// assert.equal(tx.logs[1].args._ticker, "LOG2", "Symbol should match with the registered symbol"); -// assert.equal( -// tx.logs[1].args._securityTokenAddress, -// dummy_token, -// `Address of the SecurityToken should be matched with the input value of addCustomSecurityToken` -// ); -// assert.equal(tx.logs[0].args._owner, account_temp, `Token owner should be ${account_temp}`); -// assert.equal(tx.logs[0].args._ticker, "LOG2", `Symbol should be LOG2`); -// let symbolDetails = await I_Getter.getTickerDetails("LOG2"); -// assert.equal(symbolDetails[0], account_temp, `Owner of the symbol should be ${account_temp}`); -// assert.equal(symbolDetails[3], "LOGAN2", `Name of the symbol should be LOGAN`); -// }); - -// it("Should successfully modify the ticker", async () => { -// let snap_Id = await takeSnapshot(); -// let tx = await I_STRProxied.modifyTicker( -// account_temp, -// "LOG2", -// "LOGAN2", -// currentTime, -// currentTime.add(new BN(duration.days(60))), -// false, -// { from: account_polymath } -// ); -// await revertToSnapshot(snap_Id); -// }); -// }); - -// describe("Test case for modifyTicker", async () => { -// it("Should add the custom ticker --failed because of bad owner", async () => { -// currentTime = new BN(await latestTime()); -// await catchRevert( -// I_STRProxied.modifyTicker(token_owner, "ETH", "Ether", currentTime, currentTime.add(new BN(duration.days(10))), false, { -// from: account_temp -// }), -// "tx revert -> failed beacause of bad owner0" -// ); -// }); - -// it("Should add the custom ticker --fail ticker length should not be 0", async () => { -// await catchRevert( -// I_STRProxied.modifyTicker(token_owner, "", "Ether", currentTime, currentTime.add(new BN(duration.days(10))), false, { -// from: account_polymath -// }), -// "tx revert -> failed beacause ticker length should not be 0" -// ); -// }); - -// it("Should add the custom ticker --failed because time should not be 0", async () => { -// await catchRevert( -// I_STRProxied.modifyTicker(token_owner, "ETH", "Ether", new BN(0), currentTime.add(new BN(duration.days(10))), false, { -// from: account_polymath -// }), -// "tx revert -> failed because time should not be 0" -// ); -// }); - -// it("Should add the custom ticker --failed because registeration date is greater than the expiryDate", async () => { -// let ctime = currentTime; -// await catchRevert( -// I_STRProxied.modifyTicker(token_owner, "ETH", "Ether", ctime, ctime.sub(new BN(duration.minutes(10))), false, { -// from: account_polymath -// }), -// "tx revert -> failed because registeration date is greater than the expiryDate" -// ); -// }); - -// it("Should add the custom ticker --failed because owner should not be 0x", async () => { -// let ctime = currentTime; -// await catchRevert( -// I_STRProxied.modifyTicker( -// address_zero, -// "ETH", -// "Ether", -// ctime, -// ctime.add(new BN(duration.minutes(10))), -// false, -// { from: account_polymath } -// ), -// "tx revert -> failed because owner should not be 0x" -// ); -// }); - -// it("Should add the new custom ticker", async () => { -// let ctime = currentTime; -// let tx = await I_STRProxied.modifyTicker( -// account_temp, -// "ETH", -// "Ether", -// ctime, -// ctime.add(new BN(duration.minutes(10))), -// false, -// { from: account_polymath } -// ); -// assert.equal(tx.logs[0].args._owner, account_temp, `Should be equal to the ${account_temp}`); -// assert.equal(tx.logs[0].args._ticker, "ETH", "Should be equal to ETH"); -// }); - -// it("Should change the details of the existing ticker", async () => { -// let ctime = currentTime; -// let tx = await I_STRProxied.modifyTicker( -// token_owner, -// "ETH", -// "Ether", -// ctime, -// ctime.add(new BN(duration.minutes(10))), -// false, -// { from: account_polymath } -// ); -// assert.equal(tx.logs[0].args._owner, token_owner); -// }); -// }); - -// describe("Test cases for the transferTickerOwnership()", async () => { -// it("Should able to transfer the ticker ownership -- failed because token is not deployed having the same ticker", async () => { -// await catchRevert( -// I_STRProxied.transferTickerOwnership(account_issuer, "ETH", { from: account_temp }), -// "tx revert -> failed because token is not deployed having the same ticker" -// ); -// }); - -// it("Should able to transfer the ticker ownership -- failed because new owner is 0x", async () => { -// await I_SecurityToken002.transferOwnership(account_temp, { from: token_owner }); -// await catchRevert( -// I_STRProxied.transferTickerOwnership(address_zero, symbol2, { from: token_owner }), -// "tx revert -> failed because new owner is 0x" -// ); -// }); - -// it("Should able to transfer the ticker ownership -- failed because ticker is of zero length", async () => { -// await catchRevert( -// I_STRProxied.transferTickerOwnership(account_temp, "", { from: token_owner }), -// "tx revert -> failed because ticker is of zero length" -// ); -// }); - -// it("Should able to transfer the ticker ownership", async () => { -// let tx = await I_STRProxied.transferTickerOwnership(account_temp, symbol2, { from: token_owner, gas: 5000000 }); -// assert.equal(tx.logs[0].args._newOwner, account_temp); -// let symbolDetails = await I_Getter.getTickerDetails.call(symbol2); -// assert.equal(symbolDetails[0], account_temp, `Owner of the symbol should be ${account_temp}`); -// assert.equal(symbolDetails[3], name2, `Name of the symbol should be ${name2}`); -// }); -// }); - -// describe("Test case for the changeSecurityLaunchFee()", async () => { -// it("Should able to change the STLaunchFee-- failed because of bad owner", async () => { -// await catchRevert( -// I_STRProxied.changeSecurityLaunchFee(new BN(web3.utils.toWei("500")), { from: account_temp }), -// "tx revert -> failed because of bad owner" -// ); -// }); - -// it("Should able to change the STLaunchFee-- failed because of putting the same fee", async () => { -// await catchRevert( -// I_STRProxied.changeSecurityLaunchFee(initRegFee, { from: account_polymath }), -// "tx revert -> failed because of putting the same fee" -// ); -// }); - -// it("Should able to change the STLaunchFee", async () => { -// let tx = await I_STRProxied.changeSecurityLaunchFee(new BN(web3.utils.toWei("500")), { from: account_polymath }); -// assert.equal(tx.logs[0].args._newFee.toString(), new BN(web3.utils.toWei("500")).toString()); -// let stLaunchFee = await I_STRProxied.getUintValue(web3.utils.soliditySha3("stLaunchFee")); -// assert.equal(stLaunchFee.toString(), new BN(web3.utils.toWei("500")).toString()); -// }); -// }); - -// describe("Test cases for the changeExpiryLimit()", async () => { -// it("Should able to change the ExpiryLimit-- failed because of bad owner", async () => { -// await catchRevert( -// I_STRProxied.changeExpiryLimit(duration.days(15), { from: account_temp }), -// "tx revert -> failed because of bad owner" -// ); -// }); - -// it("Should able to change the ExpiryLimit-- failed because expirylimit is less than 1 day", async () => { -// await catchRevert( -// I_STRProxied.changeExpiryLimit(duration.minutes(50), { from: account_polymath }), -// "tx revert -> failed because expirylimit is less than 1 day" -// ); -// }); - -// it("Should able to change the ExpiryLimit", async () => { -// let tx = await I_STRProxied.changeExpiryLimit(duration.days(20), { from: account_polymath }); -// assert.equal(tx.logs[0].args._newExpiry, duration.days(20)); -// let expiry = await I_STRProxied.getUintValue(web3.utils.soliditySha3("expiryLimit")); -// assert.equal(expiry, duration.days(20)); -// }); -// }); - -// describe("Test cases for the changeTickerRegistrationFee()", async () => { -// it("Should able to change the TickerRegFee-- failed because of bad owner", async () => { -// await catchRevert( -// I_STRProxied.changeTickerRegistrationFee(new BN(web3.utils.toWei("500")), { from: account_temp }), -// "tx revert -> failed because of bad owner" -// ); -// }); - -// it("Should able to change the TickerRegFee-- failed because of putting the same fee", async () => { -// await catchRevert( -// I_STRProxied.changeTickerRegistrationFee(initRegFee, { from: account_polymath }), -// "tx revert -> failed because of putting the same fee" -// ); -// }); - -// it("Should able to change the TickerRegFee", async () => { -// let tx = await I_STRProxied.changeTickerRegistrationFee(new BN(web3.utils.toWei("400")), { from: account_polymath }); -// assert.equal(tx.logs[0].args._newFee.toString(), new BN(web3.utils.toWei("400")).toString()); -// let tickerRegFee = await I_STRProxied.getUintValue(web3.utils.soliditySha3("tickerRegFee")); -// assert.equal(tickerRegFee.toString(), new BN(web3.utils.toWei("400")).toString()); -// }); - -// it("Should fail to register the ticker with the old fee", async () => { -// await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); -// await catchRevert( -// I_STRProxied.registerTicker(token_owner, "POLY", "Polymath", { from: token_owner }), -// "tx revert -> failed because of ticker registeration fee gets change" -// ); -// }); - -// it("Should register the ticker with the new fee", async () => { -// await I_PolyToken.getTokens(new BN(web3.utils.toWei("1600")), token_owner); -// await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("2000")), { from: token_owner }); -// let tx = await I_STRProxied.registerTicker(token_owner, "POLY", "Polymath", { from: token_owner }); -// assert.equal(tx.logs[0].args._owner, token_owner, `Token owner should be ${token_owner}`); -// assert.equal(tx.logs[0].args._ticker, "POLY", `Symbol should be POLY`); -// }); - -// it("Should fail to launch the securityToken with the old launch fee", async () => { -// await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); -// await catchRevert( -// I_STRProxied.generateSecurityToken("Polymath", "POLY", tokenDetails, false, { from: token_owner }), -// "tx revert -> failed because of old launch fee" -// ); -// }); - -// it("Should launch the the securityToken", async () => { -// await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("2000")), { from: token_owner }); -// let tx = await I_STRProxied.generateSecurityToken("Polymath", "POLY", tokenDetails, false, { from: token_owner }); - -// // Verify the successful generation of the security token -// assert.equal(tx.logs[2].args._ticker, "POLY", "SecurityToken doesn't get deployed"); -// }); -// }); - -// describe("Test case for the update poly token", async () => { -// it("Should change the polytoken address -- failed because of bad owner", async () => { -// catchRevert( -// I_STRProxied.updatePolyTokenAddress(dummy_token, { from: account_temp }), -// "tx revert -> failed because of bad owner" -// ); -// }); - -// it("Should change the polytoken address -- failed because of 0x address", async () => { -// catchRevert( -// I_STRProxied.updatePolyTokenAddress(address_zero, { from: account_polymath }), -// "tx revert -> failed because 0x address" -// ); -// }); - -// it("Should successfully change the polytoken address", async () => { -// let _id = await takeSnapshot(); -// await I_STRProxied.updatePolyTokenAddress(dummy_token, { from: account_polymath }); -// assert.equal(await I_STRProxied.getAddressValue.call(web3.utils.soliditySha3("polyToken")), dummy_token); -// await revertToSnapshot(_id); -// }); -// }); - -// describe("Test cases for getters", async () => { -// it("Should get the security token address", async () => { -// let address = await I_Getter.getSecurityTokenAddress.call(symbol); -// assert.equal(address, I_SecurityToken.address); -// }); - -// it("Should get the security token data", async () => { -// let data = await I_Getter.getSecurityTokenData.call(I_SecurityToken.address); -// assert.equal(data[0], symbol); -// assert.equal(data[1], token_owner); -// }); - -// it("Should get the tickers by owner", async () => { -// let tickersList = await I_Getter.getTickersByOwner.call(token_owner); -// console.log(tickersList); -// assert.equal(tickersList.length, 4); -// let tickersListArray = await I_Getter.getTickersByOwner.call(account_temp); -// console.log(tickersListArray); -// assert.equal(tickersListArray.length, 3); -// }); -// }); - -// describe("Test case for the Removing the ticker", async () => { -// it("Should remove the ticker from the polymath ecosystem -- bad owner", async () => { -// await catchRevert( -// I_STRProxied.removeTicker(symbol2, { from: account_investor1 }), -// "tx revert -> failed because msg.sender should be account_polymath" -// ); -// }); - -// it("Should remove the ticker from the polymath ecosystem -- fail because ticker doesn't exist in the ecosystem", async () => { -// await catchRevert( -// I_STRProxied.removeTicker("HOLA", { from: account_polymath }), -// "tx revert -> failed because ticker doesn't exist in the polymath ecosystem" -// ); -// }); - -// it("Should successfully remove the ticker from the polymath ecosystem", async () => { -// let tx = await I_STRProxied.removeTicker(symbol2, { from: account_polymath }); -// assert.equal(tx.logs[0].args._ticker, symbol2, "Ticker doesn't get deleted successfully"); -// }); -// }); - -// describe(" Test cases of the registerTicker", async () => { -// it("Should register the ticker 1", async () => { -// await I_PolyToken.getTokens(new BN(web3.utils.toWei("1600")), account_temp); -// await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("1600")), { from: account_temp }); -// let tx = await I_STRProxied.registerTicker(account_temp, "TOK1", "0x0", { from: account_temp }); -// assert.equal(tx.logs[0].args._owner, account_temp, `Owner should be the ${account_temp}`); -// assert.equal(tx.logs[0].args._ticker, "TOK1", `Symbol should be TOK1`); -// console.log((await I_Getter.getTickersByOwner.call(account_temp)).map(x => web3.utils.toUtf8(x))); -// }); - -// it("Should register the ticker 2", async () => { -// await I_PolyToken.getTokens(new BN(web3.utils.toWei("1600")), account_temp); -// await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("1600")), { from: account_temp }); -// let tx = await I_STRProxied.registerTicker(account_temp, "TOK2", "0x0", { from: account_temp }); -// assert.equal(tx.logs[0].args._owner, account_temp, `Owner should be the ${account_temp}`); -// assert.equal(tx.logs[0].args._ticker, "TOK2", `Symbol should be TOK2`); -// console.log((await I_Getter.getTickersByOwner.call(account_temp)).map(x => web3.utils.toUtf8(x))); -// }); - -// it("Should register the ticker 3", async () => { -// await I_PolyToken.getTokens(new BN(web3.utils.toWei("1600")), account_temp); -// await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("1600")), { from: account_temp }); -// let tx = await I_STRProxied.registerTicker(account_temp, "TOK3", "0x0", { from: account_temp }); -// assert.equal(tx.logs[0].args._owner, account_temp, `Owner should be the ${account_temp}`); -// assert.equal(tx.logs[0].args._ticker, "TOK3", `Symbol should be TOK3`); -// console.log((await I_Getter.getTickersByOwner.call(account_temp)).map(x => web3.utils.toUtf8(x))); -// }); - -// it("Should successfully remove the ticker 2", async () => { -// let tx = await I_STRProxied.removeTicker("TOK2", { from: account_polymath }); -// assert.equal(tx.logs[0].args._ticker, "TOK2", "Ticker doesn't get deleted successfully"); -// console.log((await I_Getter.getTickersByOwner.call(account_temp)).map(x => web3.utils.toUtf8(x))); -// }); - -// it("Should modify ticker 1", async () => { -// currentTime = new BN(await latestTime()); -// let tx = await I_STRProxied.modifyTicker( -// account_temp, -// "TOK1", -// "TOKEN 1", -// currentTime, -// currentTime.add(new BN(duration.minutes(10))), -// false, -// { from: account_polymath } -// ); -// assert.equal(tx.logs[0].args._owner, account_temp, `Should be equal to the ${account_temp}`); -// assert.equal(tx.logs[0].args._ticker, "TOK1", "Should be equal to TOK1"); -// assert.equal(tx.logs[0].args._name, "TOKEN 1", "Should be equal to TOKEN 1"); -// console.log((await I_Getter.getTickersByOwner.call(account_temp)).map(x => web3.utils.toUtf8(x))); -// }); - -// it("Should modify ticker 3", async () => { -// let tx = await I_STRProxied.modifyTicker( -// account_temp, -// "TOK3", -// "TOKEN 3", -// currentTime, -// currentTime.add(new BN(duration.minutes(10))), -// false, -// { from: account_polymath } -// ); -// assert.equal(tx.logs[0].args._owner, account_temp, `Should be equal to the ${account_temp}`); -// assert.equal(tx.logs[0].args._ticker, "TOK3", "Should be equal to TOK3"); -// assert.equal(tx.logs[0].args._name, "TOKEN 3", "Should be equal to TOKEN 3"); -// console.log((await I_Getter.getTickersByOwner.call(account_temp)).map(x => web3.utils.toUtf8(x))); -// }); -// }); -// describe("Test cases for IRegistry functionality", async () => { -// describe("Test cases for reclaiming funds", async () => { -// it("Should successfully reclaim POLY tokens -- fail because token address will be 0x", async () => { -// I_PolyToken.transfer(I_STRProxied.address, new BN(web3.utils.toWei("1")), { from: token_owner }); -// await catchRevert(I_STRProxied.reclaimERC20(address_zero, { from: account_polymath })); -// }); - -// it("Should successfully reclaim POLY tokens -- not authorised", async () => { -// await catchRevert(I_STRProxied.reclaimERC20(I_PolyToken.address, { from: account_temp })); -// }); - -// it("Should successfully reclaim POLY tokens", async () => { -// let bal1 = await I_PolyToken.balanceOf.call(account_polymath); -// await I_STRProxied.reclaimERC20(I_PolyToken.address, { from: account_polymath }); -// let bal2 = await I_PolyToken.balanceOf.call(account_polymath); -// assert.isAtLeast( -// bal2.div(new BN(10).pow(new BN(18))).toNumber(), -// bal2.div(new BN(10).pow(new BN(18))).toNumber() -// ); -// }); -// }); - -// describe("Test cases for pausing the contract", async () => { -// it("Should fail to pause if msg.sender is not owner", async () => { -// await catchRevert(I_STRProxied.pause({ from: account_temp }), "tx revert -> msg.sender should be account_polymath"); -// }); - -// it("Should successfully pause the contract", async () => { -// await I_STRProxied.pause({ from: account_polymath }); -// let status = await I_STRProxied.getBoolValue.call(web3.utils.soliditySha3("paused")); -// assert.isOk(status); -// }); - -// it("Should fail to unpause if msg.sender is not owner", async () => { -// await catchRevert(I_STRProxied.unpause({ from: account_temp }), "tx revert -> msg.sender should be account_polymath"); -// }); - -// it("Should successfully unpause the contract", async () => { -// await I_STRProxied.unpause({ from: account_polymath }); -// let status = await I_STRProxied.getBoolValue.call(web3.utils.soliditySha3("paused")); -// assert.isNotOk(status); -// }); -// }); - -// describe("Test cases for the setProtocolVersion", async () => { -// it("Should successfully change the protocolVersion -- failed because of bad owner", async () => { -// await catchRevert(I_STRProxied.setProtocolVersion(accounts[8], 5, 6, 7, { from: account_temp })); -// }); - -// it("Should successfully change the protocolVersion -- failed because factory address is 0x", async () => { -// await catchRevert( -// I_STRProxied.setProtocolVersion(address_zero, 5, 6, 7, { from: account_polymath }) -// ); -// }); - -// it("Should successfully change the protocolVersion -- not a valid vesrion", async () => { -// await catchRevert(I_STRProxied.setProtocolVersion(accounts[8], new BN(0), new BN(0), new BN(0), { from: account_polymath })); -// }); - -// it("Should successfully change the protocolVersion -- fail in second attempt because of invalid version", async () => { -// let snap_Id = await takeSnapshot(); -// await I_STRProxied.setProtocolVersion(accounts[8], 2, 3, 1, { from: account_polymath }); -// await catchRevert(I_STRProxied.setProtocolVersion(accounts[8], 1, 3, 1, { from: account_polymath })); -// await revertToSnapshot(snap_Id); -// }); -// }); - -// describe("Test cases for the transferOwnership", async () => { -// it("Should fail to transfer the ownership -- not authorised", async () => { -// await catchRevert(I_STRProxied.transferOwnership(account_temp, { from: account_issuer })); -// }); - -// it("Should fail to transfer the ownership -- 0x address is not allowed", async () => { -// await catchRevert(I_STRProxied.transferOwnership(address_zero, { from: account_polymath })); -// }); - -// it("Should successfully transfer the ownership of the STR", async () => { -// let tx = await I_STRProxied.transferOwnership(account_temp, { from: account_polymath }); -// assert.equal(tx.logs[0].args.previousOwner, account_polymath); -// assert.equal(tx.logs[0].args.newOwner, account_temp); -// }); -// }); -// }); -// }); +import latestTime from "./helpers/latestTime"; +import { duration, promisifyLogWatch, latestBlock } from "./helpers/utils"; +import { takeSnapshot, increaseTime, revertToSnapshot } from "./helpers/time"; +import { encodeProxyCall, encodeModuleCall } from "./helpers/encodeCall"; +import { catchRevert } from "./helpers/exceptions"; +import { setUpPolymathNetwork, deployDummySTOAndVerifyed } from "./helpers/createInstances"; + +const DummySTO = artifacts.require("./DummySTO.sol"); +const SecurityToken = artifacts.require("./SecurityToken.sol"); +const SecurityTokenRegistryProxy = artifacts.require("./SecurityTokenRegistryProxy.sol"); +const SecurityTokenRegistry = artifacts.require("./SecurityTokenRegistry.sol"); +const SecurityTokenRegistryMock = artifacts.require("./SecurityTokenRegistryMock.sol"); +const STFactory = artifacts.require("./STFactory.sol"); +const STFactoryV2 = artifacts.require("./STFactoryMock.sol"); +const STRGetter = artifacts.require('./STRGetter.sol'); +const STGetter = artifacts.require("./STGetter.sol"); +const DataStoreLogic = artifacts.require('./DataStore.sol'); +const DataStoreFactory = artifacts.require('./DataStoreFactory.sol'); +const TokenLib = artifacts.require('./TokenLib.sol'); +const SecurityTokenMock = artifacts.require('./SecurityTokenMock.sol'); + +const Web3 = require("web3"); +let BN = Web3.utils.BN; +const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); // Hardcoded development port + +contract("SecurityTokenRegistry", async (accounts) => { + // Accounts Variable declaration + let account_polymath; + let account_investor1; + let account_issuer; + let token_owner; + let account_investor2; + let account_fundsReceiver; + let account_delegate; + let account_temp; + let dummy_token; + + let balanceOfReceiver; + + let ID_snap; + const message = "Transaction Should Fail!!"; + + // Contract Instance Declaration + let I_GeneralTransferManagerFactory; + let I_GeneralPermissionManager; + let I_GeneralTransferManager; + let I_ModuleRegistryProxy; + let I_ModuleRegistry; + let I_FeatureRegistry; + let I_SecurityTokenRegistry; + let I_SecurityTokenRegistryV2; + let I_DummySTOFactory; + let I_STVersion; + let I_SecurityToken; + let I_DummySTO; + let I_PolyToken; + let I_STFactory; + let I_STFactory002; + let I_SecurityToken002; + let I_STFactory003; + let I_PolymathRegistry; + let I_SecurityTokenRegistryProxy; + let I_STRProxied; + let I_MRProxied; + let I_STRGetter; + let I_Getter; + let I_STGetter; + let stGetter; + let I_USDOracle; + let I_POLYOracle; + let I_StablePOLYOracle; + let I_TokenLib; + + // SecurityToken Details (Launched ST on the behalf of the issuer) + const name = "Demo Token"; + const symbol = "DET"; + const tokenDetails = "This is equity type of issuance"; + const decimals = 18; + + //Security Token Detials (Version 2) + const name2 = "Demo2 Token"; + const symbol2 = "DET2"; + const tokenDetails2 = "This is equity type of issuance"; + const address_zero = "0x0000000000000000000000000000000000000000"; + const one_address = "0x0000000000000000000000000000000000000001"; + + // Module key + const permissionManagerKey = 1; + const transferManagerKey = 2; + const stoKey = 3; + const budget = 0; + + // Initial fee for ticker registry and security token registry + const initRegFee = new BN(web3.utils.toWei("250")); + const initRegFeePOLY = new BN(web3.utils.toWei("1000")); + + const STRProxyParameters = ["address", "address", "uint256", "uint256", "address", "address"]; + const STOParameters = ["uint256", "uint256", "uint256", "string"]; + + // Capped STO details + const cap = new BN(web3.utils.toWei("10000")); + const someString = "Hello string"; + + let currentTime; + + function _pack(_major, _minor, _patch) { + let packedVersion =(parseInt(_major) << 16) | (parseInt(_minor) << 8) | parseInt(_patch); + return packedVersion; + } + + before(async () => { + currentTime = new BN(await latestTime()); + account_polymath = accounts[0]; + account_issuer = accounts[1]; + account_investor1 = accounts[9]; + account_investor2 = accounts[6]; + account_fundsReceiver = accounts[4]; + account_delegate = accounts[5]; + account_temp = accounts[8]; + token_owner = account_issuer; + dummy_token = accounts[3]; + + let instances = await setUpPolymathNetwork(account_polymath, token_owner); + + [ + I_PolymathRegistry, + I_PolyToken, + I_FeatureRegistry, + I_ModuleRegistry, + I_ModuleRegistryProxy, + I_MRProxied, + I_GeneralTransferManagerFactory, + I_STFactory, + I_SecurityTokenRegistry, + I_SecurityTokenRegistryProxy, + I_STRProxied, + I_STRGetter, + I_STGetter, + I_USDOracle, + I_POLYOracle, + I_StablePOLYOracle + ] = instances; + + // STEP 8: Deploy the CappedSTOFactory + + [I_DummySTOFactory] = await deployDummySTOAndVerifyed(account_polymath, I_MRProxied, 0); + // Step 9: Deploy the SecurityTokenRegistry + console.log(I_SecurityTokenRegistry.address); + I_SecurityTokenRegistry = await SecurityTokenRegistry.new({ from: account_polymath }); + console.log(I_SecurityTokenRegistry.address); + + assert.notEqual( + I_SecurityTokenRegistry.address.valueOf(), + address_zero, + "SecurityTokenRegistry contract was not deployed" + ); + + // Step 9 (a): Deploy the proxy + I_SecurityTokenRegistryProxy = await SecurityTokenRegistryProxy.new({ from: account_polymath }); + // Step 10 : Deploy the getter contract + I_STRGetter = await STRGetter.new({ from: account_polymath }); + //Step 11: update the registries addresses from the PolymathRegistry contract + await I_PolymathRegistry.changeAddress("SecurityTokenRegistry", I_SecurityTokenRegistryProxy.address, { from: account_polymath }); + await I_MRProxied.updateFromRegistry({ from: account_polymath }); + + console.log(` + --------------------- Polymath Network Smart Contracts: --------------------- + PolymathRegistry: ${I_PolymathRegistry.address} + SecurityTokenRegistryProxy: ${I_SecurityTokenRegistryProxy.address} + SecurityTokenRegistry: ${I_SecurityTokenRegistry.address} + ModuleRegistry: ${I_ModuleRegistry.address} + ModuleRegistryProxy: ${I_ModuleRegistryProxy.address} + FeatureRegistry: ${I_FeatureRegistry.address} + + STFactory: ${I_STFactory.address} + GeneralTransferManagerFactory: ${I_GeneralTransferManagerFactory.address} + + DummySTOFactory: ${I_DummySTOFactory.address} + ----------------------------------------------------------------------------- + `); + }); + + describe("Test the initialize the function", async () => { + it("Should successfully update the implementation address -- fail because polymathRegistry address is 0x", async () => { + let bytesProxy = encodeProxyCall(STRProxyParameters, [ + address_zero, + I_STFactory.address, + initRegFee, + initRegFee, + account_polymath, + I_STRGetter.address + ]); + await catchRevert( + I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { + from: account_polymath + }), + "tx-> revert because polymathRegistry address is 0x" + ); + }); + + it("Should successfully update the implementation address -- fail because STFactory address is 0x", async () => { + let bytesProxy = encodeProxyCall(STRProxyParameters, [ + I_PolymathRegistry.address, + address_zero, + initRegFee, + initRegFee, + account_polymath, + I_STRGetter.address + ]); + await catchRevert( + I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { + from: account_polymath + }), + "tx-> revert because STFactory address is 0x" + ); + }); + + it("Should successfully update the implementation address -- fail because STLaunch fee is 0", async () => { + let bytesProxy = encodeProxyCall(STRProxyParameters, [ + I_PolymathRegistry.address, + I_STFactory.address, + new BN(0), + initRegFee, + account_polymath, + I_STRGetter.address + ]); + await catchRevert( + I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { + from: account_polymath + }), + "tx-> revert because STLaunch fee is 0" + ); + }); + + it("Should successfully update the implementation address -- fail because tickerRegFee fee is 0", async () => { + let bytesProxy = encodeProxyCall(STRProxyParameters, [ + I_PolymathRegistry.address, + I_STFactory.address, + initRegFee, + new BN(0), + account_polymath, + I_STRGetter.address + ]); + await catchRevert( + I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { + from: account_polymath + }), + "tx-> revert because tickerRegFee is 0" + ); + }); + + it("Should successfully update the implementation address -- fail because owner address is 0x", async () => { + let bytesProxy = encodeProxyCall(STRProxyParameters, [ + I_PolymathRegistry.address, + I_STFactory.address, + initRegFee, + initRegFee, + address_zero, + I_STRGetter.address + ]); + await catchRevert( + I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { + from: account_polymath + }), + "tx-> revert because owner address is 0x" + ); + }); + + it("Should successfully update the implementation address -- fail because all params get 0", async () => { + let bytesProxy = encodeProxyCall(STRProxyParameters, [address_zero, address_zero, new BN(0), new BN(0), address_zero, address_zero]); + await catchRevert( + I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { + from: account_polymath + }), + "tx-> revert because owner address is 0x" + ); + }); + + it("Should successfully update the implementation address", async () => { + let bytesProxy = encodeProxyCall(STRProxyParameters, [ + I_PolymathRegistry.address, + I_STFactory.address, + initRegFee, + initRegFee, + account_polymath, + I_STRGetter.address + ]); + await I_SecurityTokenRegistryProxy.upgradeToAndCall("1.0.0", I_SecurityTokenRegistry.address, bytesProxy, { + from: account_polymath + }); + I_Getter = await STRGetter.at(I_SecurityTokenRegistryProxy.address); + I_STRProxied = await SecurityTokenRegistry.at(I_SecurityTokenRegistryProxy.address); + }); + }); + + describe(" Test cases of the registerTicker", async () => { + it("verify the intial parameters", async () => { + let intialised = await I_STRProxied.getBoolValue.call(web3.utils.soliditySha3("initialised")); + assert.isTrue(intialised, "Should be true"); + + let expiry = await I_STRProxied.getUintValue.call(web3.utils.soliditySha3("expiryLimit")); + assert.equal(expiry.toNumber(), 5184000, "Expiry limit should be equal to 60 days"); + + let polytoken = await I_STRProxied.getAddressValue.call(web3.utils.soliditySha3("polyToken")); + assert.equal(polytoken, I_PolyToken.address, "Should be the polytoken address"); + + let stlaunchFee = await I_STRProxied.getUintValue.call(web3.utils.soliditySha3("stLaunchFee")); + assert.equal(stlaunchFee.toString(), initRegFee.toString(), "Should be provided reg fee"); + + let tickerRegFee = await I_STRProxied.getUintValue.call(web3.utils.soliditySha3("tickerRegFee")); + assert.equal(tickerRegFee.toString(), tickerRegFee.toString(), "Should be provided reg fee"); + + let polymathRegistry = await I_STRProxied.getAddressValue.call(web3.utils.soliditySha3("polymathRegistry")); + assert.equal(polymathRegistry, I_PolymathRegistry.address, "Should be the address of the polymath registry"); + + let getterContract = await I_STRProxied.getAddressValue.call(web3.utils.soliditySha3("STRGetter")); + assert.equal(getterContract, I_STRGetter.address, "Should be the address of the getter contract"); + + let owner = await I_STRProxied.getAddressValue.call(web3.utils.soliditySha3("owner")); + assert.equal(owner, account_polymath, "Should be the address of the registry owner"); + }); + + it("Can't call the intialize function again", async () => { + await catchRevert( + I_STRProxied.initialize( + I_PolymathRegistry.address, + I_STFactory.address, + initRegFee, + initRegFee, + account_polymath, + I_STRGetter.address + ), + "tx revert -> Can't call the intialize function again" + ); + }); + + it("Should fail to register ticker if tickerRegFee not approved", async () => { + await catchRevert( + I_STRProxied.registerTicker(account_temp, symbol, name, { from: account_temp }), + "tx revert -> POLY allowance not provided for registration fee" + ); + }); + + it("Should fail to register ticker if owner is 0x", async () => { + await I_PolyToken.getTokens(initRegFeePOLY, account_temp); + await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: account_temp }); + + await catchRevert( + I_STRProxied.registerTicker(address_zero, symbol, name, { from: account_temp }), + "tx revert -> owner should not be 0x" + ); + }); + + it("Should fail to register ticker due to the symbol length is 0", async () => { + await catchRevert(I_STRProxied.registerTicker(account_temp, "", name, { from: account_temp }), "tx revert -> Symbol Length is 0"); + }); + + it("Should fail to register ticker due to the symbol length is greater than 10", async () => { + await catchRevert( + I_STRProxied.registerTicker(account_temp, "POLYMATHNET", name, { from: account_temp }), + "tx revert -> Symbol Length is greater than 10" + ); + }); + + it("Should register the ticker before the generation of the security token", async () => { + let tx = await I_STRProxied.registerTicker(account_temp, symbol, name, { from: account_temp }); + assert.equal(tx.logs[0].args._owner, account_temp, `Owner should be the ${account_temp}`); + assert.equal(tx.logs[0].args._ticker, symbol, `Symbol should be ${symbol}`); + let data = await I_Getter.getTickerDetails.call(symbol); + assert.equal(data[0], account_temp); + assert.equal(data[3], name); + // trying to access the function data directly from the STRGetter then it should give all values zero + data = await I_STRGetter.getTickerDetails.call(symbol); + assert.equal(data[0], address_zero); + assert.equal(data[3], ""); + }); + + it("Should change ticker price based on oracle", async () => { + let snap_Id = await takeSnapshot(); + let origPriceUSD = new BN(web3.utils.toWei("250")); + let origPricePOLY = new BN(web3.utils.toWei("1000")); + let currentRate = await I_POLYOracle.getPrice.call(); + console.log("Current Rate: " + currentRate); + let feesTicker = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); + let feesToken = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); + assert.equal(feesTicker[0].toString(), origPriceUSD.toString()); + assert.equal(feesTicker[1].toString(), origPricePOLY.toString()); + assert.equal(feesToken[0].toString(), origPriceUSD.toString()); + assert.equal(feesToken[1].toString(), origPricePOLY.toString()); + await I_POLYOracle.changePrice(new BN(27).mul(new BN(10).pow(new BN(16)))); + await I_STRProxied.getFees("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); + feesTicker = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); + feesToken = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); + // No change as difference is less than 10% + assert.equal(feesTicker[0].toString(), origPriceUSD.toString()); + assert.equal(feesTicker[1].toString(), origPricePOLY.toString()); + assert.equal(feesToken[0].toString(), origPriceUSD.toString()); + assert.equal(feesToken[1].toString(), origPricePOLY.toString()); + await I_POLYOracle.changePrice(new BN(20).mul(new BN(10).pow(new BN(16)))); + await I_STRProxied.getFees("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); + feesTicker = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); + feesToken = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); + let newPricePOLY = new BN(web3.utils.toWei("1250")); + assert.equal(feesTicker[0].toString(), origPriceUSD.toString()); + assert.equal(feesTicker[1].toString(), newPricePOLY.toString()); + assert.equal(feesToken[0].toString(), origPriceUSD.toString()); + assert.equal(feesToken[1].toString(), newPricePOLY.toString()); + await I_POLYOracle.changePrice(new BN(21).mul(new BN(10).pow(new BN(16)))); + await I_STRProxied.getFees("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); + feesTicker = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); + feesToken = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); + // No change as difference is less than 10% + assert.equal(feesTicker[0].toString(), origPriceUSD.toString()); + assert.equal(feesTicker[1].toString(), newPricePOLY.toString()); + assert.equal(feesToken[0].toString(), origPriceUSD.toString()); + assert.equal(feesToken[1].toString(), newPricePOLY.toString()); + await I_StablePOLYOracle.changeEvictPercentage(new BN(10).pow(new BN(16))); + await I_STRProxied.getFees("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); + feesTicker = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); + feesToken = await I_STRProxied.getFees.call("0x2fcc69711628630fb5a42566c68bd1092bc4aa26826736293969fddcd11cb2d2"); + // Change as eviction percentage updated + // newPricePOLY = new BN(web3.utils.toWei("1250")); + //1190.476190476190476190 = 250/0.21 + assert.equal(feesTicker[0].toString(), origPriceUSD.toString()); + assert.equal(feesTicker[1].toString(), "1190476190476190476190"); + assert.equal(feesToken[0].toString(), origPriceUSD.toString()); + assert.equal(feesToken[1].toString(), "1190476190476190476190"); + await revertToSnapshot(snap_Id); + }); + + it("Should register the ticker when the tickerRegFee is 0", async () => { + let snap_Id = await takeSnapshot(); + await I_STRProxied.changeTickerRegistrationFee(0, { from: account_polymath }); + let tx = await I_STRProxied.registerTicker(account_temp, "ZERO", name, { from: account_temp }); + assert.equal(tx.logs[0].args._owner, account_temp, `Owner should be the ${account_temp}`); + assert.equal(tx.logs[0].args._ticker, "ZERO", `Symbol should be ZERO`); + await revertToSnapshot(snap_Id); + }); + + it("Should fail to register same symbol again", async () => { + // Give POLY to token issuer + await I_PolyToken.getTokens(initRegFeePOLY, token_owner); + await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); + // Call registration function + await catchRevert( + I_STRProxied.registerTicker(token_owner, symbol, name, { from: token_owner }), + "tx revert -> Symbol is already alloted to someone else" + ); + }); + + it("Should successfully register pre registerd ticker if expiry is reached", async () => { + await increaseTime(5184000 + 100); // 60(5184000) days of expiry + 100 sec for buffer + await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); + let tx = await I_STRProxied.registerTicker(token_owner, symbol, name, { from: token_owner }); + assert.equal(tx.logs[0].args._owner, token_owner, `Owner should be the ${token_owner}`); + assert.equal(tx.logs[0].args._ticker, symbol, `Symbol should be ${symbol}`); + }); + + it("Should fail to register ticker if registration is paused", async () => { + await I_STRProxied.pause({ from: account_polymath }); + await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); + + await catchRevert( + I_STRProxied.registerTicker(token_owner, "AAA", name, { from: token_owner }), + "tx revert -> Registration is paused" + ); + }); + + it("Should fail to pause if already paused", async () => { + await catchRevert(I_STRProxied.pause({ from: account_polymath }), "tx revert -> Registration is already paused"); + }); + + it("Should successfully register ticker if registration is unpaused", async () => { + await I_STRProxied.unpause({ from: account_polymath }); + await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); + let tx = await I_STRProxied.registerTicker(token_owner, "AAA", name, { from: token_owner }); + assert.equal(tx.logs[0].args._owner, token_owner, `Owner should be the ${token_owner}`); + assert.equal(tx.logs[0].args._ticker, "AAA", `Symbol should be AAA`); + }); + + it("Should fail to unpause if already unpaused", async () => { + await catchRevert(I_STRProxied.unpause({ from: account_polymath }), "tx revert -> Registration is already unpaused"); + }); + }); + + describe("Test cases for the expiry limit", async () => { + it("Should fail to set the expiry limit because msg.sender is not owner", async () => { + await catchRevert(I_STRProxied.changeExpiryLimit(duration.days(10), { from: account_temp }), "tx revert -> msg.sender is not owner"); + }); + + it("Should successfully set the expiry limit", async () => { + await I_STRProxied.changeExpiryLimit(duration.days(10), { from: account_polymath }); + assert.equal( + (await I_STRProxied.getUintValue.call(web3.utils.soliditySha3("expiryLimit"))).toNumber(), + duration.days(10), + "Failed to change the expiry limit" + ); + }); + + it("Should fail to set the expiry limit because new expiry limit is lesser than one day", async () => { + await catchRevert( + I_STRProxied.changeExpiryLimit(duration.seconds(5000), { from: account_polymath }), + "tx revert -> New expiry limit is lesser than one day" + ); + }); + }); + + describe("Test cases for the getTickerDetails", async () => { + it("Should get the details of the symbol", async () => { + let tx = await I_Getter.getTickerDetails.call(symbol); + assert.equal(tx[0], token_owner, "Should equal to the rightful owner of the ticker"); + assert.equal(tx[3], name, `Name of the token should equal to ${name}`); + assert.equal(tx[4], false, "Status if the symbol should be undeployed -- false"); + }); + + it("Should get the details of unregistered token", async () => { + let tx = await I_Getter.getTickerDetails.call("TORO"); + assert.equal(tx[0], address_zero, "Should be 0x as ticker is not exists in the registry"); + assert.equal(tx[3], "", "Should be an empty string"); + assert.equal(tx[4], false, "Status if the symbol should be undeployed -- false"); + }); + }); + + describe("Generate SecurityToken", async () => { + it("Should get the ticker details successfully and prove the data is not storing in to the logic contract", async () => { + let data = await I_Getter.getTickerDetails(symbol, { from: token_owner }); + assert.equal(data[0], token_owner, "Token owner should be equal"); + assert.equal(data[3], name, "Name of the token should match with the registered symbol infor"); + assert.equal(data[4], false, "Token is not launched yet so it should return False"); + data = await I_STRGetter.getTickerDetails(symbol, { from: token_owner }); + console.log("This is the data from the original securityTokenRegistry contract"); + assert.equal(data[0], address_zero, "Token owner should be 0x"); + }); + + it("Should fail to generate new security token if fee not provided", async () => { + await I_PolyToken.approve(I_STRProxied.address, new BN(0), { from: token_owner }); + + await catchRevert( + I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: token_owner }), + "tx revert -> POLY allowance not provided for registration fee" + ); + }); + + it("Should fail to generate token if registration is paused", async () => { + await I_STRProxied.pause({ from: account_polymath }); + await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); + + await catchRevert( + I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: token_owner }), + "tx revert -> Registration is paused" + ); + }); + + it("Should fail to generate the securityToken -- Because ticker length is 0", async () => { + await I_STRProxied.unpause({ from: account_polymath }); + + await catchRevert( + I_STRProxied.generateSecurityToken(name, "0x0", tokenDetails, false, 0, { from: token_owner }), + "tx revert -> Zero ticker length is not allowed" + ); + }); + + it("Should fail to generate the securityToken -- Because name length is 0", async () => { + await catchRevert( + I_STRProxied.generateSecurityToken("", symbol, tokenDetails, false, 0, { from: token_owner }), + "tx revert -> 0 name length is not allowed" + ); + }); + + it("Should fail to generate the securityToken -- Because version is not valid", async () => { + await catchRevert( + I_STRProxied.generateSecurityToken("", symbol, tokenDetails, false, 12356, { from: token_owner }), + "tx revert -> 0 name length is not allowed" + ); + }); + + it("Should fail to generate the securityToken -- Because msg.sender is not the rightful owner of the ticker", async () => { + await catchRevert( + I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: account_temp }), + "tx revert -> Because msg.sender is not the rightful owner of the ticker" + ); + }); + + it("Should generate the new security token with the same symbol as registered above", async () => { + + let tx = await I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: token_owner }); + + // Verify the successful generation of the security token + assert.equal(tx.logs[2].args._ticker, symbol, "SecurityToken doesn't get deployed"); + + I_SecurityToken = await SecurityToken.at(tx.logs[2].args._securityTokenAddress); + stGetter = await STGetter.at(I_SecurityToken.address); + const log = (await I_SecurityToken.getPastEvents('ModuleAdded', {filter: {transactionHash: tx.transactionHash}}))[0]; + + // Verify that GeneralTrasnferManager module get added successfully or not + assert.equal(log.args._types[0].toNumber(), transferManagerKey, `Should be equal to the ${transferManagerKey}`); + assert.equal(web3.utils.toAscii(log.args._name).replace(/\u0000/g, ""), "GeneralTransferManager"); + }); + + it("Should fail to generate the SecurityToken when token is already deployed with the same symbol", async () => { + await catchRevert( + I_STRProxied.generateSecurityToken(name, symbol, tokenDetails, false, 0, { from: token_owner }), + "tx revert -> Because ticker is already in use" + ); + }); + + it("Should fail to generate the SecurityToken because ticker gets expired", async () => { + let snap_Id = await takeSnapshot(); + await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("2000")), { from: token_owner }); + let tx = await I_STRProxied.registerTicker(token_owner, "CCC", name, { from: token_owner }); + await increaseTime(duration.days(65)); + await catchRevert( + I_STRProxied.generateSecurityToken(name, "CCC", tokenDetails, false, 0, { from: token_owner }), + "tx revert -> Because ticker is expired" + ); + await revertToSnapshot(snap_Id); + }); + + it("Should generate the SecurityToken when launch fee is 0", async () => { + let snap_Id = await takeSnapshot(); + await I_STRProxied.changeSecurityLaunchFee(0, { from: account_polymath }); + await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("2000")), { from: token_owner }); + let tx = await I_STRProxied.registerTicker(token_owner, "CCC", name, { from: token_owner }); + await I_STRProxied.generateSecurityToken(name, "CCC", tokenDetails, false, 0, { from: token_owner }), + await revertToSnapshot(snap_Id); + }); + + it("Should get all created security tokens", async() => { + let snap_Id = await takeSnapshot(); + await I_PolyToken.getTokens(web3.utils.toWei("2000"), account_temp); + await I_PolyToken.approve(I_STRProxied.address, web3.utils.toWei("2000"), { from: account_temp }); + await I_STRProxied.registerTicker(account_temp, "TMP", name, { from: account_temp }); + let tx = await I_STRProxied.generateSecurityToken(name, "TMP", tokenDetails, false, 0, { from: account_temp }); + + // Verify the successful generation of the security token + assert.equal(tx.logs[2].args._ticker, "TMP", "SecurityToken doesn't get deployed"); + + let securityTokenTmp = await SecurityToken.at(tx.logs[2].args._securityTokenAddress); + + let tokens = await I_Getter.getTokensByOwner.call(token_owner); + assert.equal(tokens.length, 1, "tokens array length error"); + assert.equal(tokens[0], I_SecurityToken.address, "ST address incorrect"); + + let allTokens = await I_Getter.getTokens.call(); + assert.equal(allTokens.length, 2); + assert.equal(allTokens[0], securityTokenTmp.address); + assert.equal(allTokens[1], I_SecurityToken.address); + + await revertToSnapshot(snap_Id); + }); + }); + + describe("Generate SecurityToken v2", async () => { + it("Should deploy the st version 2", async () => { + // Step 7: Deploy the STFactory contract + I_STGetter = await STGetter.new(); + let I_DataStoreLogic = await DataStoreLogic.new({ from: account_polymath }); + let I_DataStoreFactory = await DataStoreFactory.new(I_DataStoreLogic.address, { from: account_polymath }); + I_TokenLib = await TokenLib.new(); + await STFactoryV2.link(TokenLib); + await SecurityTokenMock.link(TokenLib); + I_STFactory002 = await STFactoryV2.new(I_GeneralTransferManagerFactory.address, I_DataStoreFactory.address, I_STGetter.address, { from: account_polymath }); + + assert.notEqual( + I_STFactory002.address.valueOf(), + address_zero, + "STFactory002 contract was not deployed" + ); + let _protocol = await I_Getter.getCurrentProtocolVersion.call(); + assert.equal(_protocol[0], 2); + assert.equal(_protocol[1], 0); + assert.equal(_protocol[2], 0); + }); + + it("Should register the ticker before the generation of the security token", async () => { + await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); + let tx = await I_STRProxied.registerTicker(token_owner, symbol2, name2, { from: token_owner }); + assert.equal(tx.logs[0].args._owner, token_owner, `Token owner should be ${token_owner}`); + assert.equal(tx.logs[0].args._ticker, symbol2, `Symbol should be ${symbol2}`); + }); + + it("Should change the protocol version", async() => { + await I_STRProxied.setProtocolVersion(I_STFactory002.address, new BN(2), new BN(2), new BN(0), { from: account_polymath }); + let _protocol = await I_Getter.getCurrentProtocolVersion.call(); + assert.equal(_protocol[0], 2); + assert.equal(_protocol[1], 2); + assert.equal(_protocol[2], 0); + await I_STRProxied.setProtocolVersion(I_STFactory.address, new BN(3), new BN(0), new BN(0), { from: account_polymath}); + _protocol = await I_Getter.getCurrentProtocolVersion.call(); + assert.equal(_protocol[0], 3); + assert.equal(_protocol[1], 0); + assert.equal(_protocol[2], 0); + }); + + it("Should fail to generate the securityToken because of invalid version", async() => { + await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); + await catchRevert( + I_STRProxied.generateSecurityToken(name2, symbol2, tokenDetails, false, _pack(1,2,0), { from: token_owner }) + ); + }) + + it("Should generate the new security token with version 2", async () => { + let tx = await I_STRProxied.generateSecurityToken(name2, symbol2, tokenDetails, false, _pack(2,2,0), { from: token_owner }); + + // Verify the successful generation of the security token + assert.equal(tx.logs[2].args._ticker, symbol2, "SecurityToken doesn't get deployed"); + + I_SecurityToken002 = await SecurityTokenMock.at(tx.logs[2].args._securityTokenAddress); + let stGetterV2 = await STGetter.at(I_SecurityToken002.address); + let stVersion = await stGetterV2.getVersion.call(); + assert.equal(stVersion[0], 2); + assert.equal(stVersion[1], 2); + assert.equal(stVersion[2], 0); + const log = (await I_SecurityToken002.getPastEvents('ModuleAdded'))[0]; + // Verify that GeneralTransferManager module get added successfully or not + assert.equal(log.args._types[0].toNumber(), transferManagerKey); + assert.equal(web3.utils.toAscii(log.args._name).replace(/\u0000/g, ""), "GeneralTransferManager"); + }); + }); + + describe("Deploy the new SecurityTokenRegistry", async () => { + it("Should deploy the new SecurityTokenRegistry contract logic", async () => { + I_SecurityTokenRegistryV2 = await SecurityTokenRegistryMock.new({ from: account_polymath }); + assert.notEqual(I_SecurityTokenRegistryV2.address.valueOf(), address_zero, "SecurityTokenRegistry contract was not deployed"); + }); + + it("Should fail to upgrade the logic contract of the STRProxy -- bad owner", async () => { + await I_STRProxied.pause({ from: account_polymath }); + + await catchRevert( + I_SecurityTokenRegistryProxy.upgradeTo("1.1.0", I_SecurityTokenRegistryV2.address, { from: account_temp }), + "tx revert -> bad owner" + ); + }); + + it("Should upgrade the logic contract into the STRProxy", async () => { + await I_SecurityTokenRegistryProxy.upgradeTo("1.1.0", I_SecurityTokenRegistryV2.address, { from: account_polymath }); + I_STRProxied = await SecurityTokenRegistry.at(I_SecurityTokenRegistryProxy.address); + assert.isTrue(await I_STRProxied.getBoolValue.call(web3.utils.soliditySha3("paused")), "Paused value should be false"); + }); + + it("Should check the old data persist or not", async () => { + let data = await I_Getter.getTickerDetails.call(symbol); + assert.equal(data[0], token_owner, "Should be equal to the token owner address"); + assert.equal(data[3], name, "Should be equal to the name of the token that is provided earlier"); + assert.isTrue(data[4], "Token status should be deployed == true"); + }); + + it("Should unpause the logic contract", async () => { + await I_STRProxied.unpause({ from: account_polymath }); + assert.isFalse(await I_STRProxied.getBoolValue.call(web3.utils.soliditySha3("paused")), "Paused value should be false"); + }); + }); + + describe("Generate custom tokens", async () => { + it("Should fail if msg.sender is not polymath", async () => { + await catchRevert( + I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, { + from: account_delegate + }), + "tx revert -> msg.sender is not polymath account" + ); + }); + + it("Should fail to genrate the custom security token -- ticker length is greater than 10 chars", async () => { + await catchRevert( + I_STRProxied.modifySecurityToken("LOGAN", "LOGLOGLOGLOG", account_temp, dummy_token, "I am custom ST", currentTime, { + from: account_polymath + }), + "tx revert -> ticker length is greater than 10 chars" + ); + }); + + it("Should fail to generate the custom security token -- name should not be 0 length ", async () => { + await catchRevert( + I_STRProxied.modifySecurityToken("", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, { + from: account_polymath + }), + "tx revert -> name should not be 0 length" + ); + }); + + it("Should fail if ST address is 0 address", async () => { + await catchRevert( + I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, address_zero, "I am custom ST", currentTime, { + from: account_polymath + }), + "tx revert -> Security token address is 0" + ); + }); + + it("Should fail if symbol length is 0", async () => { + await catchRevert( + I_STRProxied.modifySecurityToken("", "0x0", account_temp, dummy_token, "I am custom ST", currentTime, { + from: account_polymath + }), + "tx revert -> zero length of the symbol is not allowed" + ); + }); + + it("Should fail to generate the custom ST -- deployedAt param is 0", async () => { + await catchRevert( + I_STRProxied.modifySecurityToken(name2, symbol2, token_owner, dummy_token, "I am custom ST", new BN(0), { from: account_polymath }), + "tx revert -> because deployedAt param is 0" + ); + }); + + it("Should successfully generate custom token", async () => { + // Register the new ticker -- Fulfiling the TickerStatus.ON condition + await I_PolyToken.getTokens(new BN(web3.utils.toWei("1000")), account_temp); + await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: account_temp }); + let tickersListArray = await I_Getter.getTickersByOwner.call(account_temp); + console.log(tickersListArray); + await I_STRProxied.registerTicker(account_temp, "LOG", "LOGAN", { from: account_temp }); + tickersListArray = await I_Getter.getTickersByOwner.call(account_temp); + console.log(tickersListArray); + // Generating the ST + let tx = await I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, { + from: account_polymath + }); + tickersListArray = await I_Getter.getTickersByOwner.call(account_temp); + console.log(tickersListArray); + assert.equal(tx.logs[1].args._ticker, "LOG", "Symbol should match with the registered symbol"); + assert.equal( + tx.logs[1].args._securityTokenAddress, + dummy_token, + `Address of the SecurityToken should be matched with the input value of addCustomSecurityToken` + ); + let symbolDetails = await I_Getter.getTickerDetails("LOG"); + assert.equal(symbolDetails[0], account_temp, `Owner of the symbol should be ${account_temp}`); + assert.equal(symbolDetails[3], "LOGAN", `Name of the symbol should be LOGAN`); + }); + + it("Should successfully generate the custom token", async () => { + // Fulfilling the TickerStatus.NN condition + // + // await catchRevert(I_STRProxied.modifySecurityToken("LOGAN2", "LOG2", account_temp, dummy_token, "I am custom ST", await latestTime(), {from: account_polymath})); + // await I_STRProxied.modifyTicker(account_temp, "LOG2", "LOGAN2", await latestTime(), currentTime.add(new BN(duration.days(10))), false, {from: account_polymath}); + // await increaseTime(duration.days(1)); + let tx = await I_STRProxied.modifySecurityToken("LOGAN2", "LOG2", account_temp, dummy_token, "I am custom ST", currentTime, { + from: account_polymath + }); + assert.equal(tx.logs[1].args._ticker, "LOG2", "Symbol should match with the registered symbol"); + assert.equal( + tx.logs[1].args._securityTokenAddress, + dummy_token, + `Address of the SecurityToken should be matched with the input value of addCustomSecurityToken` + ); + assert.equal(tx.logs[0].args._owner, account_temp, `Token owner should be ${account_temp}`); + assert.equal(tx.logs[0].args._ticker, "LOG2", `Symbol should be LOG2`); + let symbolDetails = await I_Getter.getTickerDetails("LOG2"); + assert.equal(symbolDetails[0], account_temp, `Owner of the symbol should be ${account_temp}`); + assert.equal(symbolDetails[3], "LOGAN2", `Name of the symbol should be LOGAN`); + }); + + it("Should successfully modify the ticker", async () => { + let snap_Id = await takeSnapshot(); + let tx = await I_STRProxied.modifyTicker( + account_temp, + "LOG2", + "LOGAN2", + currentTime, + currentTime.add(new BN(duration.days(60))), + false, + { from: account_polymath } + ); + await revertToSnapshot(snap_Id); + }); + }); + + describe("Test case for modifyTicker", async () => { + it("Should add the custom ticker --failed because of bad owner", async () => { + currentTime = new BN(await latestTime()); + await catchRevert( + I_STRProxied.modifyTicker(token_owner, "ETH", "Ether", currentTime, currentTime.add(new BN(duration.days(10))), false, { + from: account_temp + }), + "tx revert -> failed beacause of bad owner0" + ); + }); + + it("Should add the custom ticker --fail ticker length should not be 0", async () => { + await catchRevert( + I_STRProxied.modifyTicker(token_owner, "", "Ether", currentTime, currentTime.add(new BN(duration.days(10))), false, { + from: account_polymath + }), + "tx revert -> failed beacause ticker length should not be 0" + ); + }); + + it("Should add the custom ticker --failed because time should not be 0", async () => { + await catchRevert( + I_STRProxied.modifyTicker(token_owner, "ETH", "Ether", new BN(0), currentTime.add(new BN(duration.days(10))), false, { + from: account_polymath + }), + "tx revert -> failed because time should not be 0" + ); + }); + + it("Should add the custom ticker --failed because registeration date is greater than the expiryDate", async () => { + let ctime = currentTime; + await catchRevert( + I_STRProxied.modifyTicker(token_owner, "ETH", "Ether", ctime, ctime.sub(new BN(duration.minutes(10))), false, { + from: account_polymath + }), + "tx revert -> failed because registeration date is greater than the expiryDate" + ); + }); + + it("Should add the custom ticker --failed because owner should not be 0x", async () => { + let ctime = currentTime; + await catchRevert( + I_STRProxied.modifyTicker( + address_zero, + "ETH", + "Ether", + ctime, + ctime.add(new BN(duration.minutes(10))), + false, + { from: account_polymath } + ), + "tx revert -> failed because owner should not be 0x" + ); + }); + + it("Should add the new custom ticker", async () => { + let ctime = currentTime; + let tx = await I_STRProxied.modifyTicker( + account_temp, + "ETH", + "Ether", + ctime, + ctime.add(new BN(duration.minutes(10))), + false, + { from: account_polymath } + ); + assert.equal(tx.logs[0].args._owner, account_temp, `Should be equal to the ${account_temp}`); + assert.equal(tx.logs[0].args._ticker, "ETH", "Should be equal to ETH"); + }); + + it("Should change the details of the existing ticker", async () => { + let ctime = currentTime; + let tx = await I_STRProxied.modifyTicker( + token_owner, + "ETH", + "Ether", + ctime, + ctime.add(new BN(duration.minutes(10))), + false, + { from: account_polymath } + ); + assert.equal(tx.logs[0].args._owner, token_owner); + }); + }); + + describe("Test cases for the transferTickerOwnership()", async () => { + it("Should able to transfer the ticker ownership -- failed because token is not deployed having the same ticker", async () => { + await catchRevert( + I_STRProxied.transferTickerOwnership(account_issuer, "ETH", { from: account_temp }), + "tx revert -> failed because token is not deployed having the same ticker" + ); + }); + + it("Should able to transfer the ticker ownership -- failed because new owner is 0x", async () => { + await I_SecurityToken002.transferOwnership(account_temp, { from: token_owner }); + await catchRevert( + I_STRProxied.transferTickerOwnership(address_zero, symbol2, { from: token_owner }), + "tx revert -> failed because new owner is 0x" + ); + }); + + it("Should able to transfer the ticker ownership -- failed because ticker is of zero length", async () => { + await catchRevert( + I_STRProxied.transferTickerOwnership(account_temp, "", { from: token_owner }), + "tx revert -> failed because ticker is of zero length" + ); + }); + + it("Should able to transfer the ticker ownership", async () => { + let tx = await I_STRProxied.transferTickerOwnership(account_temp, symbol2, { from: token_owner, gas: 5000000 }); + assert.equal(tx.logs[0].args._newOwner, account_temp); + let symbolDetails = await I_Getter.getTickerDetails.call(symbol2); + assert.equal(symbolDetails[0], account_temp, `Owner of the symbol should be ${account_temp}`); + assert.equal(symbolDetails[3], name2, `Name of the symbol should be ${name2}`); + }); + }); + + describe("Test case for the changeSecurityLaunchFee()", async () => { + it("Should able to change the STLaunchFee-- failed because of bad owner", async () => { + await catchRevert( + I_STRProxied.changeSecurityLaunchFee(new BN(web3.utils.toWei("500")), { from: account_temp }), + "tx revert -> failed because of bad owner" + ); + }); + + it("Should able to change the STLaunchFee-- failed because of putting the same fee", async () => { + await catchRevert( + I_STRProxied.changeSecurityLaunchFee(initRegFee, { from: account_polymath }), + "tx revert -> failed because of putting the same fee" + ); + }); + + it("Should able to change the STLaunchFee", async () => { + let tx = await I_STRProxied.changeSecurityLaunchFee(new BN(web3.utils.toWei("500")), { from: account_polymath }); + assert.equal(tx.logs[0].args._newFee.toString(), new BN(web3.utils.toWei("500")).toString()); + let stLaunchFee = await I_STRProxied.getUintValue(web3.utils.soliditySha3("stLaunchFee")); + assert.equal(stLaunchFee.toString(), new BN(web3.utils.toWei("500")).toString()); + }); + }); + + describe("Test cases for the changeExpiryLimit()", async () => { + it("Should able to change the ExpiryLimit-- failed because of bad owner", async () => { + await catchRevert( + I_STRProxied.changeExpiryLimit(duration.days(15), { from: account_temp }), + "tx revert -> failed because of bad owner" + ); + }); + + it("Should able to change the ExpiryLimit-- failed because expirylimit is less than 1 day", async () => { + await catchRevert( + I_STRProxied.changeExpiryLimit(duration.minutes(50), { from: account_polymath }), + "tx revert -> failed because expirylimit is less than 1 day" + ); + }); + + it("Should able to change the ExpiryLimit", async () => { + let tx = await I_STRProxied.changeExpiryLimit(duration.days(20), { from: account_polymath }); + assert.equal(tx.logs[0].args._newExpiry, duration.days(20)); + let expiry = await I_STRProxied.getUintValue(web3.utils.soliditySha3("expiryLimit")); + assert.equal(expiry, duration.days(20)); + }); + }); + + describe("Test cases for the changeTickerRegistrationFee()", async () => { + it("Should able to change the TickerRegFee-- failed because of bad owner", async () => { + await catchRevert( + I_STRProxied.changeTickerRegistrationFee(new BN(web3.utils.toWei("500")), { from: account_temp }), + "tx revert -> failed because of bad owner" + ); + }); + + it("Should able to change the TickerRegFee-- failed because of putting the same fee", async () => { + await catchRevert( + I_STRProxied.changeTickerRegistrationFee(initRegFee, { from: account_polymath }), + "tx revert -> failed because of putting the same fee" + ); + }); + + it("Should able to change the TickerRegFee", async () => { + let tx = await I_STRProxied.changeTickerRegistrationFee(new BN(web3.utils.toWei("400")), { from: account_polymath }); + assert.equal(tx.logs[0].args._newFee.toString(), new BN(web3.utils.toWei("400")).toString()); + let tickerRegFee = await I_STRProxied.getUintValue(web3.utils.soliditySha3("tickerRegFee")); + assert.equal(tickerRegFee.toString(), new BN(web3.utils.toWei("400")).toString()); + }); + + it("Should fail to register the ticker with the old fee", async () => { + await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); + await catchRevert( + I_STRProxied.registerTicker(token_owner, "POLY", "Polymath", { from: token_owner }), + "tx revert -> failed because of ticker registeration fee gets change" + ); + }); + + it("Should register the ticker with the new fee", async () => { + await I_PolyToken.getTokens(new BN(web3.utils.toWei("1600")), token_owner); + await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("2000")), { from: token_owner }); + let tx = await I_STRProxied.registerTicker(token_owner, "POLY", "Polymath", { from: token_owner }); + assert.equal(tx.logs[0].args._owner, token_owner, `Token owner should be ${token_owner}`); + assert.equal(tx.logs[0].args._ticker, "POLY", `Symbol should be POLY`); + }); + + it("Should fail to launch the securityToken with the old launch fee", async () => { + await I_PolyToken.approve(I_STRProxied.address, initRegFeePOLY, { from: token_owner }); + await catchRevert( + I_STRProxied.generateSecurityToken("Polymath", "POLY", tokenDetails, false, 0, { from: token_owner }), + "tx revert -> failed because of old launch fee" + ); + }); + + it("Should launch the the securityToken", async () => { + await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("2000")), { from: token_owner }); + let tx = await I_STRProxied.generateSecurityToken("Polymath", "POLY", tokenDetails, false, 0, { from: token_owner }); + + // Verify the successful generation of the security token + assert.equal(tx.logs[2].args._ticker, "POLY", "SecurityToken doesn't get deployed"); + }); + }); + + describe("Test case for the update poly token", async () => { + it("Should change the polytoken address -- failed because of bad owner", async () => { + catchRevert( + I_STRProxied.updatePolyTokenAddress(dummy_token, { from: account_temp }), + "tx revert -> failed because of bad owner" + ); + }); + + it("Should change the polytoken address -- failed because of 0x address", async () => { + catchRevert( + I_STRProxied.updatePolyTokenAddress(address_zero, { from: account_polymath }), + "tx revert -> failed because 0x address" + ); + }); + + it("Should successfully change the polytoken address", async () => { + let _id = await takeSnapshot(); + await I_STRProxied.updatePolyTokenAddress(dummy_token, { from: account_polymath }); + assert.equal(await I_STRProxied.getAddressValue.call(web3.utils.soliditySha3("polyToken")), dummy_token); + await revertToSnapshot(_id); + }); + }); + + describe("Test cases for getters", async () => { + it("Should get the security token address", async () => { + let address = await I_Getter.getSecurityTokenAddress.call(symbol); + assert.equal(address, I_SecurityToken.address); + }); + + it("Should get the security token data", async () => { + let data = await I_Getter.getSecurityTokenData.call(I_SecurityToken.address); + assert.equal(data[0], symbol); + assert.equal(data[1], token_owner); + }); + + it("Should get the tickers by owner", async () => { + let tickersList = await I_Getter.getTickersByOwner.call(token_owner); + console.log(tickersList); + assert.equal(tickersList.length, 4); + let tickersListArray = await I_Getter.getTickersByOwner.call(account_temp); + console.log(tickersListArray); + assert.equal(tickersListArray.length, 3); + }); + }); + + describe("Test case for the Removing the ticker", async () => { + it("Should remove the ticker from the polymath ecosystem -- bad owner", async () => { + await catchRevert( + I_STRProxied.removeTicker(symbol2, { from: account_investor1 }), + "tx revert -> failed because msg.sender should be account_polymath" + ); + }); + + it("Should remove the ticker from the polymath ecosystem -- fail because ticker doesn't exist in the ecosystem", async () => { + await catchRevert( + I_STRProxied.removeTicker("HOLA", { from: account_polymath }), + "tx revert -> failed because ticker doesn't exist in the polymath ecosystem" + ); + }); + + it("Should successfully remove the ticker from the polymath ecosystem", async () => { + let tx = await I_STRProxied.removeTicker(symbol2, { from: account_polymath }); + assert.equal(tx.logs[0].args._ticker, symbol2, "Ticker doesn't get deleted successfully"); + }); + }); + + describe(" Test cases of the registerTicker", async () => { + it("Should register the ticker 1", async () => { + await I_PolyToken.getTokens(new BN(web3.utils.toWei("1600")), account_temp); + await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("1600")), { from: account_temp }); + let tx = await I_STRProxied.registerTicker(account_temp, "TOK1", "0x0", { from: account_temp }); + assert.equal(tx.logs[0].args._owner, account_temp, `Owner should be the ${account_temp}`); + assert.equal(tx.logs[0].args._ticker, "TOK1", `Symbol should be TOK1`); + console.log((await I_Getter.getTickersByOwner.call(account_temp)).map(x => web3.utils.toUtf8(x))); + }); + + it("Should register the ticker 2", async () => { + await I_PolyToken.getTokens(new BN(web3.utils.toWei("1600")), account_temp); + await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("1600")), { from: account_temp }); + let tx = await I_STRProxied.registerTicker(account_temp, "TOK2", "0x0", { from: account_temp }); + assert.equal(tx.logs[0].args._owner, account_temp, `Owner should be the ${account_temp}`); + assert.equal(tx.logs[0].args._ticker, "TOK2", `Symbol should be TOK2`); + console.log((await I_Getter.getTickersByOwner.call(account_temp)).map(x => web3.utils.toUtf8(x))); + }); + + it("Should register the ticker 3", async () => { + await I_PolyToken.getTokens(new BN(web3.utils.toWei("1600")), account_temp); + await I_PolyToken.approve(I_STRProxied.address, new BN(web3.utils.toWei("1600")), { from: account_temp }); + let tx = await I_STRProxied.registerTicker(account_temp, "TOK3", "0x0", { from: account_temp }); + assert.equal(tx.logs[0].args._owner, account_temp, `Owner should be the ${account_temp}`); + assert.equal(tx.logs[0].args._ticker, "TOK3", `Symbol should be TOK3`); + console.log((await I_Getter.getTickersByOwner.call(account_temp)).map(x => web3.utils.toUtf8(x))); + }); + + it("Should successfully remove the ticker 2", async () => { + let tx = await I_STRProxied.removeTicker("TOK2", { from: account_polymath }); + assert.equal(tx.logs[0].args._ticker, "TOK2", "Ticker doesn't get deleted successfully"); + console.log((await I_Getter.getTickersByOwner.call(account_temp)).map(x => web3.utils.toUtf8(x))); + }); + + it("Should modify ticker 1", async () => { + currentTime = new BN(await latestTime()); + let tx = await I_STRProxied.modifyTicker( + account_temp, + "TOK1", + "TOKEN 1", + currentTime, + currentTime.add(new BN(duration.minutes(10))), + false, + { from: account_polymath } + ); + assert.equal(tx.logs[0].args._owner, account_temp, `Should be equal to the ${account_temp}`); + assert.equal(tx.logs[0].args._ticker, "TOK1", "Should be equal to TOK1"); + assert.equal(tx.logs[0].args._name, "TOKEN 1", "Should be equal to TOKEN 1"); + console.log((await I_Getter.getTickersByOwner.call(account_temp)).map(x => web3.utils.toUtf8(x))); + }); + + it("Should modify ticker 3", async () => { + let tx = await I_STRProxied.modifyTicker( + account_temp, + "TOK3", + "TOKEN 3", + currentTime, + currentTime.add(new BN(duration.minutes(10))), + false, + { from: account_polymath } + ); + assert.equal(tx.logs[0].args._owner, account_temp, `Should be equal to the ${account_temp}`); + assert.equal(tx.logs[0].args._ticker, "TOK3", "Should be equal to TOK3"); + assert.equal(tx.logs[0].args._name, "TOKEN 3", "Should be equal to TOKEN 3"); + console.log((await I_Getter.getTickersByOwner.call(account_temp)).map(x => web3.utils.toUtf8(x))); + }); + }); + describe("Test cases for IRegistry functionality", async () => { + describe("Test cases for reclaiming funds", async () => { + it("Should successfully reclaim POLY tokens -- fail because token address will be 0x", async () => { + I_PolyToken.transfer(I_STRProxied.address, new BN(web3.utils.toWei("1")), { from: token_owner }); + await catchRevert(I_STRProxied.reclaimERC20(address_zero, { from: account_polymath })); + }); + + it("Should successfully reclaim POLY tokens -- not authorised", async () => { + await catchRevert(I_STRProxied.reclaimERC20(I_PolyToken.address, { from: account_temp })); + }); + + it("Should successfully reclaim POLY tokens", async () => { + let bal1 = await I_PolyToken.balanceOf.call(account_polymath); + await I_STRProxied.reclaimERC20(I_PolyToken.address, { from: account_polymath }); + let bal2 = await I_PolyToken.balanceOf.call(account_polymath); + assert.isAtLeast( + bal2.div(new BN(10).pow(new BN(18))).toNumber(), + bal2.div(new BN(10).pow(new BN(18))).toNumber() + ); + }); + }); + + describe("Test cases for pausing the contract", async () => { + it("Should fail to pause if msg.sender is not owner", async () => { + await catchRevert(I_STRProxied.pause({ from: account_temp }), "tx revert -> msg.sender should be account_polymath"); + }); + + it("Should successfully pause the contract", async () => { + await I_STRProxied.pause({ from: account_polymath }); + let status = await I_STRProxied.getBoolValue.call(web3.utils.soliditySha3("paused")); + assert.isOk(status); + }); + + it("Should fail to unpause if msg.sender is not owner", async () => { + await catchRevert(I_STRProxied.unpause({ from: account_temp }), "tx revert -> msg.sender should be account_polymath"); + }); + + it("Should successfully unpause the contract", async () => { + await I_STRProxied.unpause({ from: account_polymath }); + let status = await I_STRProxied.getBoolValue.call(web3.utils.soliditySha3("paused")); + assert.isNotOk(status); + }); + }); + + describe("Test cases for the setProtocolVersion", async () => { + it("Should successfully change the protocolVersion -- failed because of bad owner", async () => { + await catchRevert(I_STRProxied.setProtocolVersion(accounts[8], 5, 6, 7, { from: account_temp })); + }); + + it("Should successfully change the protocolVersion -- failed because factory address is 0x", async () => { + await catchRevert( + I_STRProxied.setProtocolVersion(address_zero, 5, 6, 7, { from: account_polymath }) + ); + }); + + it("Should successfully change the protocolVersion -- not a valid vesrion", async () => { + await catchRevert(I_STRProxied.setProtocolVersion(accounts[8], new BN(0), new BN(0), new BN(0), { from: account_polymath })); + }); + + it("Should successfully change the protocolVersion -- fail in second attempt because of invalid version", async () => { + let snap_Id = await takeSnapshot(); + await I_STRProxied.setProtocolVersion(accounts[8], 3, 1, 1, { from: account_polymath }); + await catchRevert(I_STRProxied.setProtocolVersion(accounts[8], 1, 3, 1, { from: account_polymath })); + await revertToSnapshot(snap_Id); + }); + }); + + describe("Test cases for the transferOwnership", async () => { + it("Should fail to transfer the ownership -- not authorised", async () => { + await catchRevert(I_STRProxied.transferOwnership(account_temp, { from: account_issuer })); + }); + + it("Should fail to transfer the ownership -- 0x address is not allowed", async () => { + await catchRevert(I_STRProxied.transferOwnership(address_zero, { from: account_polymath })); + }); + + it("Should successfully transfer the ownership of the STR", async () => { + let tx = await I_STRProxied.transferOwnership(account_temp, { from: account_polymath }); + assert.equal(tx.logs[0].args.previousOwner, account_polymath); + assert.equal(tx.logs[0].args.newOwner, account_temp); + }); + }); + }); +}); From dff1be7f93a639fd67852f02ca69c30f9cc1ce6c Mon Sep 17 00:00:00 2001 From: satyam Date: Fri, 22 Feb 2019 15:31:44 +0530 Subject: [PATCH 4/6] bump the version of ST --- test/n_security_token_registry.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/n_security_token_registry.js b/test/n_security_token_registry.js index 9e08bb514..b81510e7e 100644 --- a/test/n_security_token_registry.js +++ b/test/n_security_token_registry.js @@ -1119,7 +1119,7 @@ contract("SecurityTokenRegistry", async (accounts) => { let data = await I_Getter.getSecurityTokenData.call(I_SecurityToken.address); assert.equal(data[0], symbol); assert.equal(data[1], token_owner); - assert.equal(data[4][0], 2); + assert.equal(data[4][0], 3); assert.equal(data[4][1], 0); assert.equal(data[4][2], 0); }); From 14e828a0e0de302c27d8bc9ba42605fa7811a1c3 Mon Sep 17 00:00:00 2001 From: satyam Date: Thu, 28 Feb 2019 16:39:14 +0530 Subject: [PATCH 5/6] add the protocolVersion in the event --- contracts/SecurityTokenRegistry.sol | 46 ++++++++++++++++--- .../interfaces/ISecurityTokenRegistry.sol | 27 +++++++---- test/n_security_token_registry.js | 16 +++---- 3 files changed, 67 insertions(+), 22 deletions(-) diff --git a/contracts/SecurityTokenRegistry.sol b/contracts/SecurityTokenRegistry.sol index a2dabe2b6..d93b820a9 100644 --- a/contracts/SecurityTokenRegistry.sol +++ b/contracts/SecurityTokenRegistry.sol @@ -104,7 +104,8 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { address _registrant, bool _fromAdmin, uint256 _usdFee, - uint256 _polyFee + uint256 _polyFee, + uint256 _protocolVersion ); // Emit after ticker registration event RegisterTicker( @@ -517,7 +518,16 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { _deployToken(_name, ticker, _tokenDetails, msg.sender, _divisible, protocolVersion); } - function _deployToken(string memory _name, string memory _ticker, string memory _tokenDetails, address _issuer, bool _divisible, uint256 _protocolVersion) internal { + function _deployToken( + string memory _name, + string memory _ticker, + string memory _tokenDetails, + address _issuer, + bool _divisible, + uint256 _protocolVersion + ) + internal + { (uint256 _usdFee, uint256 _polyFee) = _takeFee(STLAUNCHFEE); address newSecurityTokenAddress = ISTFactory(getAddressValue(Encoder.getKey("protocolVersionST", _protocolVersion))).deployToken( _name, @@ -533,7 +543,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { _storeSecurityTokenData(newSecurityTokenAddress, _ticker, _tokenDetails, now); set(Encoder.getKey("tickerToSecurityToken", _ticker), newSecurityTokenAddress); /*solium-disable-next-line security/no-block-members*/ - emit NewSecurityToken(_ticker, _name, newSecurityTokenAddress, msg.sender, now, msg.sender, false, _usdFee, _polyFee); + _emitSecurityTokenEvent(_ticker, _name, newSecurityTokenAddress, msg.sender, now, msg.sender, false, _usdFee, _polyFee, _protocolVersion); } /** @@ -544,6 +554,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { * @param _securityToken is the address of the securityToken * @param _tokenDetails is the off-chain details of the token * @param _deployedAt is the timestamp at which the security token is deployed + * @param _protocolVersion Version of securityToken contract */ function modifySecurityToken( string calldata _name, @@ -551,11 +562,12 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { address _owner, address _securityToken, string calldata _tokenDetails, - uint256 _deployedAt + uint256 _deployedAt, + uint256 _protocolVersion ) external onlyOwner - { + { require(bytes(_name).length > 0 && bytes(_ticker).length > 0, "Bad data"); require(bytes(_ticker).length <= 10, "Bad ticker"); require(_deployedAt != 0 && _owner != address(0), "Bad data"); @@ -571,7 +583,29 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { set(Encoder.getKey("tickerToSecurityToken", ticker), _securityToken); _modifyTicker(_owner, ticker, _name, registrationTime, expiryTime, true); _storeSecurityTokenData(_securityToken, ticker, _tokenDetails, _deployedAt); - emit NewSecurityToken(ticker, _name, _securityToken, _owner, _deployedAt, msg.sender, true, uint256(0), uint256(0)); + _emitSecurityTokenEvent( + ticker, _name, _securityToken, _owner, _deployedAt, msg.sender, true, uint256(0), uint256(0), + (_protocolVersion == uint256(0) ? getUintValue(Encoder.getKey("latestVersion")) : _protocolVersion) + ); + } + + function _emitSecurityTokenEvent( + string memory _ticker, + string memory _name, + address _securityToken, + address _owner, + uint256 _addedAt, + address _registrant, + bool _fromAdmin, + uint256 _usdFee, + uint256 _polyFee, + uint256 _protocolVersion + ) + internal + { + emit NewSecurityToken( + _ticker, _name, _securityToken, _owner, _addedAt, _registrant, _fromAdmin, _usdFee, _polyFee, _protocolVersion + ); } /** diff --git a/contracts/interfaces/ISecurityTokenRegistry.sol b/contracts/interfaces/ISecurityTokenRegistry.sol index ce5486860..23c18f18e 100644 --- a/contracts/interfaces/ISecurityTokenRegistry.sol +++ b/contracts/interfaces/ISecurityTokenRegistry.sol @@ -5,13 +5,22 @@ pragma solidity ^0.5.0; */ interface ISecurityTokenRegistry { /** - * @notice Creates a new Security Token and saves it to the registry - * @param _name Name of the token - * @param _ticker Ticker ticker of the security token - * @param _tokenDetails Off-chain details of the token - * @param _divisible Whether the token is divisible or not - */ - function generateSecurityToken(string calldata _name, string calldata _ticker, string calldata _tokenDetails, bool _divisible) external; + * @notice Deploys an instance of a new Security Token and records it to the registry + * @param _name is the name of the token + * @param _ticker is the ticker symbol of the security token + * @param _tokenDetails is the off-chain details of the token + * @param _divisible is whether or not the token is divisible + * @param _protocolVersion Version of securityToken contract + * - `_protocolVersion` is the packed value of uin8[3] array (it will be calculated offchain) + * - if _protocolVersion == 0 then latest version of securityToken will be generated + */ + function generateSecurityToken( + string calldata _name, + string calldata _ticker, + string calldata _tokenDetails, + bool _divisible, + uint256 _protocolVersion + ) external; /** * @notice Adds a new custom Security Token and saves it to the registry. (Token should follow the ISecurityToken interface) @@ -21,6 +30,7 @@ interface ISecurityTokenRegistry { * @param _securityToken Address of the securityToken * @param _tokenDetails Off-chain details of the token * @param _deployedAt Timestamp at which security token comes deployed on the ethereum blockchain + * @param _protocolVersion Version of the protocol */ function modifySecurityToken( string calldata _name, @@ -28,7 +38,8 @@ interface ISecurityTokenRegistry { address _owner, address _securityToken, string calldata _tokenDetails, - uint256 _deployedAt + uint256 _deployedAt, + uint256 _protocolVersion ) external; diff --git a/test/n_security_token_registry.js b/test/n_security_token_registry.js index b81510e7e..25cf5c281 100644 --- a/test/n_security_token_registry.js +++ b/test/n_security_token_registry.js @@ -755,7 +755,7 @@ contract("SecurityTokenRegistry", async (accounts) => { describe("Generate custom tokens", async () => { it("Should fail if msg.sender is not polymath", async () => { await catchRevert( - I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, { + I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, 0, { from: account_delegate }), "tx revert -> msg.sender is not polymath account" @@ -764,7 +764,7 @@ contract("SecurityTokenRegistry", async (accounts) => { it("Should fail to genrate the custom security token -- ticker length is greater than 10 chars", async () => { await catchRevert( - I_STRProxied.modifySecurityToken("LOGAN", "LOGLOGLOGLOG", account_temp, dummy_token, "I am custom ST", currentTime, { + I_STRProxied.modifySecurityToken("LOGAN", "LOGLOGLOGLOG", account_temp, dummy_token, "I am custom ST", currentTime, 0, { from: account_polymath }), "tx revert -> ticker length is greater than 10 chars" @@ -773,7 +773,7 @@ contract("SecurityTokenRegistry", async (accounts) => { it("Should fail to generate the custom security token -- name should not be 0 length ", async () => { await catchRevert( - I_STRProxied.modifySecurityToken("", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, { + I_STRProxied.modifySecurityToken("", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, 0, { from: account_polymath }), "tx revert -> name should not be 0 length" @@ -782,7 +782,7 @@ contract("SecurityTokenRegistry", async (accounts) => { it("Should fail if ST address is 0 address", async () => { await catchRevert( - I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, address_zero, "I am custom ST", currentTime, { + I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, address_zero, "I am custom ST", currentTime, 0, { from: account_polymath }), "tx revert -> Security token address is 0" @@ -791,7 +791,7 @@ contract("SecurityTokenRegistry", async (accounts) => { it("Should fail if symbol length is 0", async () => { await catchRevert( - I_STRProxied.modifySecurityToken("", "0x0", account_temp, dummy_token, "I am custom ST", currentTime, { + I_STRProxied.modifySecurityToken("", "0x0", account_temp, dummy_token, "I am custom ST", currentTime, 0, { from: account_polymath }), "tx revert -> zero length of the symbol is not allowed" @@ -800,7 +800,7 @@ contract("SecurityTokenRegistry", async (accounts) => { it("Should fail to generate the custom ST -- deployedAt param is 0", async () => { await catchRevert( - I_STRProxied.modifySecurityToken(name2, symbol2, token_owner, dummy_token, "I am custom ST", new BN(0), { from: account_polymath }), + I_STRProxied.modifySecurityToken(name2, symbol2, token_owner, dummy_token, "I am custom ST", new BN(0), 0, { from: account_polymath }), "tx revert -> because deployedAt param is 0" ); }); @@ -815,7 +815,7 @@ contract("SecurityTokenRegistry", async (accounts) => { tickersListArray = await I_Getter.getTickersByOwner.call(account_temp); console.log(tickersListArray); // Generating the ST - let tx = await I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, { + let tx = await I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, 0, { from: account_polymath }); tickersListArray = await I_Getter.getTickersByOwner.call(account_temp); @@ -837,7 +837,7 @@ contract("SecurityTokenRegistry", async (accounts) => { // await catchRevert(I_STRProxied.modifySecurityToken("LOGAN2", "LOG2", account_temp, dummy_token, "I am custom ST", await latestTime(), {from: account_polymath})); // await I_STRProxied.modifyTicker(account_temp, "LOG2", "LOGAN2", await latestTime(), currentTime.add(new BN(duration.days(10))), false, {from: account_polymath}); // await increaseTime(duration.days(1)); - let tx = await I_STRProxied.modifySecurityToken("LOGAN2", "LOG2", account_temp, dummy_token, "I am custom ST", currentTime, { + let tx = await I_STRProxied.modifySecurityToken("LOGAN2", "LOG2", account_temp, dummy_token, "I am custom ST", currentTime, 0, { from: account_polymath }); assert.equal(tx.logs[1].args._ticker, "LOG2", "Symbol should match with the registered symbol"); From c56fb1dd0ec79baeff45c7ac13902097f1c14ca9 Mon Sep 17 00:00:00 2001 From: satyam Date: Fri, 1 Mar 2019 11:15:32 +0530 Subject: [PATCH 6/6] minor fixes in the STR --- CHANGELOG.md | 2 +- contracts/STRGetter.sol | 2 +- contracts/SecurityTokenRegistry.sol | 30 ++++--------------- .../interfaces/ISecurityTokenRegistry.sol | 4 +-- test/n_security_token_registry.js | 22 +++++++------- 5 files changed, 19 insertions(+), 41 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b284759b5..1caec4be2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ All notable changes to this project will be documented in this file. * Migrate all the getters of `SecurityTokenRegsitry.sol` to `STRGetter.sol` contract. * Removed `_polyToken` parameter from `initialize` function in `SecurityTokenRegistry`. * Allows an explicit token factory version to be used during creation of securityToken. -* Rename the `getProtocolVersion()` to `getCurrentProtocolVersion()`. +* Rename the `getProtocolVersion()` to `getLatestProtocolVersion()`. * Return SecurityToken version in the `getSecurityTokenData()` function. ## GeneralTransferManager diff --git a/contracts/STRGetter.sol b/contracts/STRGetter.sol index d995cb196..850820696 100644 --- a/contracts/STRGetter.sol +++ b/contracts/STRGetter.sol @@ -222,7 +222,7 @@ contract STRGetter is EternalStorage { /** * @notice Gets Protocol version */ - function getCurrentProtocolVersion() public view returns(uint8[] memory) { + function getLatestProtocolVersion() public view returns(uint8[] memory) { return VersionUtils.unpack(uint24(getUintValue(Encoder.getKey("latestVersion")))); } diff --git a/contracts/SecurityTokenRegistry.sol b/contracts/SecurityTokenRegistry.sol index d93b820a9..4cff717f0 100644 --- a/contracts/SecurityTokenRegistry.sol +++ b/contracts/SecurityTokenRegistry.sol @@ -543,7 +543,9 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { _storeSecurityTokenData(newSecurityTokenAddress, _ticker, _tokenDetails, now); set(Encoder.getKey("tickerToSecurityToken", _ticker), newSecurityTokenAddress); /*solium-disable-next-line security/no-block-members*/ - _emitSecurityTokenEvent(_ticker, _name, newSecurityTokenAddress, msg.sender, now, msg.sender, false, _usdFee, _polyFee, _protocolVersion); + emit NewSecurityToken( + _ticker, _name, newSecurityTokenAddress, msg.sender, now, msg.sender, false, _usdFee, _polyFee, _protocolVersion + ); } /** @@ -554,7 +556,6 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { * @param _securityToken is the address of the securityToken * @param _tokenDetails is the off-chain details of the token * @param _deployedAt is the timestamp at which the security token is deployed - * @param _protocolVersion Version of securityToken contract */ function modifySecurityToken( string calldata _name, @@ -562,8 +563,7 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { address _owner, address _securityToken, string calldata _tokenDetails, - uint256 _deployedAt, - uint256 _protocolVersion + uint256 _deployedAt ) external onlyOwner @@ -583,28 +583,8 @@ contract SecurityTokenRegistry is EternalStorage, Proxy { set(Encoder.getKey("tickerToSecurityToken", ticker), _securityToken); _modifyTicker(_owner, ticker, _name, registrationTime, expiryTime, true); _storeSecurityTokenData(_securityToken, ticker, _tokenDetails, _deployedAt); - _emitSecurityTokenEvent( - ticker, _name, _securityToken, _owner, _deployedAt, msg.sender, true, uint256(0), uint256(0), - (_protocolVersion == uint256(0) ? getUintValue(Encoder.getKey("latestVersion")) : _protocolVersion) - ); - } - - function _emitSecurityTokenEvent( - string memory _ticker, - string memory _name, - address _securityToken, - address _owner, - uint256 _addedAt, - address _registrant, - bool _fromAdmin, - uint256 _usdFee, - uint256 _polyFee, - uint256 _protocolVersion - ) - internal - { emit NewSecurityToken( - _ticker, _name, _securityToken, _owner, _addedAt, _registrant, _fromAdmin, _usdFee, _polyFee, _protocolVersion + ticker, _name, _securityToken, _owner, _deployedAt, msg.sender, true, uint256(0), uint256(0), 0 ); } diff --git a/contracts/interfaces/ISecurityTokenRegistry.sol b/contracts/interfaces/ISecurityTokenRegistry.sol index 23c18f18e..13b126f4b 100644 --- a/contracts/interfaces/ISecurityTokenRegistry.sol +++ b/contracts/interfaces/ISecurityTokenRegistry.sol @@ -30,7 +30,6 @@ interface ISecurityTokenRegistry { * @param _securityToken Address of the securityToken * @param _tokenDetails Off-chain details of the token * @param _deployedAt Timestamp at which security token comes deployed on the ethereum blockchain - * @param _protocolVersion Version of the protocol */ function modifySecurityToken( string calldata _name, @@ -38,8 +37,7 @@ interface ISecurityTokenRegistry { address _owner, address _securityToken, string calldata _tokenDetails, - uint256 _deployedAt, - uint256 _protocolVersion + uint256 _deployedAt ) external; diff --git a/test/n_security_token_registry.js b/test/n_security_token_registry.js index 25cf5c281..b6fcbc4ce 100644 --- a/test/n_security_token_registry.js +++ b/test/n_security_token_registry.js @@ -666,7 +666,7 @@ contract("SecurityTokenRegistry", async (accounts) => { address_zero, "STFactory002 contract was not deployed" ); - let _protocol = await I_Getter.getCurrentProtocolVersion.call(); + let _protocol = await I_Getter.getLatestProtocolVersion.call(); assert.equal(_protocol[0], 2); assert.equal(_protocol[1], 0); assert.equal(_protocol[2], 0); @@ -681,12 +681,12 @@ contract("SecurityTokenRegistry", async (accounts) => { it("Should change the protocol version", async() => { await I_STRProxied.setProtocolVersion(I_STFactory002.address, new BN(2), new BN(2), new BN(0), { from: account_polymath }); - let _protocol = await I_Getter.getCurrentProtocolVersion.call(); + let _protocol = await I_Getter.getLatestProtocolVersion.call(); assert.equal(_protocol[0], 2); assert.equal(_protocol[1], 2); assert.equal(_protocol[2], 0); await I_STRProxied.setProtocolVersion(I_STFactory.address, new BN(3), new BN(0), new BN(0), { from: account_polymath}); - _protocol = await I_Getter.getCurrentProtocolVersion.call(); + _protocol = await I_Getter.getLatestProtocolVersion.call(); assert.equal(_protocol[0], 3); assert.equal(_protocol[1], 0); assert.equal(_protocol[2], 0); @@ -755,7 +755,7 @@ contract("SecurityTokenRegistry", async (accounts) => { describe("Generate custom tokens", async () => { it("Should fail if msg.sender is not polymath", async () => { await catchRevert( - I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, 0, { + I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, { from: account_delegate }), "tx revert -> msg.sender is not polymath account" @@ -764,7 +764,7 @@ contract("SecurityTokenRegistry", async (accounts) => { it("Should fail to genrate the custom security token -- ticker length is greater than 10 chars", async () => { await catchRevert( - I_STRProxied.modifySecurityToken("LOGAN", "LOGLOGLOGLOG", account_temp, dummy_token, "I am custom ST", currentTime, 0, { + I_STRProxied.modifySecurityToken("LOGAN", "LOGLOGLOGLOG", account_temp, dummy_token, "I am custom ST", currentTime, { from: account_polymath }), "tx revert -> ticker length is greater than 10 chars" @@ -773,7 +773,7 @@ contract("SecurityTokenRegistry", async (accounts) => { it("Should fail to generate the custom security token -- name should not be 0 length ", async () => { await catchRevert( - I_STRProxied.modifySecurityToken("", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, 0, { + I_STRProxied.modifySecurityToken("", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, { from: account_polymath }), "tx revert -> name should not be 0 length" @@ -782,7 +782,7 @@ contract("SecurityTokenRegistry", async (accounts) => { it("Should fail if ST address is 0 address", async () => { await catchRevert( - I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, address_zero, "I am custom ST", currentTime, 0, { + I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, address_zero, "I am custom ST", currentTime, { from: account_polymath }), "tx revert -> Security token address is 0" @@ -791,7 +791,7 @@ contract("SecurityTokenRegistry", async (accounts) => { it("Should fail if symbol length is 0", async () => { await catchRevert( - I_STRProxied.modifySecurityToken("", "0x0", account_temp, dummy_token, "I am custom ST", currentTime, 0, { + I_STRProxied.modifySecurityToken("", "0x0", account_temp, dummy_token, "I am custom ST", currentTime, { from: account_polymath }), "tx revert -> zero length of the symbol is not allowed" @@ -800,7 +800,7 @@ contract("SecurityTokenRegistry", async (accounts) => { it("Should fail to generate the custom ST -- deployedAt param is 0", async () => { await catchRevert( - I_STRProxied.modifySecurityToken(name2, symbol2, token_owner, dummy_token, "I am custom ST", new BN(0), 0, { from: account_polymath }), + I_STRProxied.modifySecurityToken(name2, symbol2, token_owner, dummy_token, "I am custom ST", new BN(0), { from: account_polymath }), "tx revert -> because deployedAt param is 0" ); }); @@ -815,7 +815,7 @@ contract("SecurityTokenRegistry", async (accounts) => { tickersListArray = await I_Getter.getTickersByOwner.call(account_temp); console.log(tickersListArray); // Generating the ST - let tx = await I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, 0, { + let tx = await I_STRProxied.modifySecurityToken("LOGAN", "LOG", account_temp, dummy_token, "I am custom ST", currentTime, { from: account_polymath }); tickersListArray = await I_Getter.getTickersByOwner.call(account_temp); @@ -837,7 +837,7 @@ contract("SecurityTokenRegistry", async (accounts) => { // await catchRevert(I_STRProxied.modifySecurityToken("LOGAN2", "LOG2", account_temp, dummy_token, "I am custom ST", await latestTime(), {from: account_polymath})); // await I_STRProxied.modifyTicker(account_temp, "LOG2", "LOGAN2", await latestTime(), currentTime.add(new BN(duration.days(10))), false, {from: account_polymath}); // await increaseTime(duration.days(1)); - let tx = await I_STRProxied.modifySecurityToken("LOGAN2", "LOG2", account_temp, dummy_token, "I am custom ST", currentTime, 0, { + let tx = await I_STRProxied.modifySecurityToken("LOGAN2", "LOG2", account_temp, dummy_token, "I am custom ST", currentTime, { from: account_polymath }); assert.equal(tx.logs[1].args._ticker, "LOG2", "Symbol should match with the registered symbol");