From 32a676ba6ca9044e47c1da06e9c0dbbd8a80dc7c Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Mon, 18 Nov 2019 13:44:58 -0800 Subject: [PATCH 01/21] fix: createEtherDividendDistribution refactor naming and object --- .../__tests__/CreateEtherDividendDistribution.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/procedures/__tests__/CreateEtherDividendDistribution.ts b/src/procedures/__tests__/CreateEtherDividendDistribution.ts index a00883b..b7991df 100644 --- a/src/procedures/__tests__/CreateEtherDividendDistribution.ts +++ b/src/procedures/__tests__/CreateEtherDividendDistribution.ts @@ -143,14 +143,12 @@ describe('CreateEtherDividendDistribution', () => { test('should return the newly created eth dividend distribution', async () => { const dividendObject = { - permissions: { - securityTokenId: () => 'Id', - index: () => 1, - }, + securityTokenId: () => 'Id', + index: () => 1, }; const fetchStub = dividendDistributionFactoryMock.mock('fetch', dividendObject); - const findEvents = ImportMock.mockFunction(utilsModule, 'findEvents', [ + const findEventsStub = ImportMock.mockFunction(utilsModule, 'findEvents', [ { args: { _dividendIndex: new BigNumber(1), @@ -163,7 +161,7 @@ describe('CreateEtherDividendDistribution', () => { await resolver.run({} as TransactionReceiptWithDecodedLogs); await expect(resolver.result).toEqual(dividendObject); expect(fetchStub.callCount).toBe(1); - expect(findEvents.callCount).toBe(1); + expect(findEventsStub.callCount).toBe(1); }); test('should throw if eth dividends manager has not been enabled', async () => { From 62cacc63c94bcd0ce5d17c1a8ca934e904e9e354 Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Tue, 19 Nov 2019 08:16:59 -0800 Subject: [PATCH 02/21] fix: initial review issues --- src/procedures/__tests__/LaunchCappedSto.ts | 20 +++++---- .../__tests__/LaunchUsdTieredSto.ts | 20 +++++---- src/procedures/__tests__/MintTokens.ts | 12 +++--- .../__tests__/ModifyShareholderData.ts | 43 ++++++++++--------- src/procedures/__tests__/PauseSto.ts | 16 +++---- 5 files changed, 59 insertions(+), 52 deletions(-) diff --git a/src/procedures/__tests__/LaunchCappedSto.ts b/src/procedures/__tests__/LaunchCappedSto.ts index f8b85e6..46fec8d 100644 --- a/src/procedures/__tests__/LaunchCappedSto.ts +++ b/src/procedures/__tests__/LaunchCappedSto.ts @@ -33,6 +33,11 @@ const params: LaunchCappedStoProcedureArgs = { treasuryWallet: '0x7777777777777777777777777777777777777777', }; +const currentWallet = '0x8888888888888888888888888888888888888888'; +const securityTokenAddress = '0x9999999999999999999999999999999999999999'; +const polyTokenAddress = '0x5555555555555555555555555555555555555555'; +const moduleFactoryAddress = '0x4444444444444444444444444444444444444444'; + describe('LaunchCappedSto', () => { let target: LaunchCappedSto; let contextMock: MockManager; @@ -83,10 +88,7 @@ describe('LaunchCappedSto', () => { const factoryMockSetup = mockFactories(); factoryMockSetup.cappedStoFactory = cappedStoFactoryMock.getMockInstance(); contextMock.set('factories', factoryMockSetup); - contextMock.set( - 'currentWallet', - new Wallet({ address: () => Promise.resolve(params.storageWallet) }) - ); + contextMock.set('currentWallet', new Wallet({ address: () => Promise.resolve(currentWallet) })); polyTokenMock = ImportMock.mockClass(contractWrappersModule, 'PolyToken'); polyTokenMock.mock('balanceOf', Promise.resolve(new BigNumber(2))); @@ -95,7 +97,7 @@ describe('LaunchCappedSto', () => { wrappersMock.set('polyToken', polyTokenMock.getMockInstance()); wrappersMock.mock('isTestnet', Promise.resolve(false)); - wrappersMock.mock('getModuleFactoryAddress', Promise.resolve(params.treasuryWallet)); + wrappersMock.mock('getModuleFactoryAddress', moduleFactoryAddress); // Instantiate LaunchCappedSto target = new LaunchCappedSto(params, contextMock.getMockInstance()); @@ -164,11 +166,11 @@ describe('LaunchCappedSto', () => { ); }); - test('should return the capped sto', async () => { + test('should return the capped sto object information', async () => { const stoObject = { - securityTokenId: () => Promise.resolve(params.symbol), - stoType: () => Promise.resolve(StoType.Capped), - address: () => Promise.resolve(params.storageWallet), + securityTokenId: params.symbol, + stoType: StoType.Capped, + address: securityTokenAddress, }; const fetchStub = cappedStoFactoryMock.mock('fetch', stoObject); const moduleAddress = '0x3333333333333333333333333333333333333333'; diff --git a/src/procedures/__tests__/LaunchUsdTieredSto.ts b/src/procedures/__tests__/LaunchUsdTieredSto.ts index 66c094d..ef6f534 100644 --- a/src/procedures/__tests__/LaunchUsdTieredSto.ts +++ b/src/procedures/__tests__/LaunchUsdTieredSto.ts @@ -40,6 +40,11 @@ const params: LaunchUsdTieredStoProcedureArgs = { usdTokenAddresses: ['0x7777777777777777777777777777777777777777'], }; +const currentWallet = '0x8888888888888888888888888888888888888888'; +const securityTokenAddress = '0x9999999999999999999999999999999999999999'; +const polyTokenAddress = '0x5555555555555555555555555555555555555555'; +const moduleFactoryAddress = '0x4444444444444444444444444444444444444444'; + describe('LaunchUsdTieredSto', () => { let target: LaunchUsdTieredSto; let contextMock: MockManager; @@ -100,10 +105,7 @@ describe('LaunchUsdTieredSto', () => { const factoryMockSetup = mockFactories(); factoryMockSetup.usdTieredStoFactory = usdTieredStoFactoryMock.getMockInstance(); contextMock.set('factories', factoryMockSetup); - contextMock.set( - 'currentWallet', - new Wallet({ address: () => Promise.resolve(params.storageWallet) }) - ); + contextMock.set('currentWallet', new Wallet({ address: () => Promise.resolve(currentWallet) })); polyTokenMock = ImportMock.mockClass(contractWrappersModule, 'PolyToken'); polyTokenMock.mock('balanceOf', Promise.resolve(new BigNumber(2))); @@ -114,7 +116,7 @@ describe('LaunchUsdTieredSto', () => { getAttachedModulesFactoryAddressStub = wrappersMock.mock( 'getModuleFactoryAddress', - Promise.resolve(params.treasuryWallet) + Promise.resolve(moduleFactoryAddress) ); // Instantiate LaunchUsdTieredSto @@ -183,11 +185,11 @@ describe('LaunchUsdTieredSto', () => { ); }); - test('should return the usd tiered sto', async () => { + test('should return the usd tiered sto object information', async () => { const stoObject = { - securityTokenId: () => Promise.resolve(params.symbol), - stoType: () => Promise.resolve(StoType.UsdTiered), - address: () => Promise.resolve(params.storageWallet), + securityTokenId: params.symbol, + stoType: StoType.UsdTiered, + address: securityTokenAddress, }; const fetchStub = usdTieredStoFactoryMock.mock('fetch', stoObject); const moduleAddress = '0x3333333333333333333333333333333333333333'; diff --git a/src/procedures/__tests__/MintTokens.ts b/src/procedures/__tests__/MintTokens.ts index fd2dde5..314c279 100644 --- a/src/procedures/__tests__/MintTokens.ts +++ b/src/procedures/__tests__/MintTokens.ts @@ -19,6 +19,8 @@ import { mockFactories } from '~/testUtils/mockFactories'; import { Shareholder } from '~/entities'; import { SecurityToken } from '~/entities/SecurityToken/SecurityToken'; +const cloneDeep = require('lodash/clonedeep'); + const securityTokenId = 'ST ID'; const testAddress = '0x6666666666666666666666666666666666666666'; const testAddress2 = '0x9999999999999999999999999999999999999999'; @@ -157,17 +159,17 @@ describe('MintTokens', () => { expect(addProcedureSpy.callCount).toEqual(1); }); - test('should return the minted tokens shareholders object', async () => { + test('should return an array of the shareholders for whom tokens were minted', async () => { const shareholderObject = { - securityTokenId: () => Promise.resolve(params.symbol), - address: () => Promise.resolve(testAddress), + securityTokenId: params.symbol, + address: testAddress, }; const fetchStub = shareholderFactoryMock.mock('fetch', shareholderObject); // Real call const resolver = await target.prepareTransactions(); await resolver.run({} as TransactionReceiptWithDecodedLogs); - await expect(resolver.result).toEqual([shareholderObject, shareholderObject]); + expect(resolver.result).toEqual([shareholderObject, shareholderObject]); // Verification for fetch expect( @@ -221,7 +223,7 @@ describe('MintTokens', () => { }); test('should throw an error for an expired Kyc', async () => { - const expiredParams = params; + const expiredParams = cloneDeep(params); expiredParams.mintingData[0].shareholderData = { canSendAfter: new Date(Date.now()), canReceiveAfter: new Date(2035, 1), diff --git a/src/procedures/__tests__/ModifyShareholderData.ts b/src/procedures/__tests__/ModifyShareholderData.ts index 8b10287..317f311 100644 --- a/src/procedures/__tests__/ModifyShareholderData.ts +++ b/src/procedures/__tests__/ModifyShareholderData.ts @@ -2,7 +2,7 @@ import { ImportMock, MockManager, StaticMockManager } from 'ts-mock-imports'; import { spy, restore } from 'sinon'; import * as contractWrappersModule from '@polymathnetwork/contract-wrappers'; import { TransactionReceiptWithDecodedLogs } from 'ethereum-protocol'; -import { BigNumber } from '@polymathnetwork/contract-wrappers'; +import { BigNumber, GeneralTransferManager_3_0_0 } from '@polymathnetwork/contract-wrappers'; import { ModifyShareholderData } from '../../procedures/ModifyShareholderData'; import { Procedure } from '~/procedures/Procedure'; import { ErrorCode, ProcedureType } from '~/types'; @@ -18,6 +18,8 @@ import { SecurityToken } from '~/entities/SecurityToken/SecurityToken'; import { PolymathError } from '~/PolymathError'; import { Shareholder } from '~/entities'; +const cloneDeep = require('lodash/clonedeep'); + const testAddress = '0x6666666666666666666666666666666666666666'; const testAddress2 = '0x9999999999999999999999999999999999999999'; const oldShareholdersData = [ @@ -79,6 +81,7 @@ describe('ModifyShareholderData', () => { let securityTokenEntityMock: MockManager; let gtmMock: MockManager; + let gtmMockInstance: GeneralTransferManager_3_0_0; const securityTokenId = 'ST ID'; @@ -120,8 +123,8 @@ describe('ModifyShareholderData', () => { contextMock.set('factories', factoryMockSetup); gtmMock = ImportMock.mockClass(contractWrappersModule, 'GeneralTransferManager_3_0_0'); - - wrappersMock.mock('getAttachedModules', Promise.resolve([gtmMock.getMockInstance()])); + gtmMockInstance = gtmMock.getMockInstance(); + wrappersMock.mock('getAttachedModules', [gtmMockInstance]); // Instantiate ModifyShareholderData target = new ModifyShareholderData(params, contextMock.getMockInstance()); @@ -138,27 +141,27 @@ describe('ModifyShareholderData', () => { }); describe('ModifyShareholderData', () => { - test('should add a transaction to the queue to create a new checkpoint', async () => { + test('should add a transaction to the queue to modify the shareholders data', async () => { const addTransactionSpy = spy(target, 'addTransaction'); // Real call await target.prepareTransactions(); // Verifications + expect(addTransactionSpy.getCall(0).calledWith(gtmMockInstance.modifyKYCDataMulti)).toEqual( + true + ); expect( - addTransactionSpy.getCall(0).calledWith(gtmMock.getMockInstance().modifyKYCDataMulti) - ).toEqual(true); - expect( - addTransactionSpy.getCall(1).calledWith(gtmMock.getMockInstance().modifyInvestorFlagMulti) + addTransactionSpy.getCall(1).calledWith(gtmMockInstance.modifyInvestorFlagMulti) ).toEqual(true); expect(addTransactionSpy.callCount).toEqual(2); }); - test('should return the newly created checkpoint', async () => { + test('should return an array of the shareholders which have been modified', async () => { const shareholderObject = { - securityTokenId: () => params.symbol, - address: () => testAddress, + securityTokenId: params.symbol, + address: testAddress, }; - const fetchStub = shareholderFactoryMock.mock('fetch', Promise.resolve(shareholderObject)); + const fetchStub = shareholderFactoryMock.mock('fetch', shareholderObject); // Real call const resolver = await target.prepareTransactions(); @@ -205,7 +208,7 @@ describe('ModifyShareholderData', () => { }); test('should throw if the general transfer manager is not enabled', async () => { - wrappersMock.mock('getAttachedModules', {}); + wrappersMock.mock('getAttachedModules', []); await expect(target.prepareTransactions()).rejects.toThrow( new PolymathError({ code: ErrorCode.ProcedureValidationError, @@ -229,8 +232,8 @@ describe('ModifyShareholderData', () => { ); }); - test('should add a transaction to the queue to create a new checkpoint without changing flags', async () => { - const paramsWithoutFlagsChange = Object.assign({}, params); + test('should add a transaction to the queue to modify shareholder data without changing flags', async () => { + const paramsWithoutFlagsChange = cloneDeep(params); paramsWithoutFlagsChange.shareholderData[0].isAccredited = false; paramsWithoutFlagsChange.shareholderData[1].isAccredited = false; paramsWithoutFlagsChange.shareholderData[0].canBuyFromSto = false; @@ -241,9 +244,9 @@ describe('ModifyShareholderData', () => { // Real call await target.prepareTransactions(); // Verifications - expect( - addTransactionSpy.getCall(0).calledWith(gtmMock.getMockInstance().modifyKYCDataMulti) - ).toEqual(true); + expect(addTransactionSpy.getCall(0).calledWith(gtmMockInstance.modifyKYCDataMulti)).toEqual( + true + ); expect(addTransactionSpy.callCount).toEqual(1); }); @@ -284,8 +287,8 @@ describe('ModifyShareholderData', () => { expect(fetchStub.callCount).toBe(2); }); - test('should throw if there is an invalid epoch time', async () => { - const invalidParams = Object.assign({}, params); + test('should throw if there is an invalid epoch time used', async () => { + const invalidParams = cloneDeep(params); invalidParams.shareholderData[0].kycExpiry = new Date(0); target = new ModifyShareholderData(invalidParams, contextMock.getMockInstance()); await expect(target.prepareTransactions()).rejects.toThrow( diff --git a/src/procedures/__tests__/PauseSto.ts b/src/procedures/__tests__/PauseSto.ts index 67e1e30..b69bb42 100644 --- a/src/procedures/__tests__/PauseSto.ts +++ b/src/procedures/__tests__/PauseSto.ts @@ -28,6 +28,8 @@ const cappedParams: PauseStoProcedureArgs = { stoType: StoType.Capped, }; +const invalidSto = 'InvalidSto'; + describe('PauseSto', () => { let target: PauseSto; let contextMock: MockManager; @@ -154,14 +156,14 @@ describe('PauseSto', () => { { stoAddress: cappedParams.stoAddress, symbol: cappedParams.symbol, - stoType: {} as StoType, + stoType: invalidSto as StoType, }, contextMock.getMockInstance() ); await expect(target.prepareTransactions()).rejects.toThrow( new PolymathError({ code: ErrorCode.ProcedureValidationError, - message: `Invalid STO type ${{}}`, + message: `Invalid STO type ${invalidSto}`, }) ); }); @@ -175,11 +177,9 @@ describe('PauseSto', () => { }) ); }); - }); - describe('should successfully resolve pause sto with cappedSto', () => { - test('should successfully resolve controller transfer', async () => { - const refreshStub = cappedStoFactoryMock.mock('refresh', Promise.resolve(undefined)); + test('should successfully resolve pause sto with capped sto params', async () => { + const refreshStub = cappedStoFactoryMock.mock('refresh', undefined); await pauseStoModule.createPauseStoResolver( factoryMockSetup, cappedParams.symbol, @@ -197,10 +197,8 @@ describe('PauseSto', () => { ).toEqual(true); expect(refreshStub.callCount).toEqual(1); }); - }); - describe('should successfully resolve pause sto with usdtieredSto', () => { - test('should successfully resolve controller transfer', async () => { + test('should successfully resolve pause sto with usd tiered sto params', async () => { target = new PauseSto(usdTieredParams, contextMock.getMockInstance()); const refreshStub = usdTieredStoFactoryMock.mock('refresh', Promise.resolve(undefined)); await pauseStoModule.createPauseStoResolver( From 8172497615e44325b04489d778c8279a69ee0a2e Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Tue, 19 Nov 2019 09:10:50 -0800 Subject: [PATCH 03/21] refactor: use full syntax for imports, not ~ --- src/procedures/__tests__/ApproveErc20.ts | 10 ++++---- .../__tests__/AssignSecurityTokenRole.ts | 10 ++++---- src/procedures/__tests__/AssignStoRole.ts | 6 ++--- .../__tests__/ControllerTransfer.ts | 12 +++++----- src/procedures/__tests__/CreateCheckpoint.ts | 14 +++++------ .../CreateErc20DividendDistribution.ts | 16 ++++++------- .../CreateEtherDividendDistribution.ts | 16 ++++++------- .../__tests__/CreateSecurityToken.ts | 20 ++++++++-------- .../__tests__/EnableDividendManagers.ts | 6 ++--- .../EnableGeneralPermissionManager.ts | 6 ++--- src/procedures/__tests__/LaunchCappedSto.ts | 18 +++++++------- .../__tests__/LaunchUsdTieredSto.ts | 16 ++++++------- src/procedures/__tests__/MintTokens.ts | 24 +++++++++---------- .../__tests__/ModifyShareholderData.ts | 20 ++++++++-------- src/procedures/__tests__/PauseSto.ts | 14 +++++------ .../__tests__/SetDividendsWallet.ts | 16 ++++++------- 16 files changed, 112 insertions(+), 112 deletions(-) diff --git a/src/procedures/__tests__/ApproveErc20.ts b/src/procedures/__tests__/ApproveErc20.ts index d56a84c..2c6c79c 100644 --- a/src/procedures/__tests__/ApproveErc20.ts +++ b/src/procedures/__tests__/ApproveErc20.ts @@ -1,14 +1,14 @@ import { ImportMock, MockManager } from 'ts-mock-imports'; import * as contractWrappersModule from '@polymathnetwork/contract-wrappers'; import { BigNumber } from '@polymathnetwork/contract-wrappers'; -import { SinonStub, stub, spy } from 'sinon'; +import { SinonStub, spy } from 'sinon'; import * as contextModule from '../../Context'; import * as polymathBaseModule from '../../PolymathBase'; import { ApproveErc20 } from '../../procedures/ApproveErc20'; -import { Procedure } from '~/procedures/Procedure'; -import { Wallet } from '~/Wallet'; -import { PolymathError } from '~/PolymathError'; -import { ErrorCode, PolyTransactionTag, ProcedureType } from '~/types'; +import { Procedure } from '../../procedures/Procedure'; +import { Wallet } from '../../Wallet'; +import { PolymathError } from '../../PolymathError'; +import { ErrorCode, PolyTransactionTag, ProcedureType } from '../../types'; const params = { amount: new BigNumber(1), diff --git a/src/procedures/__tests__/AssignSecurityTokenRole.ts b/src/procedures/__tests__/AssignSecurityTokenRole.ts index 665472e..e5147f7 100644 --- a/src/procedures/__tests__/AssignSecurityTokenRole.ts +++ b/src/procedures/__tests__/AssignSecurityTokenRole.ts @@ -6,11 +6,11 @@ import * as contextModule from '../../Context'; import * as wrappersModule from '../../PolymathBase'; import * as tokenFactoryModule from '../../testUtils/MockedTokenFactoryModule'; import { AssignSecurityTokenRole } from '../../procedures/AssignSecurityTokenRole'; -import { Procedure } from '~/procedures/Procedure'; -import { PolymathError } from '~/PolymathError'; -import { ErrorCode, Feature, PolyTransactionTag, SecurityTokenRole } from '~/types'; -import * as securityTokenFactoryModule from '~/entities/factories/SecurityTokenFactory'; -import { mockFactories } from '~/testUtils/mockFactories'; +import { Procedure } from '../Procedure'; +import { PolymathError } from '../../PolymathError'; +import { ErrorCode, Feature, PolyTransactionTag, SecurityTokenRole } from '../../types'; +import * as securityTokenFactoryModule from '../../entities/factories/SecurityTokenFactory'; +import { mockFactories } from '../../testUtils/mockFactories'; const params = { symbol: 'TEST1', diff --git a/src/procedures/__tests__/AssignStoRole.ts b/src/procedures/__tests__/AssignStoRole.ts index ffbeb8b..14e3f4d 100644 --- a/src/procedures/__tests__/AssignStoRole.ts +++ b/src/procedures/__tests__/AssignStoRole.ts @@ -5,9 +5,9 @@ import * as contextModule from '../../Context'; import * as wrappersModule from '../../PolymathBase'; import * as tokenFactoryModule from '../../testUtils/MockedTokenFactoryModule'; import { AssignStoRole } from '../../procedures/AssignStoRole'; -import { Procedure } from '~/procedures/Procedure'; -import { PolymathError } from '~/PolymathError'; -import { ErrorCode, PolyTransactionTag, StoRole } from '~/types'; +import { Procedure } from '../Procedure'; +import { PolymathError } from '../../PolymathError'; +import { ErrorCode, PolyTransactionTag, StoRole } from '../../types'; const params = { symbol: 'TEST1', diff --git a/src/procedures/__tests__/ControllerTransfer.ts b/src/procedures/__tests__/ControllerTransfer.ts index 33c57ba..34183cd 100644 --- a/src/procedures/__tests__/ControllerTransfer.ts +++ b/src/procedures/__tests__/ControllerTransfer.ts @@ -8,13 +8,13 @@ import { Wallet } from '../../Wallet'; import * as tokenFactoryModule from '../../testUtils/MockedTokenFactoryModule'; import { ControllerTransfer } from '../../procedures/ControllerTransfer'; import * as controllerTransferModule from '../../procedures/ControllerTransfer'; -import { Procedure } from '~/procedures/Procedure'; -import { PolymathError } from '~/PolymathError'; -import { ErrorCode, ProcedureType } from '~/types'; -import { mockFactories } from '~/testUtils/mockFactories'; -import * as shareholderFactoryModule from '~/entities/factories/ShareholderFactory'; +import { Procedure } from '../../procedures/Procedure'; +import { PolymathError } from '../../PolymathError'; +import { ErrorCode, ProcedureType } from '../../types'; +import { mockFactories } from '../../testUtils/mockFactories'; +import * as shareholderFactoryModule from '../../entities/factories/ShareholderFactory'; import { Factories } from '../../Context'; -import { SecurityToken, Shareholder } from '~/entities'; +import { SecurityToken, Shareholder } from '../../entities'; const params = { symbol: 'TEST1', diff --git a/src/procedures/__tests__/CreateCheckpoint.ts b/src/procedures/__tests__/CreateCheckpoint.ts index 54d5d6f..e98b291 100644 --- a/src/procedures/__tests__/CreateCheckpoint.ts +++ b/src/procedures/__tests__/CreateCheckpoint.ts @@ -5,16 +5,16 @@ import { TransactionReceiptWithDecodedLogs } from 'ethereum-protocol'; import { BigNumber } from '@polymathnetwork/contract-wrappers'; import { SecurityTokenEvents } from '@polymathnetwork/contract-wrappers'; import { CreateCheckpoint } from '../../procedures/CreateCheckpoint'; -import { Procedure } from '~/procedures/Procedure'; -import { PolymathError } from '~/PolymathError'; -import { ErrorCode, ProcedureType } from '~/types'; +import { Procedure } from '../../procedures/Procedure'; +import { PolymathError } from '../../PolymathError'; +import { ErrorCode, ProcedureType } from '../../types'; import * as utilsModule from '../../utils'; -import * as checkpointFactoryModule from '~/entities/factories/CheckpointFactory'; +import * as checkpointFactoryModule from '../../entities/factories/CheckpointFactory'; import * as contextModule from '../../Context'; import * as wrappersModule from '../../PolymathBase'; import * as tokenFactoryModule from '../../testUtils/MockedTokenFactoryModule'; -import { mockFactories } from '~/testUtils/mockFactories'; -import { Checkpoint, SecurityToken } from '~/entities'; +import { mockFactories } from '../../testUtils/mockFactories'; +import { Checkpoint, SecurityToken } from '../../entities'; const params = { symbol: 'TEST1', @@ -91,7 +91,7 @@ describe('CreateCheckpoint', () => { // Real call const resolver = await target.prepareTransactions(); - expect(resolver.run({} as TransactionReceiptWithDecodedLogs)).rejects.toThrow( + await expect(resolver.run({} as TransactionReceiptWithDecodedLogs)).rejects.toThrow( new PolymathError({ code: ErrorCode.UnexpectedEventLogs, message: diff --git a/src/procedures/__tests__/CreateErc20DividendDistribution.ts b/src/procedures/__tests__/CreateErc20DividendDistribution.ts index 2b638f3..2b5b8d7 100644 --- a/src/procedures/__tests__/CreateErc20DividendDistribution.ts +++ b/src/procedures/__tests__/CreateErc20DividendDistribution.ts @@ -8,14 +8,14 @@ import * as wrappersModule from '../../PolymathBase'; import * as approveModule from '../ApproveErc20'; import * as tokenFactoryModule from '../../testUtils/MockedTokenFactoryModule'; import { CreateErc20DividendDistribution } from '../../procedures/CreateErc20DividendDistribution'; -import { Procedure } from '~/procedures/Procedure'; -import { PolymathError } from '~/PolymathError'; -import { DividendType, ErrorCode, ProcedureType } from '~/types'; +import { Procedure } from '../Procedure'; +import { PolymathError } from '../../PolymathError'; +import { DividendType, ErrorCode, ProcedureType } from '../../types'; import { ApproveErc20 } from '../ApproveErc20'; -import * as dividendDistributionSecurityTokenFactoryModule from '~/entities/factories/DividendDistributionFactory'; -import * as utilsModule from '~/utils'; -import { mockFactories } from '~/testUtils/mockFactories'; -import { DividendDistribution, SecurityToken } from '~/entities'; +import * as dividendDistributionSecurityTokenFactoryModule from '../../entities/factories/DividendDistributionFactory'; +import * as utilsModule from '../../utils'; +import { mockFactories } from '../../testUtils/mockFactories'; +import { DividendDistribution, SecurityToken } from '../../entities'; const params = { symbol: 'TEST1', @@ -167,7 +167,7 @@ describe('CreateErc20DividendDistribution', () => { // Real call const resolver = await target.prepareTransactions(); - expect(resolver.run({} as TransactionReceiptWithDecodedLogs)).rejects.toThrow( + await expect(resolver.run({} as TransactionReceiptWithDecodedLogs)).rejects.toThrow( new PolymathError({ code: ErrorCode.UnexpectedEventLogs, message: diff --git a/src/procedures/__tests__/CreateEtherDividendDistribution.ts b/src/procedures/__tests__/CreateEtherDividendDistribution.ts index 79a203f..4a435ac 100644 --- a/src/procedures/__tests__/CreateEtherDividendDistribution.ts +++ b/src/procedures/__tests__/CreateEtherDividendDistribution.ts @@ -4,16 +4,16 @@ import { BigNumber, EtherDividendCheckpointEvents } from '@polymathnetwork/contr import { TransactionReceiptWithDecodedLogs } from 'ethereum-protocol'; import * as contractWrappersModule from '@polymathnetwork/contract-wrappers'; import { CreateEtherDividendDistribution } from '../../procedures/CreateEtherDividendDistribution'; -import { Procedure } from '~/procedures/Procedure'; -import { PolymathError } from '~/PolymathError'; -import { DividendType, ErrorCode, ProcedureType } from '~/types'; -import * as dividendDistributionSecurityTokenFactoryModule from '~/entities/factories/DividendDistributionFactory'; -import * as utilsModule from '~/utils'; +import { Procedure } from '../Procedure'; +import { PolymathError } from '../../PolymathError'; +import { DividendType, ErrorCode, ProcedureType } from '../../types'; +import * as dividendDistributionSecurityTokenFactoryModule from '../../entities/factories/DividendDistributionFactory'; +import * as utilsModule from '../../utils'; import * as contextModule from '../../Context'; import * as wrappersModule from '../../PolymathBase'; import * as tokenFactoryModule from '../../testUtils/MockedTokenFactoryModule'; -import { mockFactories } from '~/testUtils/mockFactories'; -import { DividendDistribution, SecurityToken } from '~/entities'; +import { mockFactories } from '../../testUtils/mockFactories'; +import { DividendDistribution, SecurityToken } from '../../entities'; const params = { symbol: 'TEST1', @@ -135,7 +135,7 @@ describe('CreateEtherDividendDistribution', () => { // Real call const resolver = await target.prepareTransactions(); - expect(resolver.run({} as TransactionReceiptWithDecodedLogs)).rejects.toThrow( + await expect(resolver.run({} as TransactionReceiptWithDecodedLogs)).rejects.toThrow( new PolymathError({ code: ErrorCode.UnexpectedEventLogs, message: diff --git a/src/procedures/__tests__/CreateSecurityToken.ts b/src/procedures/__tests__/CreateSecurityToken.ts index ad3efc2..167ede6 100644 --- a/src/procedures/__tests__/CreateSecurityToken.ts +++ b/src/procedures/__tests__/CreateSecurityToken.ts @@ -2,20 +2,20 @@ import { ImportMock, MockManager } from 'ts-mock-imports'; import { BigNumber, SecurityTokenRegistryEvents } from '@polymathnetwork/contract-wrappers'; import * as contractWrappersModule from '@polymathnetwork/contract-wrappers'; import { spy, restore } from 'sinon'; +import { TransactionReceiptWithDecodedLogs } from 'ethereum-protocol'; import * as contextModule from '../../Context'; import * as wrappersModule from '../../PolymathBase'; import * as approvalModule from '../ApproveErc20'; import { CreateSecurityToken } from '../../procedures/CreateSecurityToken'; -import { Procedure } from '~/procedures/Procedure'; -import { Wallet } from '~/Wallet'; -import { PolymathError } from '~/PolymathError'; -import { ErrorCode, ProcedureType } from '~/types'; +import { Procedure } from '../../procedures/Procedure'; +import { Wallet } from '../../Wallet'; +import { PolymathError } from '../../PolymathError'; +import { ErrorCode, ProcedureType } from '../../types'; import { ApproveErc20 } from '../ApproveErc20'; -import * as securityTokenFactoryModule from '~/entities/factories/SecurityTokenFactory'; -import { TransactionReceiptWithDecodedLogs } from 'ethereum-protocol'; -import * as utilsModule from '~/utils'; -import { mockFactories } from '~/testUtils/mockFactories'; -import { SecurityToken } from '~/entities'; +import * as securityTokenFactoryModule from '../../entities/factories/SecurityTokenFactory'; +import * as utilsModule from '../../utils'; +import { mockFactories } from '../../testUtils/mockFactories'; +import { SecurityToken } from '../../entities'; const params = { symbol: 'TEST1', @@ -110,7 +110,7 @@ describe('CreateSecurityToken', () => { // Real call const resolver = await target.prepareTransactions(); - expect(resolver.run({} as TransactionReceiptWithDecodedLogs)).rejects.toThrow( + await expect(resolver.run({} as TransactionReceiptWithDecodedLogs)).rejects.toThrow( new PolymathError({ code: ErrorCode.UnexpectedEventLogs, message: diff --git a/src/procedures/__tests__/EnableDividendManagers.ts b/src/procedures/__tests__/EnableDividendManagers.ts index 00434f7..750747f 100644 --- a/src/procedures/__tests__/EnableDividendManagers.ts +++ b/src/procedures/__tests__/EnableDividendManagers.ts @@ -6,9 +6,9 @@ import * as contextModule from '../../Context'; import * as wrappersModule from '../../PolymathBase'; import * as tokenFactoryModule from '../../testUtils/MockedTokenFactoryModule'; import { EnableDividendManagers } from '../../procedures/EnableDividendManagers'; -import { Procedure } from '~/procedures/Procedure'; -import { PolymathError } from '~/PolymathError'; -import { ErrorCode, PolyTransactionTag } from '~/types'; +import { Procedure } from '../Procedure'; +import { PolymathError } from '../../PolymathError'; +import { ErrorCode, PolyTransactionTag } from '../../types'; const params = { symbol: 'TEST1', diff --git a/src/procedures/__tests__/EnableGeneralPermissionManager.ts b/src/procedures/__tests__/EnableGeneralPermissionManager.ts index 6c4b0e8..6c02660 100644 --- a/src/procedures/__tests__/EnableGeneralPermissionManager.ts +++ b/src/procedures/__tests__/EnableGeneralPermissionManager.ts @@ -6,9 +6,9 @@ import * as contextModule from '../../Context'; import * as wrappersModule from '../../PolymathBase'; import * as tokenFactoryModule from '../../testUtils/MockedTokenFactoryModule'; import { EnableGeneralPermissionManager } from '../../procedures/EnableGeneralPermissionManager'; -import { Procedure } from '~/procedures/Procedure'; -import { PolymathError } from '~/PolymathError'; -import { ErrorCode, PolyTransactionTag } from '~/types'; +import { Procedure } from '../Procedure'; +import { PolymathError } from '../../PolymathError'; +import { ErrorCode, PolyTransactionTag } from '../../types'; const params = { symbol: 'TEST1', diff --git a/src/procedures/__tests__/LaunchCappedSto.ts b/src/procedures/__tests__/LaunchCappedSto.ts index 46fec8d..4e2994f 100644 --- a/src/procedures/__tests__/LaunchCappedSto.ts +++ b/src/procedures/__tests__/LaunchCappedSto.ts @@ -8,19 +8,19 @@ import { TransactionReceiptWithDecodedLogs, } from '@polymathnetwork/contract-wrappers'; import { LaunchCappedSto } from '../../procedures/LaunchCappedSto'; -import { Procedure } from '~/procedures/Procedure'; -import { PolymathError } from '~/PolymathError'; -import { ErrorCode, LaunchCappedStoProcedureArgs, ProcedureType, StoType } from '~/types'; -import * as cappedStoFactoryModule from '~/entities/factories/CappedStoFactory'; -import * as utilsModule from '~/utils'; +import { Procedure } from '../../procedures/Procedure'; +import { PolymathError } from '../../PolymathError'; +import { ErrorCode, LaunchCappedStoProcedureArgs, ProcedureType, StoType } from '../../types'; +import * as cappedStoFactoryModule from '../../entities/factories/CappedStoFactory'; +import * as utilsModule from '../../utils'; import * as contextModule from '../../Context'; import * as wrappersModule from '../../PolymathBase'; import * as tokenFactoryModule from '../../testUtils/MockedTokenFactoryModule'; import * as moduleWrapperFactoryModule from '../../testUtils/MockedModuleWrapperFactoryModule'; -import { Wallet } from '~/Wallet'; -import { TransferErc20 } from '~/procedures'; -import { mockFactories } from '~/testUtils/mockFactories'; -import { CappedSto, SecurityToken } from '~/entities'; +import { Wallet } from '../../Wallet'; +import { TransferErc20 } from '../../procedures'; +import { mockFactories } from '../../testUtils/mockFactories'; +import { CappedSto, SecurityToken } from '../../entities'; const params: LaunchCappedStoProcedureArgs = { symbol: 'TEST1', diff --git a/src/procedures/__tests__/LaunchUsdTieredSto.ts b/src/procedures/__tests__/LaunchUsdTieredSto.ts index ef6f534..5a5bf7c 100644 --- a/src/procedures/__tests__/LaunchUsdTieredSto.ts +++ b/src/procedures/__tests__/LaunchUsdTieredSto.ts @@ -8,19 +8,19 @@ import { } from '@polymathnetwork/contract-wrappers'; import * as contractWrappersModule from '@polymathnetwork/contract-wrappers'; import { LaunchUsdTieredSto } from '../../procedures/LaunchUsdTieredSto'; -import { Procedure } from '~/procedures/Procedure'; -import { PolymathError } from '~/PolymathError'; -import { ErrorCode, LaunchUsdTieredStoProcedureArgs, ProcedureType, StoType } from '~/types'; +import { Procedure } from '../Procedure'; +import { PolymathError } from '../../PolymathError'; +import { ErrorCode, LaunchUsdTieredStoProcedureArgs, ProcedureType, StoType } from '../../types'; import * as usdTieredStoFactoryModule from '~/entities/factories/UsdTieredStoFactory'; -import * as utilsModule from '~/utils'; +import * as utilsModule from '../../utils'; import * as contextModule from '../../Context'; import * as wrappersModule from '../../PolymathBase'; import * as tokenFactoryModule from '../../testUtils/MockedTokenFactoryModule'; import * as moduleWrapperFactoryModule from '../../testUtils/MockedModuleWrapperFactoryModule'; -import { Wallet } from '~/Wallet'; -import { TransferErc20 } from '~/procedures'; -import { mockFactories } from '~/testUtils/mockFactories'; -import { SecurityToken, UsdTieredSto } from '~/entities'; +import { Wallet } from '../../Wallet'; +import { TransferErc20 } from '../../procedures'; +import { mockFactories } from '../../testUtils/mockFactories'; +import { SecurityToken, UsdTieredSto } from '../../entities'; const params: LaunchUsdTieredStoProcedureArgs = { symbol: 'TEST1', diff --git a/src/procedures/__tests__/MintTokens.ts b/src/procedures/__tests__/MintTokens.ts index 314c279..9e2d431 100644 --- a/src/procedures/__tests__/MintTokens.ts +++ b/src/procedures/__tests__/MintTokens.ts @@ -3,21 +3,21 @@ import { spy, restore } from 'sinon'; import { BigNumber, TransactionReceiptWithDecodedLogs } from '@polymathnetwork/contract-wrappers'; import * as contractWrappersModule from '@polymathnetwork/contract-wrappers'; import { MintTokens } from '../../procedures/MintTokens'; -import { Procedure } from '~/procedures/Procedure'; -import * as shareholdersEntityModule from '~/entities/SecurityToken/Shareholders'; -import * as securityTokenEntityModule from '~/entities/SecurityToken/SecurityToken'; -import { PolymathError } from '~/PolymathError'; -import { ErrorCode, MintTokensProcedureArgs, ProcedureType } from '~/types'; -import * as securityTokenFactoryModule from '~/entities/factories/SecurityTokenFactory'; -import * as shareholderFactoryModule from '~/entities/factories/ShareholderFactory'; +import { Procedure } from '../../procedures/Procedure'; +import * as shareholdersEntityModule from '../../entities/SecurityToken/Shareholders'; +import * as securityTokenEntityModule from '../../entities/SecurityToken/SecurityToken'; +import { PolymathError } from '../../PolymathError'; +import { ErrorCode, MintTokensProcedureArgs, ProcedureType } from '../../types'; +import * as securityTokenFactoryModule from '../../entities/factories/SecurityTokenFactory'; +import * as shareholderFactoryModule from '../../entities/factories/ShareholderFactory'; import * as contextModule from '../../Context'; import * as wrappersModule from '../../PolymathBase'; import * as tokenFactoryModule from '../../testUtils/MockedTokenFactoryModule'; import * as moduleWrapperFactoryModule from '../../testUtils/MockedModuleWrapperFactoryModule'; -import { ModifyShareholderData } from '~/procedures'; -import { mockFactories } from '~/testUtils/mockFactories'; -import { Shareholder } from '~/entities'; -import { SecurityToken } from '~/entities/SecurityToken/SecurityToken'; +import { ModifyShareholderData } from '../../procedures'; +import { mockFactories } from '../../testUtils/mockFactories'; +import { Shareholder } from '../../entities'; +import { SecurityToken } from '../../entities/SecurityToken/SecurityToken'; const cloneDeep = require('lodash/clonedeep'); @@ -100,7 +100,7 @@ describe('MintTokens', () => { const factoryMockSetup = mockFactories(); - wrappersMock.mock('getAttachedModules', Promise.resolve('')); + wrappersMock.mock('getAttachedModules', Promise.resolve([])); const shareHolders = [ { diff --git a/src/procedures/__tests__/ModifyShareholderData.ts b/src/procedures/__tests__/ModifyShareholderData.ts index 317f311..73dfba1 100644 --- a/src/procedures/__tests__/ModifyShareholderData.ts +++ b/src/procedures/__tests__/ModifyShareholderData.ts @@ -4,19 +4,19 @@ import * as contractWrappersModule from '@polymathnetwork/contract-wrappers'; import { TransactionReceiptWithDecodedLogs } from 'ethereum-protocol'; import { BigNumber, GeneralTransferManager_3_0_0 } from '@polymathnetwork/contract-wrappers'; import { ModifyShareholderData } from '../../procedures/ModifyShareholderData'; -import { Procedure } from '~/procedures/Procedure'; -import { ErrorCode, ProcedureType } from '~/types'; -import * as shareholderFactoryModule from '~/entities/factories/ShareholderFactory'; -import * as securityTokenFactoryModule from '~/entities/factories/SecurityTokenFactory'; +import { Procedure } from '../../procedures/Procedure'; +import { ErrorCode, ProcedureType } from '../../types'; +import * as shareholderFactoryModule from '../../entities/factories/ShareholderFactory'; +import * as securityTokenFactoryModule from '../../entities/factories/SecurityTokenFactory'; import * as contextModule from '../../Context'; import * as wrappersModule from '../../PolymathBase'; import * as tokenFactoryModule from '../../testUtils/MockedTokenFactoryModule'; -import { mockFactories } from '~/testUtils/mockFactories'; -import * as shareholdersEntityModule from '~/entities/SecurityToken/Shareholders'; -import * as securityTokenEntityModule from '~/entities/SecurityToken/SecurityToken'; -import { SecurityToken } from '~/entities/SecurityToken/SecurityToken'; -import { PolymathError } from '~/PolymathError'; -import { Shareholder } from '~/entities'; +import { mockFactories } from '../../testUtils/mockFactories'; +import * as shareholdersEntityModule from '../../entities/SecurityToken/Shareholders'; +import * as securityTokenEntityModule from '../../entities/SecurityToken/SecurityToken'; +import { SecurityToken } from '../../entities/SecurityToken/SecurityToken'; +import { PolymathError } from '../../PolymathError'; +import { Shareholder } from '../../entities'; const cloneDeep = require('lodash/clonedeep'); diff --git a/src/procedures/__tests__/PauseSto.ts b/src/procedures/__tests__/PauseSto.ts index b69bb42..dd142e9 100644 --- a/src/procedures/__tests__/PauseSto.ts +++ b/src/procedures/__tests__/PauseSto.ts @@ -2,19 +2,19 @@ import { ImportMock, MockManager } from 'ts-mock-imports'; import { restore, spy } from 'sinon'; import * as contractWrappersModule from '@polymathnetwork/contract-wrappers'; import { PauseSto } from '../../procedures/PauseSto'; -import { Procedure } from '~/procedures/Procedure'; -import { PolymathError } from '~/PolymathError'; -import { ErrorCode, PauseStoProcedureArgs, ProcedureType, StoType } from '~/types'; +import { Procedure } from '../../procedures/Procedure'; +import { PolymathError } from '../../PolymathError'; +import { ErrorCode, PauseStoProcedureArgs, ProcedureType, StoType } from '../../types'; import * as pauseStoModule from '../../procedures/PauseSto'; -import * as cappedStoFactoryModule from '~/entities/factories/CappedStoFactory'; -import * as usdTieredStoFactoryModule from '~/entities/factories/UsdTieredStoFactory'; +import * as cappedStoFactoryModule from '../../entities/factories/CappedStoFactory'; +import * as usdTieredStoFactoryModule from '../../entities/factories/UsdTieredStoFactory'; import * as contextModule from '../../Context'; import * as wrappersModule from '../../PolymathBase'; import * as tokenFactoryModule from '../../testUtils/MockedTokenFactoryModule'; import * as moduleWrapperFactoryModule from '../../testUtils/MockedModuleWrapperFactoryModule'; -import { mockFactories } from '~/testUtils/mockFactories'; +import { mockFactories } from '../../testUtils/mockFactories'; import { Factories } from '../../Context'; -import { CappedSto, SecurityToken, UsdTieredSto } from '~/entities'; +import { CappedSto, SecurityToken, UsdTieredSto } from '../../entities'; const usdTieredParams: PauseStoProcedureArgs = { symbol: 'TEST1', diff --git a/src/procedures/__tests__/SetDividendsWallet.ts b/src/procedures/__tests__/SetDividendsWallet.ts index f94e955..0a22484 100644 --- a/src/procedures/__tests__/SetDividendsWallet.ts +++ b/src/procedures/__tests__/SetDividendsWallet.ts @@ -1,5 +1,5 @@ import { ImportMock, MockManager } from 'ts-mock-imports'; -import { stub, spy, restore } from 'sinon'; +import { spy, restore } from 'sinon'; import * as contractWrappersModule from '@polymathnetwork/contract-wrappers'; import * as contextModule from '../../Context'; import { Factories } from '../../Context'; @@ -7,13 +7,13 @@ import * as wrappersModule from '../../PolymathBase'; import * as tokenFactoryModule from '../../testUtils/MockedTokenFactoryModule'; import { SetDividendsWallet } from '../../procedures/SetDividendsWallet'; import * as setDividendsWalletModule from '../../procedures/SetDividendsWallet'; -import { Procedure } from '~/procedures/Procedure'; -import { ProcedureType, DividendType, ErrorCode } from '~/types'; -import { PolymathError } from '~/PolymathError'; -import { mockFactories } from '~/testUtils/mockFactories'; -import * as erc20FactoryModule from '~/entities/factories/Erc20DividendsManagerFactory'; -import * as ethFactoryModule from '~/entities/factories/EthDividendsManagerFactory'; -import { SecurityToken, Erc20DividendsManager, EthDividendsManager } from '~/entities'; +import { Procedure } from '../../procedures/Procedure'; +import { ProcedureType, DividendType, ErrorCode } from '../../types'; +import { PolymathError } from '../../PolymathError'; +import { mockFactories } from '../../testUtils/mockFactories'; +import * as erc20FactoryModule from '../../entities/factories/Erc20DividendsManagerFactory'; +import * as ethFactoryModule from '../../entities/factories/EthDividendsManagerFactory'; +import { SecurityToken, Erc20DividendsManager, EthDividendsManager } from '../../entities'; const params = { symbol: 'TEST1', From 06ea717aafa16833b2a43d3cf6ba22b1c69ab323 Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Tue, 19 Nov 2019 09:21:11 -0800 Subject: [PATCH 04/21] fix: cloneDeep issue and prettier --- src/procedures/__tests__/MintTokens.ts | 3 +-- src/procedures/__tests__/ModifyShareholderData.ts | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/procedures/__tests__/MintTokens.ts b/src/procedures/__tests__/MintTokens.ts index 9e2d431..2906808 100644 --- a/src/procedures/__tests__/MintTokens.ts +++ b/src/procedures/__tests__/MintTokens.ts @@ -2,6 +2,7 @@ import { ImportMock, MockManager, StaticMockManager } from 'ts-mock-imports'; import { spy, restore } from 'sinon'; import { BigNumber, TransactionReceiptWithDecodedLogs } from '@polymathnetwork/contract-wrappers'; import * as contractWrappersModule from '@polymathnetwork/contract-wrappers'; +import { cloneDeep } from 'lodash'; import { MintTokens } from '../../procedures/MintTokens'; import { Procedure } from '../../procedures/Procedure'; import * as shareholdersEntityModule from '../../entities/SecurityToken/Shareholders'; @@ -19,8 +20,6 @@ import { mockFactories } from '../../testUtils/mockFactories'; import { Shareholder } from '../../entities'; import { SecurityToken } from '../../entities/SecurityToken/SecurityToken'; -const cloneDeep = require('lodash/clonedeep'); - const securityTokenId = 'ST ID'; const testAddress = '0x6666666666666666666666666666666666666666'; const testAddress2 = '0x9999999999999999999999999999999999999999'; diff --git a/src/procedures/__tests__/ModifyShareholderData.ts b/src/procedures/__tests__/ModifyShareholderData.ts index 73dfba1..120dbd9 100644 --- a/src/procedures/__tests__/ModifyShareholderData.ts +++ b/src/procedures/__tests__/ModifyShareholderData.ts @@ -3,6 +3,7 @@ import { spy, restore } from 'sinon'; import * as contractWrappersModule from '@polymathnetwork/contract-wrappers'; import { TransactionReceiptWithDecodedLogs } from 'ethereum-protocol'; import { BigNumber, GeneralTransferManager_3_0_0 } from '@polymathnetwork/contract-wrappers'; +import { cloneDeep } from 'lodash'; import { ModifyShareholderData } from '../../procedures/ModifyShareholderData'; import { Procedure } from '../../procedures/Procedure'; import { ErrorCode, ProcedureType } from '../../types'; @@ -18,8 +19,6 @@ import { SecurityToken } from '../../entities/SecurityToken/SecurityToken'; import { PolymathError } from '../../PolymathError'; import { Shareholder } from '../../entities'; -const cloneDeep = require('lodash/clonedeep'); - const testAddress = '0x6666666666666666666666666666666666666666'; const testAddress2 = '0x9999999999999999999999999999999999999999'; const oldShareholdersData = [ @@ -255,7 +254,7 @@ describe('ModifyShareholderData', () => { securityTokenId: () => params.symbol, address: () => testAddress, }; - const fetchStub = shareholderFactoryMock.mock('fetch', Promise.resolve(shareholderObject)); + const fetchStub = shareholderFactoryMock.mock('fetch', shareholderObject); // Real call const resolver = await target.prepareTransactions(); From b98ea7266043c753ec6263d3a9f12082d674be6a Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Tue, 19 Nov 2019 10:09:18 -0800 Subject: [PATCH 05/21] refactor: fetch, refresh without promises --- src/procedures/__tests__/ControllerTransfer.ts | 2 +- src/procedures/__tests__/CreateCheckpoint.ts | 2 +- src/procedures/__tests__/EnableDividendManagers.ts | 7 ++++--- src/procedures/__tests__/EnableGeneralPermissionManager.ts | 6 ++++-- src/procedures/__tests__/PauseSto.ts | 2 +- src/procedures/__tests__/SetDividendsWallet.ts | 4 ++-- 6 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/procedures/__tests__/ControllerTransfer.ts b/src/procedures/__tests__/ControllerTransfer.ts index 34183cd..a28037b 100644 --- a/src/procedures/__tests__/ControllerTransfer.ts +++ b/src/procedures/__tests__/ControllerTransfer.ts @@ -162,7 +162,7 @@ describe('ControllerTransfer', () => { }); test('should successfully resolve controller transfer', async () => { - const refreshStub = shareholderFactoryMock.mock('refresh', Promise.resolve(undefined)); + const refreshStub = shareholderFactoryMock.mock('refresh', undefined); const securityTokenId = SecurityToken.generateId({ symbol: params.symbol }); const resolverValue = await controllerTransferModule.createControllerTransferResolver( factoriesMockedSetup, diff --git a/src/procedures/__tests__/CreateCheckpoint.ts b/src/procedures/__tests__/CreateCheckpoint.ts index e98b291..2064bca 100644 --- a/src/procedures/__tests__/CreateCheckpoint.ts +++ b/src/procedures/__tests__/CreateCheckpoint.ts @@ -108,7 +108,7 @@ describe('CreateCheckpoint', () => { }; // Better test this - const fetchStub = checkpointFactoryMock.mock('fetch', Promise.resolve(checkpointObject)); + const fetchStub = checkpointFactoryMock.mock('fetch', checkpointObject); const findEventsStub = ImportMock.mockFunction(utilsModule, 'findEvents', [ { args: { diff --git a/src/procedures/__tests__/EnableDividendManagers.ts b/src/procedures/__tests__/EnableDividendManagers.ts index 750747f..ad8e296 100644 --- a/src/procedures/__tests__/EnableDividendManagers.ts +++ b/src/procedures/__tests__/EnableDividendManagers.ts @@ -15,7 +15,8 @@ const params = { storageWalletAddress: '0x5555555555555555555555555555555555555555', }; -const testAddress = '0x2222222222222222222222222222222222222222'; +const securityTokenAddress = '0x2222222222222222222222222222222222222222'; +const moduleFactoryAddress = '0x3333333333333333333333333333333333333333'; describe('EnableDividendManagers', () => { let target: EnableDividendManagers; @@ -34,13 +35,13 @@ describe('EnableDividendManagers', () => { wrappersMock.set('tokenFactory', tokenFactoryMock.getMockInstance()); securityTokenMock = ImportMock.mockClass(contractWrappersModule, 'SecurityToken_3_0_0'); - securityTokenMock.mock('address', Promise.resolve(testAddress)); + securityTokenMock.mock('address', Promise.resolve(securityTokenAddress)); etherDividendsMock = ImportMock.mockClass( contractWrappersModule, 'EtherDividendCheckpoint_3_0_0' ); - wrappersMock.mock('getModuleFactoryAddress', Promise.resolve(testAddress)); + wrappersMock.mock('getModuleFactoryAddress', moduleFactoryAddress); tokenFactoryMock.mock( 'getSecurityTokenInstanceFromTicker', securityTokenMock.getMockInstance() diff --git a/src/procedures/__tests__/EnableGeneralPermissionManager.ts b/src/procedures/__tests__/EnableGeneralPermissionManager.ts index 6c02660..a749481 100644 --- a/src/procedures/__tests__/EnableGeneralPermissionManager.ts +++ b/src/procedures/__tests__/EnableGeneralPermissionManager.ts @@ -14,6 +14,8 @@ const params = { symbol: 'TEST1', address: '0x4444444444444444444444444444444444444444', }; +const securityTokenAddress = '0x2222222222222222222222222222222222222222'; +const moduleFactoryAddress = '0x3333333333333333333333333333333333333333'; describe('EnableGeneralPermissionManager', () => { let target: EnableGeneralPermissionManager; @@ -32,13 +34,13 @@ describe('EnableGeneralPermissionManager', () => { wrappersMock.set('tokenFactory', tokenFactoryMock.getMockInstance()); securityTokenMock = ImportMock.mockClass(contractWrappersModule, 'SecurityToken_3_0_0'); - securityTokenMock.mock('address', Promise.resolve(params.address)); + securityTokenMock.mock('address', Promise.resolve(securityTokenAddress)); etherDividendsMock = ImportMock.mockClass( contractWrappersModule, 'EtherDividendCheckpoint_3_0_0' ); - wrappersMock.mock('getModuleFactoryAddress', Promise.resolve(params.address)); + wrappersMock.mock('getModuleFactoryAddress', moduleFactoryAddress); tokenFactoryMock.mock( 'getSecurityTokenInstanceFromTicker', securityTokenMock.getMockInstance() diff --git a/src/procedures/__tests__/PauseSto.ts b/src/procedures/__tests__/PauseSto.ts index dd142e9..c905384 100644 --- a/src/procedures/__tests__/PauseSto.ts +++ b/src/procedures/__tests__/PauseSto.ts @@ -200,7 +200,7 @@ describe('PauseSto', () => { test('should successfully resolve pause sto with usd tiered sto params', async () => { target = new PauseSto(usdTieredParams, contextMock.getMockInstance()); - const refreshStub = usdTieredStoFactoryMock.mock('refresh', Promise.resolve(undefined)); + const refreshStub = usdTieredStoFactoryMock.mock('refresh', undefined); await pauseStoModule.createPauseStoResolver( factoryMockSetup, usdTieredParams.symbol, diff --git a/src/procedures/__tests__/SetDividendsWallet.ts b/src/procedures/__tests__/SetDividendsWallet.ts index 0a22484..51f985d 100644 --- a/src/procedures/__tests__/SetDividendsWallet.ts +++ b/src/procedures/__tests__/SetDividendsWallet.ts @@ -195,7 +195,7 @@ describe('SetDividendsWallet', () => { }); test('should successfully refresh ERC20 dividends factory', async () => { - const refreshStub = erc20FactoryMock.mock('refresh', Promise.resolve(undefined)); + const refreshStub = erc20FactoryMock.mock('refresh', undefined); const resolverValue = await setDividendsWalletModule.createSetDividendsWalletResolver( DividendType.Erc20, @@ -219,7 +219,7 @@ describe('SetDividendsWallet', () => { }); test('should successfully refresh Eth dividends factory', async () => { - const refreshStub = ethFactoryMock.mock('refresh', Promise.resolve(undefined)); + const refreshStub = ethFactoryMock.mock('refresh', undefined); const resolverValue = await setDividendsWalletModule.createSetDividendsWalletResolver( DividendType.Eth, From 5ddc68e12b41d30fd33110e67d993c6ec6b76faa Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Tue, 19 Nov 2019 11:05:52 -0800 Subject: [PATCH 06/21] refactor: rectify promise resolve and add prettier to all working files --- src/procedures/__tests__/ControllerTransfer.ts | 2 +- src/procedures/__tests__/CreateCheckpoint.ts | 3 +-- src/procedures/__tests__/CreateErc20DividendDistribution.ts | 5 ++++- src/procedures/__tests__/CreateEtherDividendDistribution.ts | 5 ++++- src/procedures/__tests__/CreateSecurityToken.ts | 3 +-- src/procedures/__tests__/EnableDividendManagers.ts | 2 +- src/procedures/__tests__/EnableGeneralPermissionManager.ts | 2 +- src/procedures/__tests__/LaunchCappedSto.ts | 2 +- src/procedures/__tests__/LaunchUsdTieredSto.ts | 2 +- src/procedures/__tests__/MintTokens.ts | 2 +- src/procedures/__tests__/ModifyShareholderData.ts | 4 ++-- src/procedures/__tests__/PauseSto.ts | 4 ++-- src/procedures/__tests__/SetDividendsWallet.ts | 4 ++-- 13 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/procedures/__tests__/ControllerTransfer.ts b/src/procedures/__tests__/ControllerTransfer.ts index a28037b..b4e7539 100644 --- a/src/procedures/__tests__/ControllerTransfer.ts +++ b/src/procedures/__tests__/ControllerTransfer.ts @@ -162,7 +162,7 @@ describe('ControllerTransfer', () => { }); test('should successfully resolve controller transfer', async () => { - const refreshStub = shareholderFactoryMock.mock('refresh', undefined); + const refreshStub = shareholderFactoryMock.mock('refresh', Promise.resolve()); const securityTokenId = SecurityToken.generateId({ symbol: params.symbol }); const resolverValue = await controllerTransferModule.createControllerTransferResolver( factoriesMockedSetup, diff --git a/src/procedures/__tests__/CreateCheckpoint.ts b/src/procedures/__tests__/CreateCheckpoint.ts index 2064bca..b15338a 100644 --- a/src/procedures/__tests__/CreateCheckpoint.ts +++ b/src/procedures/__tests__/CreateCheckpoint.ts @@ -107,8 +107,7 @@ describe('CreateCheckpoint', () => { index: () => indexValue, }; - // Better test this - const fetchStub = checkpointFactoryMock.mock('fetch', checkpointObject); + const fetchStub = checkpointFactoryMock.mock('fetch', Promise.resolve(checkpointObject)); const findEventsStub = ImportMock.mockFunction(utilsModule, 'findEvents', [ { args: { diff --git a/src/procedures/__tests__/CreateErc20DividendDistribution.ts b/src/procedures/__tests__/CreateErc20DividendDistribution.ts index 2b5b8d7..c2b8876 100644 --- a/src/procedures/__tests__/CreateErc20DividendDistribution.ts +++ b/src/procedures/__tests__/CreateErc20DividendDistribution.ts @@ -183,7 +183,10 @@ describe('CreateErc20DividendDistribution', () => { index: () => Promise.resolve(dividendIndex), }; - const fetchStub = dividendDistributionFactoryMock.mock('fetch', dividendObject); + const fetchStub = dividendDistributionFactoryMock.mock( + 'fetch', + Promise.resolve(dividendObject) + ); const findEventsStub = ImportMock.mockFunction(utilsModule, 'findEvents', [ { args: { diff --git a/src/procedures/__tests__/CreateEtherDividendDistribution.ts b/src/procedures/__tests__/CreateEtherDividendDistribution.ts index 4a435ac..cde52c1 100644 --- a/src/procedures/__tests__/CreateEtherDividendDistribution.ts +++ b/src/procedures/__tests__/CreateEtherDividendDistribution.ts @@ -151,7 +151,10 @@ describe('CreateEtherDividendDistribution', () => { index: () => dividendIndex, }; - const fetchStub = dividendDistributionFactoryMock.mock('fetch', dividendObject); + const fetchStub = dividendDistributionFactoryMock.mock( + 'fetch', + Promise.resolve(dividendObject) + ); const findEventsStub = ImportMock.mockFunction(utilsModule, 'findEvents', [ { args: { diff --git a/src/procedures/__tests__/CreateSecurityToken.ts b/src/procedures/__tests__/CreateSecurityToken.ts index 167ede6..43eb153 100644 --- a/src/procedures/__tests__/CreateSecurityToken.ts +++ b/src/procedures/__tests__/CreateSecurityToken.ts @@ -143,9 +143,8 @@ describe('CreateSecurityToken', () => { const receipt = {} as TransactionReceiptWithDecodedLogs; await resolver.run(receipt); - // Verification for resolver result + // Verifications expect(resolver.result).toEqual(creationObject); - // Verification for fetch expect( createStub .getCall(0) diff --git a/src/procedures/__tests__/EnableDividendManagers.ts b/src/procedures/__tests__/EnableDividendManagers.ts index ad8e296..beddf95 100644 --- a/src/procedures/__tests__/EnableDividendManagers.ts +++ b/src/procedures/__tests__/EnableDividendManagers.ts @@ -41,7 +41,7 @@ describe('EnableDividendManagers', () => { contractWrappersModule, 'EtherDividendCheckpoint_3_0_0' ); - wrappersMock.mock('getModuleFactoryAddress', moduleFactoryAddress); + wrappersMock.mock('getModuleFactoryAddress', Promise.resolve(moduleFactoryAddress)); tokenFactoryMock.mock( 'getSecurityTokenInstanceFromTicker', securityTokenMock.getMockInstance() diff --git a/src/procedures/__tests__/EnableGeneralPermissionManager.ts b/src/procedures/__tests__/EnableGeneralPermissionManager.ts index a749481..c145ecb 100644 --- a/src/procedures/__tests__/EnableGeneralPermissionManager.ts +++ b/src/procedures/__tests__/EnableGeneralPermissionManager.ts @@ -40,7 +40,7 @@ describe('EnableGeneralPermissionManager', () => { contractWrappersModule, 'EtherDividendCheckpoint_3_0_0' ); - wrappersMock.mock('getModuleFactoryAddress', moduleFactoryAddress); + wrappersMock.mock('getModuleFactoryAddress', Promise.resolve(moduleFactoryAddress)); tokenFactoryMock.mock( 'getSecurityTokenInstanceFromTicker', securityTokenMock.getMockInstance() diff --git a/src/procedures/__tests__/LaunchCappedSto.ts b/src/procedures/__tests__/LaunchCappedSto.ts index 4e2994f..ffde516 100644 --- a/src/procedures/__tests__/LaunchCappedSto.ts +++ b/src/procedures/__tests__/LaunchCappedSto.ts @@ -172,7 +172,7 @@ describe('LaunchCappedSto', () => { stoType: StoType.Capped, address: securityTokenAddress, }; - const fetchStub = cappedStoFactoryMock.mock('fetch', stoObject); + const fetchStub = cappedStoFactoryMock.mock('fetch', Promise.resolve(stoObject)); const moduleAddress = '0x3333333333333333333333333333333333333333'; const findEventsStub = ImportMock.mockFunction(utilsModule, 'findEvents', [ { diff --git a/src/procedures/__tests__/LaunchUsdTieredSto.ts b/src/procedures/__tests__/LaunchUsdTieredSto.ts index 5a5bf7c..2535bb3 100644 --- a/src/procedures/__tests__/LaunchUsdTieredSto.ts +++ b/src/procedures/__tests__/LaunchUsdTieredSto.ts @@ -191,7 +191,7 @@ describe('LaunchUsdTieredSto', () => { stoType: StoType.UsdTiered, address: securityTokenAddress, }; - const fetchStub = usdTieredStoFactoryMock.mock('fetch', stoObject); + const fetchStub = usdTieredStoFactoryMock.mock('fetch', Promise.resolve(stoObject)); const moduleAddress = '0x3333333333333333333333333333333333333333'; findEventsStub = ImportMock.mockFunction(utilsModule, 'findEvents', [ { diff --git a/src/procedures/__tests__/MintTokens.ts b/src/procedures/__tests__/MintTokens.ts index 2906808..a480dc2 100644 --- a/src/procedures/__tests__/MintTokens.ts +++ b/src/procedures/__tests__/MintTokens.ts @@ -163,7 +163,7 @@ describe('MintTokens', () => { securityTokenId: params.symbol, address: testAddress, }; - const fetchStub = shareholderFactoryMock.mock('fetch', shareholderObject); + const fetchStub = shareholderFactoryMock.mock('fetch', Promise.resolve(shareholderObject)); // Real call const resolver = await target.prepareTransactions(); diff --git a/src/procedures/__tests__/ModifyShareholderData.ts b/src/procedures/__tests__/ModifyShareholderData.ts index 120dbd9..8a8d814 100644 --- a/src/procedures/__tests__/ModifyShareholderData.ts +++ b/src/procedures/__tests__/ModifyShareholderData.ts @@ -160,7 +160,7 @@ describe('ModifyShareholderData', () => { securityTokenId: params.symbol, address: testAddress, }; - const fetchStub = shareholderFactoryMock.mock('fetch', shareholderObject); + const fetchStub = shareholderFactoryMock.mock('fetch', Promise.resolve(shareholderObject)); // Real call const resolver = await target.prepareTransactions(); @@ -254,7 +254,7 @@ describe('ModifyShareholderData', () => { securityTokenId: () => params.symbol, address: () => testAddress, }; - const fetchStub = shareholderFactoryMock.mock('fetch', shareholderObject); + const fetchStub = shareholderFactoryMock.mock('fetch', Promise.resolve(shareholderObject)); // Real call const resolver = await target.prepareTransactions(); diff --git a/src/procedures/__tests__/PauseSto.ts b/src/procedures/__tests__/PauseSto.ts index c905384..b0931b8 100644 --- a/src/procedures/__tests__/PauseSto.ts +++ b/src/procedures/__tests__/PauseSto.ts @@ -179,7 +179,7 @@ describe('PauseSto', () => { }); test('should successfully resolve pause sto with capped sto params', async () => { - const refreshStub = cappedStoFactoryMock.mock('refresh', undefined); + const refreshStub = cappedStoFactoryMock.mock('refresh', Promise.resolve()); await pauseStoModule.createPauseStoResolver( factoryMockSetup, cappedParams.symbol, @@ -200,7 +200,7 @@ describe('PauseSto', () => { test('should successfully resolve pause sto with usd tiered sto params', async () => { target = new PauseSto(usdTieredParams, contextMock.getMockInstance()); - const refreshStub = usdTieredStoFactoryMock.mock('refresh', undefined); + const refreshStub = usdTieredStoFactoryMock.mock('refresh', Promise.resolve()); await pauseStoModule.createPauseStoResolver( factoryMockSetup, usdTieredParams.symbol, diff --git a/src/procedures/__tests__/SetDividendsWallet.ts b/src/procedures/__tests__/SetDividendsWallet.ts index 51f985d..5e49826 100644 --- a/src/procedures/__tests__/SetDividendsWallet.ts +++ b/src/procedures/__tests__/SetDividendsWallet.ts @@ -195,7 +195,7 @@ describe('SetDividendsWallet', () => { }); test('should successfully refresh ERC20 dividends factory', async () => { - const refreshStub = erc20FactoryMock.mock('refresh', undefined); + const refreshStub = erc20FactoryMock.mock('refresh', Promise.resolve()); const resolverValue = await setDividendsWalletModule.createSetDividendsWalletResolver( DividendType.Erc20, @@ -219,7 +219,7 @@ describe('SetDividendsWallet', () => { }); test('should successfully refresh Eth dividends factory', async () => { - const refreshStub = ethFactoryMock.mock('refresh', undefined); + const refreshStub = ethFactoryMock.mock('refresh', Promise.resolve()); const resolverValue = await setDividendsWalletModule.createSetDividendsWalletResolver( DividendType.Eth, From a588c7e3c04f67504295ae29d9e90027c1a11c70 Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Tue, 19 Nov 2019 13:15:58 -0800 Subject: [PATCH 07/21] feat: check tags and fees related to launch sto addTransaction call --- src/procedures/__tests__/LaunchCappedSto.ts | 36 ++++++++++++++----- .../__tests__/LaunchUsdTieredSto.ts | 36 +++++++++++++++---- 2 files changed, 56 insertions(+), 16 deletions(-) diff --git a/src/procedures/__tests__/LaunchCappedSto.ts b/src/procedures/__tests__/LaunchCappedSto.ts index ffde516..39e44e6 100644 --- a/src/procedures/__tests__/LaunchCappedSto.ts +++ b/src/procedures/__tests__/LaunchCappedSto.ts @@ -10,7 +10,13 @@ import { import { LaunchCappedSto } from '../../procedures/LaunchCappedSto'; import { Procedure } from '../../procedures/Procedure'; import { PolymathError } from '../../PolymathError'; -import { ErrorCode, LaunchCappedStoProcedureArgs, ProcedureType, StoType } from '../../types'; +import { + ErrorCode, + LaunchCappedStoProcedureArgs, + PolyTransactionTag, + ProcedureType, + StoType, +} from '../../types'; import * as cappedStoFactoryModule from '../../entities/factories/CappedStoFactory'; import * as utilsModule from '../../utils'; import * as contextModule from '../../Context'; @@ -37,6 +43,8 @@ const currentWallet = '0x8888888888888888888888888888888888888888'; const securityTokenAddress = '0x9999999999999999999999999999999999999999'; const polyTokenAddress = '0x5555555555555555555555555555555555555555'; const moduleFactoryAddress = '0x4444444444444444444444444444444444444444'; +const costInPoly = new BigNumber(5); +const costInUsd = new BigNumber(6); describe('LaunchCappedSto', () => { let target: LaunchCappedSto; @@ -69,13 +77,13 @@ describe('LaunchCappedSto', () => { wrappersMock.set('moduleFactory', moduleWrapperFactoryMock.getMockInstance()); securityTokenMock = ImportMock.mockClass(contractWrappersModule, 'SecurityToken_3_0_0'); - securityTokenMock.mock('address', Promise.resolve(params.storageWallet)); - securityTokenMock.mock('balanceOf', Promise.resolve(new BigNumber(1))); + securityTokenMock.mock('address', Promise.resolve(securityTokenAddress)); + securityTokenMock.mock('balanceOf', Promise.resolve(new BigNumber(10))); moduleFactoryMock = ImportMock.mockClass(contractWrappersModule, 'ModuleFactory_3_0_0'); - moduleFactoryMock.mock('setupCostInPoly', Promise.resolve(new BigNumber(1))); + moduleFactoryMock.mock('setupCostInPoly', Promise.resolve(costInPoly)); moduleFactoryMock.mock('isCostInPoly', Promise.resolve(false)); - moduleFactoryMock.mock('setupCost', Promise.resolve(new BigNumber(1))); + moduleFactoryMock.mock('setupCost', Promise.resolve(costInUsd)); tokenFactoryMock.mock( 'getSecurityTokenInstanceFromTicker', @@ -91,12 +99,12 @@ describe('LaunchCappedSto', () => { contextMock.set('currentWallet', new Wallet({ address: () => Promise.resolve(currentWallet) })); polyTokenMock = ImportMock.mockClass(contractWrappersModule, 'PolyToken'); - polyTokenMock.mock('balanceOf', Promise.resolve(new BigNumber(2))); - polyTokenMock.mock('address', Promise.resolve(params.treasuryWallet)); + polyTokenMock.mock('balanceOf', Promise.resolve(new BigNumber(20))); + polyTokenMock.mock('address', Promise.resolve(polyTokenAddress)); polyTokenMock.mock('allowance', Promise.resolve(new BigNumber(0))); + wrappersMock.set('polyToken', polyTokenMock.getMockInstance()); wrappersMock.mock('isTestnet', Promise.resolve(false)); - wrappersMock.mock('getModuleFactoryAddress', moduleFactoryAddress); // Instantiate LaunchCappedSto @@ -114,7 +122,7 @@ describe('LaunchCappedSto', () => { }); describe('LaunchCappedSto', () => { - test('should add a transaction to the queue to launch a capped sto', async () => { + test('should add a transaction to the queue to launch a capped sto with cost in usd', async () => { const addProcedureSpy = spy(target, 'addProcedure'); const addTransactionSpy = spy(target, 'addTransaction'); // Real call @@ -126,6 +134,11 @@ describe('LaunchCappedSto', () => { .getCall(0) .calledWith(securityTokenMock.getMockInstance().addModuleWithLabel) ).toEqual(true); + expect(addTransactionSpy.getCall(0).lastArg.fees).toEqual({ + usd: costInUsd, + poly: costInPoly, + }); + expect(addTransactionSpy.getCall(0).lastArg.tag).toEqual(PolyTransactionTag.EnableCappedSto); expect(addTransactionSpy.callCount).toEqual(1); expect(addProcedureSpy.getCall(0).calledWith(TransferErc20)).toEqual(true); expect(addProcedureSpy.callCount).toEqual(1); @@ -146,6 +159,11 @@ describe('LaunchCappedSto', () => { .getCall(0) .calledWith(securityTokenMock.getMockInstance().addModuleWithLabel) ).toEqual(true); + expect(addTransactionSpy.getCall(0).lastArg.fees).toEqual({ + usd: null, + poly: costInPoly, + }); + expect(addTransactionSpy.getCall(0).lastArg.tag).toEqual(PolyTransactionTag.EnableCappedSto); expect(addTransactionSpy.callCount).toEqual(1); expect(addProcedureSpy.getCall(0).calledWith(TransferErc20)).toEqual(true); expect(addProcedureSpy.callCount).toEqual(1); diff --git a/src/procedures/__tests__/LaunchUsdTieredSto.ts b/src/procedures/__tests__/LaunchUsdTieredSto.ts index 2535bb3..0829be5 100644 --- a/src/procedures/__tests__/LaunchUsdTieredSto.ts +++ b/src/procedures/__tests__/LaunchUsdTieredSto.ts @@ -10,7 +10,13 @@ import * as contractWrappersModule from '@polymathnetwork/contract-wrappers'; import { LaunchUsdTieredSto } from '../../procedures/LaunchUsdTieredSto'; import { Procedure } from '../Procedure'; import { PolymathError } from '../../PolymathError'; -import { ErrorCode, LaunchUsdTieredStoProcedureArgs, ProcedureType, StoType } from '../../types'; +import { + ErrorCode, + LaunchUsdTieredStoProcedureArgs, + PolyTransactionTag, + ProcedureType, + StoType, +} from '../../types'; import * as usdTieredStoFactoryModule from '~/entities/factories/UsdTieredStoFactory'; import * as utilsModule from '../../utils'; import * as contextModule from '../../Context'; @@ -44,6 +50,8 @@ const currentWallet = '0x8888888888888888888888888888888888888888'; const securityTokenAddress = '0x9999999999999999999999999999999999999999'; const polyTokenAddress = '0x5555555555555555555555555555555555555555'; const moduleFactoryAddress = '0x4444444444444444444444444444444444444444'; +const costInPoly = new BigNumber(5); +const costInUsd = new BigNumber(6); describe('LaunchUsdTieredSto', () => { let target: LaunchUsdTieredSto; @@ -81,13 +89,13 @@ describe('LaunchUsdTieredSto', () => { wrappersMock.set('moduleFactory', moduleWrapperFactoryMock.getMockInstance()); securityTokenMock = ImportMock.mockClass(contractWrappersModule, 'SecurityToken_3_0_0'); - securityTokenMock.mock('address', Promise.resolve(params.storageWallet)); - securityTokenMock.mock('balanceOf', Promise.resolve(new BigNumber(1))); + securityTokenMock.mock('address', Promise.resolve(securityTokenAddress)); + securityTokenMock.mock('balanceOf', Promise.resolve(new BigNumber(10))); moduleFactoryMock = ImportMock.mockClass(contractWrappersModule, 'ModuleFactory_3_0_0'); - moduleFactoryMock.mock('setupCostInPoly', Promise.resolve(new BigNumber(1))); + moduleFactoryMock.mock('setupCostInPoly', Promise.resolve(costInPoly)); moduleFactoryMock.mock('isCostInPoly', Promise.resolve(false)); - moduleFactoryMock.mock('setupCost', Promise.resolve(new BigNumber(1))); + moduleFactoryMock.mock('setupCost', Promise.resolve(costInUsd)); tokenFactoryStub = tokenFactoryMock.mock( 'getSecurityTokenInstanceFromTicker', @@ -108,8 +116,8 @@ describe('LaunchUsdTieredSto', () => { contextMock.set('currentWallet', new Wallet({ address: () => Promise.resolve(currentWallet) })); polyTokenMock = ImportMock.mockClass(contractWrappersModule, 'PolyToken'); - polyTokenMock.mock('balanceOf', Promise.resolve(new BigNumber(2))); - polyTokenMock.mock('address', Promise.resolve(params.treasuryWallet)); + polyTokenMock.mock('balanceOf', Promise.resolve(new BigNumber(20))); + polyTokenMock.mock('address', Promise.resolve(polyTokenAddress)); polyTokenMock.mock('allowance', Promise.resolve(new BigNumber(0))); wrappersMock.set('polyToken', polyTokenMock.getMockInstance()); wrappersMock.mock('isTestnet', Promise.resolve(false)); @@ -146,6 +154,13 @@ describe('LaunchUsdTieredSto', () => { .getCall(0) .calledWith(securityTokenMock.getMockInstance().addModuleWithLabel) ).toEqual(true); + expect(addTransactionSpy.getCall(0).lastArg.fees).toEqual({ + usd: costInUsd, + poly: costInPoly, + }); + expect(addTransactionSpy.getCall(0).lastArg.tag).toEqual( + PolyTransactionTag.EnableUsdTieredSto + ); expect(addTransactionSpy.callCount).toEqual(1); expect(addProcedureSpy.getCall(0).calledWith(TransferErc20)).toEqual(true); expect(addProcedureSpy.callCount).toEqual(1); @@ -165,6 +180,13 @@ describe('LaunchUsdTieredSto', () => { .getCall(0) .calledWith(securityTokenMock.getMockInstance().addModuleWithLabel) ).toEqual(true); + expect(addTransactionSpy.getCall(0).lastArg.fees).toEqual({ + usd: null, + poly: costInPoly, + }); + expect(addTransactionSpy.getCall(0).lastArg.tag).toEqual( + PolyTransactionTag.EnableUsdTieredSto + ); expect(addTransactionSpy.callCount).toEqual(1); expect(addProcedureSpy.getCall(0).calledWith(TransferErc20)).toEqual(true); expect(addProcedureSpy.callCount).toEqual(1); From 5cb7947fa9a1cde1c706024cba21d2c2a641bf68 Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Tue, 19 Nov 2019 13:17:35 -0800 Subject: [PATCH 08/21] feat: add prettier From cfe0dd7a0eff39519cb5e22c060fc32b8a676d81 Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Tue, 19 Nov 2019 13:41:23 -0800 Subject: [PATCH 09/21] test: that tags are being called in the last arg of addTransaction --- .../__tests__/ControllerTransfer.ts | 5 ++++- src/procedures/__tests__/CreateCheckpoint.ts | 5 +++-- .../CreateErc20DividendDistribution.ts | 11 +++++++++- .../CreateEtherDividendDistribution.ts | 11 +++++++++- .../__tests__/CreateSecurityToken.ts | 20 ++++++++++++------- src/procedures/__tests__/MintTokens.ts | 5 +++-- .../__tests__/ModifyShareholderData.ts | 13 ++++++++++-- src/procedures/__tests__/PauseSto.ts | 10 +++++++++- .../__tests__/SetDividendsWallet.ts | 8 +++++++- 9 files changed, 70 insertions(+), 18 deletions(-) diff --git a/src/procedures/__tests__/ControllerTransfer.ts b/src/procedures/__tests__/ControllerTransfer.ts index b4e7539..cdca3c8 100644 --- a/src/procedures/__tests__/ControllerTransfer.ts +++ b/src/procedures/__tests__/ControllerTransfer.ts @@ -10,7 +10,7 @@ import { ControllerTransfer } from '../../procedures/ControllerTransfer'; import * as controllerTransferModule from '../../procedures/ControllerTransfer'; import { Procedure } from '../../procedures/Procedure'; import { PolymathError } from '../../PolymathError'; -import { ErrorCode, ProcedureType } from '../../types'; +import { ErrorCode, PolyTransactionTag, ProcedureType } from '../../types'; import { mockFactories } from '../../testUtils/mockFactories'; import * as shareholderFactoryModule from '../../entities/factories/ShareholderFactory'; import { Factories } from '../../Context'; @@ -85,6 +85,9 @@ describe('ControllerTransfer', () => { .getCall(0) .calledWith(securityTokenMock.getMockInstance().controllerTransfer) ).toEqual(true); + expect(addTransactionSpy.getCall(0).lastArg.tag).toEqual( + PolyTransactionTag.ControllerTransfer + ); expect(addTransactionSpy.callCount).toEqual(1); }); diff --git a/src/procedures/__tests__/CreateCheckpoint.ts b/src/procedures/__tests__/CreateCheckpoint.ts index b15338a..8114062 100644 --- a/src/procedures/__tests__/CreateCheckpoint.ts +++ b/src/procedures/__tests__/CreateCheckpoint.ts @@ -7,7 +7,7 @@ import { SecurityTokenEvents } from '@polymathnetwork/contract-wrappers'; import { CreateCheckpoint } from '../../procedures/CreateCheckpoint'; import { Procedure } from '../../procedures/Procedure'; import { PolymathError } from '../../PolymathError'; -import { ErrorCode, ProcedureType } from '../../types'; +import { ErrorCode, PolyTransactionTag, ProcedureType } from '../../types'; import * as utilsModule from '../../utils'; import * as checkpointFactoryModule from '../../entities/factories/CheckpointFactory'; import * as contextModule from '../../Context'; @@ -80,8 +80,9 @@ describe('CreateCheckpoint', () => { expect( addTransactionSpy .getCall(0) - .calledWith(securityTokenMock.getMockInstance().controllerTransfer) + .calledWith(securityTokenMock.getMockInstance().createCheckpoint) ).toEqual(true); + expect(addTransactionSpy.getCall(0).lastArg.tag).toEqual(PolyTransactionTag.CreateCheckpoint); expect(addTransactionSpy.callCount).toEqual(1); }); diff --git a/src/procedures/__tests__/CreateErc20DividendDistribution.ts b/src/procedures/__tests__/CreateErc20DividendDistribution.ts index c2b8876..2676653 100644 --- a/src/procedures/__tests__/CreateErc20DividendDistribution.ts +++ b/src/procedures/__tests__/CreateErc20DividendDistribution.ts @@ -10,7 +10,7 @@ import * as tokenFactoryModule from '../../testUtils/MockedTokenFactoryModule'; import { CreateErc20DividendDistribution } from '../../procedures/CreateErc20DividendDistribution'; import { Procedure } from '../Procedure'; import { PolymathError } from '../../PolymathError'; -import { DividendType, ErrorCode, ProcedureType } from '../../types'; +import { DividendType, ErrorCode, PolyTransactionTag, ProcedureType } from '../../types'; import { ApproveErc20 } from '../ApproveErc20'; import * as dividendDistributionSecurityTokenFactoryModule from '../../entities/factories/DividendDistributionFactory'; import * as utilsModule from '../../utils'; @@ -109,6 +109,9 @@ describe('CreateErc20DividendDistribution', () => { erc20DividendsMock.getMockInstance().createDividendWithCheckpointAndExclusions ) ).toEqual(true); + expect(addTransactionSpy.getCall(0).lastArg.tag).toEqual( + PolyTransactionTag.CreateErc20DividendDistribution + ); expect(addTransactionSpy.callCount).toEqual(1); expect(addProcedureSpy.callCount).toEqual(1); }); @@ -140,9 +143,15 @@ describe('CreateErc20DividendDistribution', () => { erc20DividendsMock.getMockInstance().createDividendWithCheckpointAndExclusions ) ).toEqual(true); + expect(addTransactionSpy.getCall(0).lastArg.tag).toEqual( + PolyTransactionTag.CreateErc20DividendDistribution + ); expect( addTransactionSpy.getCall(1).calledWith(erc20DividendsMock.getMockInstance().setWithholding) ).toEqual(true); + expect(addTransactionSpy.getCall(1).lastArg.tag).toEqual( + PolyTransactionTag.SetErc20TaxWithholding + ); expect(addTransactionSpy.callCount).toEqual(2); expect(addProcedureSpy.callCount).toEqual(1); }); diff --git a/src/procedures/__tests__/CreateEtherDividendDistribution.ts b/src/procedures/__tests__/CreateEtherDividendDistribution.ts index cde52c1..d3dcf38 100644 --- a/src/procedures/__tests__/CreateEtherDividendDistribution.ts +++ b/src/procedures/__tests__/CreateEtherDividendDistribution.ts @@ -6,7 +6,7 @@ import * as contractWrappersModule from '@polymathnetwork/contract-wrappers'; import { CreateEtherDividendDistribution } from '../../procedures/CreateEtherDividendDistribution'; import { Procedure } from '../Procedure'; import { PolymathError } from '../../PolymathError'; -import { DividendType, ErrorCode, ProcedureType } from '../../types'; +import { DividendType, ErrorCode, PolyTransactionTag, ProcedureType } from '../../types'; import * as dividendDistributionSecurityTokenFactoryModule from '../../entities/factories/DividendDistributionFactory'; import * as utilsModule from '../../utils'; import * as contextModule from '../../Context'; @@ -94,6 +94,9 @@ describe('CreateEtherDividendDistribution', () => { etherDividendsMock.getMockInstance().createDividendWithCheckpointAndExclusions ) ).toEqual(true); + expect(addTransactionSpy.getCall(0).lastArg.tag).toEqual( + PolyTransactionTag.CreateEtherDividendDistribution + ); expect(addTransactionSpy.callCount).toEqual(1); }); @@ -123,9 +126,15 @@ describe('CreateEtherDividendDistribution', () => { etherDividendsMock.getMockInstance().createDividendWithCheckpointAndExclusions ) ).toEqual(true); + expect(addTransactionSpy.getCall(0).lastArg.tag).toEqual( + PolyTransactionTag.CreateEtherDividendDistribution + ); expect( addTransactionSpy.getCall(1).calledWith(etherDividendsMock.getMockInstance().setWithholding) ).toEqual(true); + expect(addTransactionSpy.getCall(1).lastArg.tag).toEqual( + PolyTransactionTag.SetEtherTaxWithholding + ); expect(addTransactionSpy.callCount).toEqual(2); }); diff --git a/src/procedures/__tests__/CreateSecurityToken.ts b/src/procedures/__tests__/CreateSecurityToken.ts index 43eb153..23962a7 100644 --- a/src/procedures/__tests__/CreateSecurityToken.ts +++ b/src/procedures/__tests__/CreateSecurityToken.ts @@ -10,7 +10,7 @@ import { CreateSecurityToken } from '../../procedures/CreateSecurityToken'; import { Procedure } from '../../procedures/Procedure'; import { Wallet } from '../../Wallet'; import { PolymathError } from '../../PolymathError'; -import { ErrorCode, ProcedureType } from '../../types'; +import { ErrorCode, PolyTransactionTag, ProcedureType } from '../../types'; import { ApproveErc20 } from '../ApproveErc20'; import * as securityTokenFactoryModule from '../../entities/factories/SecurityTokenFactory'; import * as utilsModule from '../../utils'; @@ -26,6 +26,9 @@ const params = { divisible: false, }; +const costInPoly = new BigNumber(5); +const costInUsd = new BigNumber(6); + describe('CreateSecurityToken', () => { let target: CreateSecurityToken; let contextMock: MockManager; @@ -54,10 +57,7 @@ describe('CreateSecurityToken', () => { securityTokenRegistryMock.mock('tickerAvailable', Promise.resolve(false)); securityTokenRegistryMock.mock('isTickerRegisteredByCurrentIssuer', Promise.resolve(true)); securityTokenRegistryMock.mock('isTokenLaunched', Promise.resolve(false)); - securityTokenRegistryMock.mock( - 'getFees', - Promise.resolve([new BigNumber(1), new BigNumber(1)]) - ); + securityTokenRegistryMock.mock('getFees', Promise.resolve([costInUsd, costInPoly])); securityTokenRegistryMock.mock('address', Promise.resolve(params.address)); contextMock.set('contractWrappers', wrappersMock.getMockInstance()); @@ -200,9 +200,15 @@ describe('CreateSecurityToken', () => { .getCall(0) .calledWith(securityTokenRegistryMock.getMockInstance().generateNewSecurityToken) ).toEqual(true); - + expect(addTransactionSpy.getCall(0).lastArg.fees).toEqual({ + usd: costInUsd, + poly: costInPoly, + }); + expect(addTransactionSpy.getCall(0).lastArg.tag).toEqual( + PolyTransactionTag.CreateSecurityToken + ); expect(addTransactionSpy.callCount).toEqual(1); - expect(addProcedureSpy.getCall(0).calledWith(ApproveErc20)).toEqual(true); + expect(addProcedureSpy.getCall(0).calledWithExactly(ApproveErc20)).toEqual(true); expect(addProcedureSpy.callCount).toEqual(1); }); diff --git a/src/procedures/__tests__/MintTokens.ts b/src/procedures/__tests__/MintTokens.ts index a480dc2..fef9064 100644 --- a/src/procedures/__tests__/MintTokens.ts +++ b/src/procedures/__tests__/MintTokens.ts @@ -8,7 +8,7 @@ import { Procedure } from '../../procedures/Procedure'; import * as shareholdersEntityModule from '../../entities/SecurityToken/Shareholders'; import * as securityTokenEntityModule from '../../entities/SecurityToken/SecurityToken'; import { PolymathError } from '../../PolymathError'; -import { ErrorCode, MintTokensProcedureArgs, ProcedureType } from '../../types'; +import { ErrorCode, MintTokensProcedureArgs, PolyTransactionTag, ProcedureType } from '../../types'; import * as securityTokenFactoryModule from '../../entities/factories/SecurityTokenFactory'; import * as shareholderFactoryModule from '../../entities/factories/ShareholderFactory'; import * as contextModule from '../../Context'; @@ -153,8 +153,9 @@ describe('MintTokens', () => { expect( addTransactionSpy.getCall(0).calledWith(securityTokenMock.getMockInstance().issueMulti) ).toEqual(true); + expect(addTransactionSpy.getCall(0).lastArg.tag).toEqual(PolyTransactionTag.IssueMulti); expect(addTransactionSpy.callCount).toEqual(1); - expect(addProcedureSpy.getCall(0).calledWith(ModifyShareholderData)).toEqual(true); + expect(addProcedureSpy.getCall(0).calledWithExactly(ModifyShareholderData)).toEqual(true); expect(addProcedureSpy.callCount).toEqual(1); }); diff --git a/src/procedures/__tests__/ModifyShareholderData.ts b/src/procedures/__tests__/ModifyShareholderData.ts index 8a8d814..7ee3f5d 100644 --- a/src/procedures/__tests__/ModifyShareholderData.ts +++ b/src/procedures/__tests__/ModifyShareholderData.ts @@ -6,7 +6,7 @@ import { BigNumber, GeneralTransferManager_3_0_0 } from '@polymathnetwork/contra import { cloneDeep } from 'lodash'; import { ModifyShareholderData } from '../../procedures/ModifyShareholderData'; import { Procedure } from '../../procedures/Procedure'; -import { ErrorCode, ProcedureType } from '../../types'; +import { ErrorCode, PolyTransactionTag, ProcedureType } from '../../types'; import * as shareholderFactoryModule from '../../entities/factories/ShareholderFactory'; import * as securityTokenFactoryModule from '../../entities/factories/SecurityTokenFactory'; import * as contextModule from '../../Context'; @@ -140,7 +140,7 @@ describe('ModifyShareholderData', () => { }); describe('ModifyShareholderData', () => { - test('should add a transaction to the queue to modify the shareholders data', async () => { + test('should add a transaction to the queue to modify the shareholders kyc data and flags', async () => { const addTransactionSpy = spy(target, 'addTransaction'); // Real call @@ -149,9 +149,15 @@ describe('ModifyShareholderData', () => { expect(addTransactionSpy.getCall(0).calledWith(gtmMockInstance.modifyKYCDataMulti)).toEqual( true ); + expect(addTransactionSpy.getCall(0).lastArg.tag).toEqual( + PolyTransactionTag.ModifyKycDataMulti + ); expect( addTransactionSpy.getCall(1).calledWith(gtmMockInstance.modifyInvestorFlagMulti) ).toEqual(true); + expect(addTransactionSpy.getCall(1).lastArg.tag).toEqual( + PolyTransactionTag.ModifyInvestorFlagMulti + ); expect(addTransactionSpy.callCount).toEqual(2); }); @@ -246,6 +252,9 @@ describe('ModifyShareholderData', () => { expect(addTransactionSpy.getCall(0).calledWith(gtmMockInstance.modifyKYCDataMulti)).toEqual( true ); + expect(addTransactionSpy.getCall(0).lastArg.tag).toEqual( + PolyTransactionTag.ModifyKycDataMulti + ); expect(addTransactionSpy.callCount).toEqual(1); }); diff --git a/src/procedures/__tests__/PauseSto.ts b/src/procedures/__tests__/PauseSto.ts index b0931b8..f92a534 100644 --- a/src/procedures/__tests__/PauseSto.ts +++ b/src/procedures/__tests__/PauseSto.ts @@ -4,7 +4,13 @@ import * as contractWrappersModule from '@polymathnetwork/contract-wrappers'; import { PauseSto } from '../../procedures/PauseSto'; import { Procedure } from '../../procedures/Procedure'; import { PolymathError } from '../../PolymathError'; -import { ErrorCode, PauseStoProcedureArgs, ProcedureType, StoType } from '../../types'; +import { + ErrorCode, + PauseStoProcedureArgs, + PolyTransactionTag, + ProcedureType, + StoType, +} from '../../types'; import * as pauseStoModule from '../../procedures/PauseSto'; import * as cappedStoFactoryModule from '../../entities/factories/CappedStoFactory'; import * as usdTieredStoFactoryModule from '../../entities/factories/UsdTieredStoFactory'; @@ -117,6 +123,7 @@ describe('PauseSto', () => { expect( addTransactionSpy.getCall(0).calledWith(cappedStoMock.getMockInstance().pause) ).toEqual(true); + expect(addTransactionSpy.getCall(0).lastArg.tag).toEqual(PolyTransactionTag.PauseSto); expect(addTransactionSpy.callCount).toEqual(1); }); @@ -131,6 +138,7 @@ describe('PauseSto', () => { expect( addTransactionSpy.getCall(0).calledWith(usdTieredStoMock.getMockInstance().pause) ).toEqual(true); + expect(addTransactionSpy.getCall(0).lastArg.tag).toEqual(PolyTransactionTag.PauseSto); expect(addTransactionSpy.callCount).toEqual(1); }); diff --git a/src/procedures/__tests__/SetDividendsWallet.ts b/src/procedures/__tests__/SetDividendsWallet.ts index 5e49826..bbbc519 100644 --- a/src/procedures/__tests__/SetDividendsWallet.ts +++ b/src/procedures/__tests__/SetDividendsWallet.ts @@ -8,7 +8,7 @@ import * as tokenFactoryModule from '../../testUtils/MockedTokenFactoryModule'; import { SetDividendsWallet } from '../../procedures/SetDividendsWallet'; import * as setDividendsWalletModule from '../../procedures/SetDividendsWallet'; import { Procedure } from '../../procedures/Procedure'; -import { ProcedureType, DividendType, ErrorCode } from '../../types'; +import { ProcedureType, DividendType, ErrorCode, PolyTransactionTag } from '../../types'; import { PolymathError } from '../../PolymathError'; import { mockFactories } from '../../testUtils/mockFactories'; import * as erc20FactoryModule from '../../entities/factories/Erc20DividendsManagerFactory'; @@ -166,6 +166,9 @@ describe('SetDividendsWallet', () => { expect( addTransactionSpy.getCall(0).calledWith(erc20DividendMock.getMockInstance().changeWallet) ).toEqual(true); + expect(addTransactionSpy.getCall(0).lastArg.tag).toEqual( + PolyTransactionTag.SetDividendsWallet + ); expect(addTransactionSpy.callCount).toEqual(1); }); @@ -191,6 +194,9 @@ describe('SetDividendsWallet', () => { expect( addTransactionSpy.getCall(0).calledWith(ethDividendMock.getMockInstance().changeWallet) ).toEqual(true); + expect(addTransactionSpy.getCall(0).lastArg.tag).toEqual( + PolyTransactionTag.SetDividendsWallet + ); expect(addTransactionSpy.callCount).toEqual(1); }); From b99d2fa5c761d610a631ca4f9d5cfba955cc1300 Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Wed, 20 Nov 2019 05:46:51 -0800 Subject: [PATCH 10/21] refactor: approverErc20 with mocks for calledWith, prettier --- src/procedures/__tests__/ApproveErc20.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/procedures/__tests__/ApproveErc20.ts b/src/procedures/__tests__/ApproveErc20.ts index 2c6c79c..4c19722 100644 --- a/src/procedures/__tests__/ApproveErc20.ts +++ b/src/procedures/__tests__/ApproveErc20.ts @@ -87,6 +87,7 @@ describe('ApproveErc20', () => { target = new ApproveErc20(params, contextMock.getMockInstance()); const addTransactionSpy = spy(target, 'addTransaction'); + polyTokenMock.mock('approve', Promise.resolve('Approve')); // Real call await target.prepareTransactions(); @@ -111,13 +112,14 @@ describe('ApproveErc20', () => { target = new ApproveErc20({ ...params, tokenAddress }, contextMock.getMockInstance()); const addTransactionSpy = spy(target, 'addTransaction'); + erc20Mock.mock('approve', Promise.resolve('Approve')); // Real call await target.prepareTransactions(); // Verifications expect( - addTransactionSpy.getCall(0).calledWithExactly(polyTokenMock.getMockInstance().approve, { + addTransactionSpy.getCall(0).calledWithExactly(erc20Mock.getMockInstance().approve, { tag: PolyTransactionTag.ApproveErc20, }) ).toEqual(true); @@ -151,6 +153,8 @@ describe('ApproveErc20', () => { target = new ApproveErc20(params, contextMock.getMockInstance()); const addTransactionSpy = spy(target, 'addTransaction'); + polyTokenMock.mock('approve', Promise.resolve('Approve')); + wrappersMock.mock('getPolyTokens', Promise.resolve('GetPolyTokens')); // Real call await target.prepareTransactions(); From f8d0870c997736d3d910b565cdd65e40f841d70f Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Wed, 20 Nov 2019 06:05:43 -0800 Subject: [PATCH 11/21] refactor: assign role procedures with correct gpm mocks for calledwith --- src/procedures/__tests__/AssignSecurityTokenRole.ts | 5 +++++ src/procedures/__tests__/AssignStoRole.ts | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/src/procedures/__tests__/AssignSecurityTokenRole.ts b/src/procedures/__tests__/AssignSecurityTokenRole.ts index e5147f7..56066e2 100644 --- a/src/procedures/__tests__/AssignSecurityTokenRole.ts +++ b/src/procedures/__tests__/AssignSecurityTokenRole.ts @@ -83,6 +83,8 @@ describe('AssignSecurityTokenRole', () => { describe('AssignSecurityTokenRole', () => { test('should add a change permission transaction to the queue with an existing delegate address', async () => { const addTransactionSpy = spy(target, 'addTransaction'); + gpmMock.mock('changePermission', Promise.resolve('ChangePermission')); + // Real call await target.prepareTransactions(); @@ -98,6 +100,9 @@ describe('AssignSecurityTokenRole', () => { test('should add transactions to the queue for add delegate and change permissions with a new delegate address', async () => { gpmMock.mock('getAllDelegates', Promise.resolve([])); const addTransactionSpy = spy(target, 'addTransaction'); + gpmMock.mock('addDelegate', Promise.resolve('AddDelegate')); + gpmMock.mock('changePermission', Promise.resolve('ChangePermission')); + // Real call await target.prepareTransactions(); diff --git a/src/procedures/__tests__/AssignStoRole.ts b/src/procedures/__tests__/AssignStoRole.ts index 14e3f4d..dc773c1 100644 --- a/src/procedures/__tests__/AssignStoRole.ts +++ b/src/procedures/__tests__/AssignStoRole.ts @@ -53,6 +53,8 @@ describe('AssignStoRole', () => { describe('AssignStoRole', () => { test('should add transaction to the queue to change permission for an sto', async () => { const addTransactionSpy = spy(target, 'addTransaction'); + gpmMock.mock('changePermission', Promise.resolve('ChangePermission')); + // Real call await target.prepareTransactions(); @@ -68,6 +70,9 @@ describe('AssignStoRole', () => { test('should add transaction to the queue to add delegate and change permission for a new delegate in an sto', async () => { gpmMock.mock('getAllDelegates', Promise.resolve([])); const addTransactionSpy = spy(target, 'addTransaction'); + gpmMock.mock('addDelegate', Promise.resolve('AddDelegate')); + gpmMock.mock('changePermission', Promise.resolve('ChangePermission')); + // Real call await target.prepareTransactions(); @@ -91,6 +96,8 @@ describe('AssignStoRole', () => { contextMock.getMockInstance() ); const addTransactionSpy = spy(target, 'addTransaction'); + gpmMock.mock('changePermission', Promise.resolve('ChangePermission')); + // Real call await target.prepareTransactions(); From 6db3b7bc6b37a1dd7633dbda05bc04eb5fa4a039 Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Wed, 20 Nov 2019 06:59:11 -0800 Subject: [PATCH 12/21] refactor: create checkpoint, distr calledWith valid arguments, prettier --- src/procedures/__tests__/CreateCheckpoint.ts | 1 + .../__tests__/CreateErc20DividendDistribution.ts | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/procedures/__tests__/CreateCheckpoint.ts b/src/procedures/__tests__/CreateCheckpoint.ts index 8114062..13e269e 100644 --- a/src/procedures/__tests__/CreateCheckpoint.ts +++ b/src/procedures/__tests__/CreateCheckpoint.ts @@ -73,6 +73,7 @@ describe('CreateCheckpoint', () => { describe('createCheckpoint', () => { test('should add a transaction to the queue to create a new checkpoint', async () => { const addTransactionSpy = spy(target, 'addTransaction'); + securityTokenMock.mock('createCheckpoint', Promise.resolve('CreateCheckpoint')); // Real call await target.prepareTransactions(); diff --git a/src/procedures/__tests__/CreateErc20DividendDistribution.ts b/src/procedures/__tests__/CreateErc20DividendDistribution.ts index 2676653..cb6b3b8 100644 --- a/src/procedures/__tests__/CreateErc20DividendDistribution.ts +++ b/src/procedures/__tests__/CreateErc20DividendDistribution.ts @@ -97,11 +97,16 @@ describe('CreateErc20DividendDistribution', () => { test('should add a transaction to the queue to create an erc20 dividend distribution and to approve erc20 token', async () => { const addProcedureSpy = spy(target, 'addProcedure'); const addTransactionSpy = spy(target, 'addTransaction'); + erc20DividendsMock.mock( + 'createDividendWithCheckpointAndExclusions', + Promise.resolve('CreateDividendWithCheckpointAndExclusions') + ); + // Real call await target.prepareTransactions(); // Verifications - expect(addProcedureSpy.getCall(0).calledWith(ApproveErc20)).toEqual(true); + expect(addProcedureSpy.getCall(0).calledWithExactly(ApproveErc20)).toEqual(true); expect( addTransactionSpy .getCall(0) @@ -131,11 +136,17 @@ describe('CreateErc20DividendDistribution', () => { ); const addProcedureSpy = spy(target, 'addProcedure'); const addTransactionSpy = spy(target, 'addTransaction'); + erc20DividendsMock.mock( + 'createDividendWithCheckpointAndExclusions', + Promise.resolve('CreateDividendWithCheckpointAndExclusions') + ); + erc20DividendsMock.mock('setWithholding', Promise.resolve('SetWithholding')); + // Real call await target.prepareTransactions(); // Verifications - expect(addProcedureSpy.getCall(0).calledWith(ApproveErc20)).toEqual(true); + expect(addProcedureSpy.getCall(0).calledWithExactly(ApproveErc20)).toEqual(true); expect( addTransactionSpy .getCall(0) From cdb96d4ce1eeed882192be013990a031cfadbe07 Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Wed, 20 Nov 2019 07:07:50 -0800 Subject: [PATCH 13/21] refactor: controllerTransfer prettier and valid calledWith --- src/procedures/__tests__/ControllerTransfer.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/procedures/__tests__/ControllerTransfer.ts b/src/procedures/__tests__/ControllerTransfer.ts index cdca3c8..4cd5bd6 100644 --- a/src/procedures/__tests__/ControllerTransfer.ts +++ b/src/procedures/__tests__/ControllerTransfer.ts @@ -76,6 +76,8 @@ describe('ControllerTransfer', () => { describe('ControllerTransfer', () => { test('should add a transaction to the queue to execute a controller transfer', async () => { const addTransactionSpy = spy(target, 'addTransaction'); + securityTokenMock.mock('controllerTransfer', Promise.resolve('ControllerTransfer')); + // Real call await target.prepareTransactions(); From 0b56abf02f56697a79f5c24eda0cb8bd7ac27451 Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Wed, 20 Nov 2019 07:37:44 -0800 Subject: [PATCH 14/21] refactor: create st, distr, enable managers calledWith/prettier --- .../__tests__/CreateEtherDividendDistribution.ts | 11 +++++++++++ src/procedures/__tests__/CreateSecurityToken.ts | 5 +++++ src/procedures/__tests__/EnableDividendManagers.ts | 2 ++ .../__tests__/EnableGeneralPermissionManager.ts | 2 ++ src/procedures/__tests__/LaunchCappedSto.ts | 7 +++++-- 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/procedures/__tests__/CreateEtherDividendDistribution.ts b/src/procedures/__tests__/CreateEtherDividendDistribution.ts index d3dcf38..abbf0ae 100644 --- a/src/procedures/__tests__/CreateEtherDividendDistribution.ts +++ b/src/procedures/__tests__/CreateEtherDividendDistribution.ts @@ -83,6 +83,11 @@ describe('CreateEtherDividendDistribution', () => { describe('CreateEtherDividendDistribution', () => { test('should add the transaction to the queue to create an ether dividend distribution', async () => { const addTransactionSpy = spy(target, 'addTransaction'); + etherDividendsMock.mock( + 'createDividendWithCheckpointAndExclusions', + Promise.resolve('CreateDividendWithCheckpointAndExclusions') + ); + // Real call await target.prepareTransactions(); @@ -115,6 +120,12 @@ describe('CreateEtherDividendDistribution', () => { ); const addTransactionSpy = spy(target, 'addTransaction'); + etherDividendsMock.mock( + 'createDividendWithCheckpointAndExclusions', + Promise.resolve('CreateDividendWithCheckpointAndExclusions') + ); + etherDividendsMock.mock('setWithholding', Promise.resolve('SetWithholding')); + // Real call await target.prepareTransactions(); diff --git a/src/procedures/__tests__/CreateSecurityToken.ts b/src/procedures/__tests__/CreateSecurityToken.ts index 23962a7..40bcf7c 100644 --- a/src/procedures/__tests__/CreateSecurityToken.ts +++ b/src/procedures/__tests__/CreateSecurityToken.ts @@ -191,6 +191,11 @@ describe('CreateSecurityToken', () => { test('should add the transaction to the queue to create the security token and approve erc20 transfer', async () => { const addProcedureSpy = spy(target, 'addProcedure'); const addTransactionSpy = spy(target, 'addTransaction'); + securityTokenRegistryMock.mock( + 'generateNewSecurityToken', + Promise.resolve('GenerateNewSecurityToken') + ); + // Real call await target.prepareTransactions(); diff --git a/src/procedures/__tests__/EnableDividendManagers.ts b/src/procedures/__tests__/EnableDividendManagers.ts index beddf95..84c8d7d 100644 --- a/src/procedures/__tests__/EnableDividendManagers.ts +++ b/src/procedures/__tests__/EnableDividendManagers.ts @@ -64,6 +64,8 @@ describe('EnableDividendManagers', () => { describe('EnableDividendManagers', () => { test('should add a transaction to the queue to enable dividend managers', async () => { const addTransactionSpy = spy(target, 'addTransaction'); + securityTokenMock.mock('addModuleWithLabel', Promise.resolve('AddModuleWithLabel')); + // Real call await target.prepareTransactions(); diff --git a/src/procedures/__tests__/EnableGeneralPermissionManager.ts b/src/procedures/__tests__/EnableGeneralPermissionManager.ts index c145ecb..3dca716 100644 --- a/src/procedures/__tests__/EnableGeneralPermissionManager.ts +++ b/src/procedures/__tests__/EnableGeneralPermissionManager.ts @@ -63,6 +63,8 @@ describe('EnableGeneralPermissionManager', () => { describe('EnableGeneralPermissionManager', () => { test('should add a transaction to the queue to enable general permission manager', async () => { const addTransactionSpy = spy(target, 'addTransaction'); + securityTokenMock.mock('addModuleWithLabel', Promise.resolve('AddModuleWithLabel')); + // Real call await target.prepareTransactions(); diff --git a/src/procedures/__tests__/LaunchCappedSto.ts b/src/procedures/__tests__/LaunchCappedSto.ts index 39e44e6..c753ee3 100644 --- a/src/procedures/__tests__/LaunchCappedSto.ts +++ b/src/procedures/__tests__/LaunchCappedSto.ts @@ -125,6 +125,8 @@ describe('LaunchCappedSto', () => { test('should add a transaction to the queue to launch a capped sto with cost in usd', async () => { const addProcedureSpy = spy(target, 'addProcedure'); const addTransactionSpy = spy(target, 'addTransaction'); + securityTokenMock.mock('addModuleWithLabel', Promise.resolve('AddModuleWithLabel')); + // Real call await target.prepareTransactions(); @@ -140,7 +142,7 @@ describe('LaunchCappedSto', () => { }); expect(addTransactionSpy.getCall(0).lastArg.tag).toEqual(PolyTransactionTag.EnableCappedSto); expect(addTransactionSpy.callCount).toEqual(1); - expect(addProcedureSpy.getCall(0).calledWith(TransferErc20)).toEqual(true); + expect(addProcedureSpy.getCall(0).calledWithExactly(TransferErc20)).toEqual(true); expect(addProcedureSpy.callCount).toEqual(1); }); @@ -149,6 +151,7 @@ describe('LaunchCappedSto', () => { const addTransactionSpy = spy(target, 'addTransaction'); moduleFactoryMock.mock('isCostInPoly', Promise.resolve(true)); + securityTokenMock.mock('addModuleWithLabel', Promise.resolve('AddModuleWithLabel')); // Real call await target.prepareTransactions(); @@ -165,7 +168,7 @@ describe('LaunchCappedSto', () => { }); expect(addTransactionSpy.getCall(0).lastArg.tag).toEqual(PolyTransactionTag.EnableCappedSto); expect(addTransactionSpy.callCount).toEqual(1); - expect(addProcedureSpy.getCall(0).calledWith(TransferErc20)).toEqual(true); + expect(addProcedureSpy.getCall(0).calledWithExactly(TransferErc20)).toEqual(true); expect(addProcedureSpy.callCount).toEqual(1); }); From 12e0fef1a798c59514b6388278743b563a3311eb Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Wed, 20 Nov 2019 07:38:50 -0800 Subject: [PATCH 15/21] refactor: launch usdTieredSto calledWith valid args and prettier --- src/procedures/__tests__/LaunchUsdTieredSto.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/procedures/__tests__/LaunchUsdTieredSto.ts b/src/procedures/__tests__/LaunchUsdTieredSto.ts index 0829be5..25aedac 100644 --- a/src/procedures/__tests__/LaunchUsdTieredSto.ts +++ b/src/procedures/__tests__/LaunchUsdTieredSto.ts @@ -145,6 +145,8 @@ describe('LaunchUsdTieredSto', () => { test('should add the transaction to the queue to launch usd tiered sto and add a procedure to transfer erc20 token', async () => { const addProcedureSpy = spy(target, 'addProcedure'); const addTransactionSpy = spy(target, 'addTransaction'); + securityTokenMock.mock('addModuleWithLabel', Promise.resolve('AddModuleWithLabel')); + // Real call await target.prepareTransactions(); @@ -162,15 +164,16 @@ describe('LaunchUsdTieredSto', () => { PolyTransactionTag.EnableUsdTieredSto ); expect(addTransactionSpy.callCount).toEqual(1); - expect(addProcedureSpy.getCall(0).calledWith(TransferErc20)).toEqual(true); + expect(addProcedureSpy.getCall(0).calledWithExactly(TransferErc20)).toEqual(true); expect(addProcedureSpy.callCount).toEqual(1); }); test('should add the transaction to the queue to launch usd tiered sto with cost in poly', async () => { const addProcedureSpy = spy(target, 'addProcedure'); const addTransactionSpy = spy(target, 'addTransaction'); - + securityTokenMock.mock('addModuleWithLabel', Promise.resolve('AddModuleWithLabel')); moduleFactoryMock.mock('isCostInPoly', Promise.resolve(true)); + // Real call await target.prepareTransactions(); @@ -188,7 +191,7 @@ describe('LaunchUsdTieredSto', () => { PolyTransactionTag.EnableUsdTieredSto ); expect(addTransactionSpy.callCount).toEqual(1); - expect(addProcedureSpy.getCall(0).calledWith(TransferErc20)).toEqual(true); + expect(addProcedureSpy.getCall(0).calledWithExactly(TransferErc20)).toEqual(true); expect(addProcedureSpy.callCount).toEqual(1); }); From bfa6123b9a596219eee15326ebee5078f1337e75 Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Wed, 20 Nov 2019 07:39:33 -0800 Subject: [PATCH 16/21] refactor: calledWith, prettier for mintToken and modifyShData --- src/procedures/__tests__/MintTokens.ts | 2 ++ src/procedures/__tests__/ModifyShareholderData.ts | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/procedures/__tests__/MintTokens.ts b/src/procedures/__tests__/MintTokens.ts index fef9064..e28a55e 100644 --- a/src/procedures/__tests__/MintTokens.ts +++ b/src/procedures/__tests__/MintTokens.ts @@ -146,6 +146,8 @@ describe('MintTokens', () => { test('should add the transaction to the queue to mint tokens and add a procedure to modify shareholder data', async () => { const addProcedureSpy = spy(target, 'addProcedure'); const addTransactionSpy = spy(target, 'addTransaction'); + securityTokenMock.mock('issueMulti', Promise.resolve('IssueMulti')); + // Real call await target.prepareTransactions(); diff --git a/src/procedures/__tests__/ModifyShareholderData.ts b/src/procedures/__tests__/ModifyShareholderData.ts index 7ee3f5d..3621533 100644 --- a/src/procedures/__tests__/ModifyShareholderData.ts +++ b/src/procedures/__tests__/ModifyShareholderData.ts @@ -142,6 +142,8 @@ describe('ModifyShareholderData', () => { describe('ModifyShareholderData', () => { test('should add a transaction to the queue to modify the shareholders kyc data and flags', async () => { const addTransactionSpy = spy(target, 'addTransaction'); + gtmMock.mock('modifyKYCDataMulti', Promise.resolve('ModifyKYCDataMulti')); + gtmMock.mock('modifyInvestorFlagMulti', Promise.resolve('ModifyInvestorFlagMulti')); // Real call await target.prepareTransactions(); @@ -245,6 +247,7 @@ describe('ModifyShareholderData', () => { paramsWithoutFlagsChange.shareholderData[1].canBuyFromSto = false; target = new ModifyShareholderData(paramsWithoutFlagsChange, contextMock.getMockInstance()); const addTransactionSpy = spy(target, 'addTransaction'); + gtmMock.mock('modifyKYCDataMulti', Promise.resolve('ModifyKYCDataMulti')); // Real call await target.prepareTransactions(); From 49a285c642f291f54e4c504995cc9642633fcb31 Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Wed, 20 Nov 2019 07:48:52 -0800 Subject: [PATCH 17/21] fix: review comment --- src/procedures/__tests__/ModifyShareholderData.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/procedures/__tests__/ModifyShareholderData.ts b/src/procedures/__tests__/ModifyShareholderData.ts index 3621533..75e33e1 100644 --- a/src/procedures/__tests__/ModifyShareholderData.ts +++ b/src/procedures/__tests__/ModifyShareholderData.ts @@ -123,7 +123,7 @@ describe('ModifyShareholderData', () => { gtmMock = ImportMock.mockClass(contractWrappersModule, 'GeneralTransferManager_3_0_0'); gtmMockInstance = gtmMock.getMockInstance(); - wrappersMock.mock('getAttachedModules', [gtmMockInstance]); + wrappersMock.mock('getAttachedModules', Promise.resolve([gtmMockInstance])); // Instantiate ModifyShareholderData target = new ModifyShareholderData(params, contextMock.getMockInstance()); From f8860b44b7a805afffbee64b855eb6a93bdf2d49 Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Wed, 20 Nov 2019 07:49:42 -0800 Subject: [PATCH 18/21] test: set dividend wallet calledWith change, prettier --- src/procedures/__tests__/SetDividendsWallet.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/procedures/__tests__/SetDividendsWallet.ts b/src/procedures/__tests__/SetDividendsWallet.ts index bbbc519..0080cf7 100644 --- a/src/procedures/__tests__/SetDividendsWallet.ts +++ b/src/procedures/__tests__/SetDividendsWallet.ts @@ -158,6 +158,7 @@ describe('SetDividendsWallet', () => { ); const addTransactionSpy = spy(target, 'addTransaction'); + erc20DividendMock.mock('changeWallet', Promise.resolve('ChangeWallet')); // Real call await target.prepareTransactions(); @@ -186,6 +187,7 @@ describe('SetDividendsWallet', () => { wrappersMock.mock('getAttachedModules', Promise.resolve([ethDividendMock.getMockInstance()])); const addTransactionSpy = spy(target, 'addTransaction'); + ethDividendMock.mock('changeWallet', Promise.resolve('ChangeWallet')); // Real call await target.prepareTransactions(); From 4a311be636d7a48a849535cf7022b3279f198afe Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Wed, 20 Nov 2019 07:50:07 -0800 Subject: [PATCH 19/21] refactor: prettier for modifyShareholderData From 5ee5b0206425e8a03a0646d1cafff6fcde06b227 Mon Sep 17 00:00:00 2001 From: Victor Wiebe Date: Wed, 20 Nov 2019 08:25:16 -0800 Subject: [PATCH 20/21] fix: bug in pauseSto, calledWith args, prettier --- src/procedures/__tests__/PauseSto.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/procedures/__tests__/PauseSto.ts b/src/procedures/__tests__/PauseSto.ts index f92a534..d9adeca 100644 --- a/src/procedures/__tests__/PauseSto.ts +++ b/src/procedures/__tests__/PauseSto.ts @@ -53,7 +53,7 @@ describe('PauseSto', () => { let usdTieredStoFactoryMock: MockManager; let securityTokenMock: MockManager; - let moduleFactoryMock: MockManager; + let factoryMockSetup: Factories; let securityTokenId: string; @@ -73,15 +73,11 @@ describe('PauseSto', () => { securityTokenMock = ImportMock.mockClass(contractWrappersModule, 'SecurityToken_3_0_0'); - moduleFactoryMock = ImportMock.mockClass(contractWrappersModule, 'ModuleFactory_3_0_0'); - tokenFactoryMock.mock( 'getSecurityTokenInstanceFromTicker', securityTokenMock.getMockInstance() ); - moduleWrapperFactoryMock.mock('getModuleInstance', moduleFactoryMock.getMockInstance()); - cappedStoFactoryMock = ImportMock.mockClass(cappedStoFactoryModule, 'CappedStoFactory'); usdTieredStoFactoryMock = ImportMock.mockClass( @@ -99,6 +95,8 @@ describe('PauseSto', () => { securityTokenId = SecurityToken.generateId({ symbol: cappedParams.symbol }); + moduleWrapperFactoryMock.mock('getModuleInstance', cappedStoMock.getMockInstance()); + // Instantiate PauseSto target = new PauseSto(cappedParams, contextMock.getMockInstance()); }); @@ -116,10 +114,12 @@ describe('PauseSto', () => { describe('PauseSto', () => { test('should add the transaction to the queue to pause a capped sto', async () => { const addTransactionSpy = spy(target, 'addTransaction'); + cappedStoMock.mock('pause', Promise.resolve('Pause')); + // Real call await target.prepareTransactions(); - // Verifications + // Verifications\ expect( addTransactionSpy.getCall(0).calledWith(cappedStoMock.getMockInstance().pause) ).toEqual(true); @@ -128,9 +128,12 @@ describe('PauseSto', () => { }); test('should add the transaction to the queue to pause a usdTiered sto', async () => { + moduleWrapperFactoryMock.mock('getModuleInstance', usdTieredStoMock.getMockInstance()); target = new PauseSto(usdTieredParams, contextMock.getMockInstance()); const addTransactionSpy = spy(target, 'addTransaction'); + usdTieredStoMock.mock('pause', Promise.resolve('Pause')); + // Real call await target.prepareTransactions(); From ab36efddded71d07a048c85bbb729d922142fa6c Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 20 Nov 2019 16:48:44 +0000 Subject: [PATCH 21/21] chore(release): 2.0.1-beta.56 [skip ci] ## [2.0.1-beta.56](https://github.com/PolymathNetwork/polymath-sdk/compare/v2.0.1-beta.55@beta...v2.0.1-beta.56@beta) (2019-11-20) ### Bug Fixes * add prettier to files missing it ([73884ea](https://github.com/PolymathNetwork/polymath-sdk/commit/73884ea)) * add shareholder factory mock instance ([ec5554c](https://github.com/PolymathNetwork/polymath-sdk/commit/ec5554c)) * bug in mint tokens ([68a4bc7](https://github.com/PolymathNetwork/polymath-sdk/commit/68a4bc7)) * bug in pauseSto, calledWith args, prettier ([5ee5b02](https://github.com/PolymathNetwork/polymath-sdk/commit/5ee5b02)) * bug with mintTokens test ([bdee0a6](https://github.com/PolymathNetwork/polymath-sdk/commit/bdee0a6)) * build issue ([aa632e1](https://github.com/PolymathNetwork/polymath-sdk/commit/aa632e1)) * cloneDeep issue and prettier ([06ea717](https://github.com/PolymathNetwork/polymath-sdk/commit/06ea717)) * createEtherDividendDistribution refactor naming and object ([32a676b](https://github.com/PolymathNetwork/polymath-sdk/commit/32a676b)) * get launchcappedsto to pass fully ([5a3c84f](https://github.com/PolymathNetwork/polymath-sdk/commit/5a3c84f)) * incorrect module name reference ([260bc7a](https://github.com/PolymathNetwork/polymath-sdk/commit/260bc7a)) * initial review issues ([62cacc6](https://github.com/PolymathNetwork/polymath-sdk/commit/62cacc6)) * launchCappedSto issue ([2ce4b99](https://github.com/PolymathNetwork/polymath-sdk/commit/2ce4b99)) * mint Tokens tests now pass ([ca95696](https://github.com/PolymathNetwork/polymath-sdk/commit/ca95696)) * mockFactories issue in launch sto branch ([23c8117](https://github.com/PolymathNetwork/polymath-sdk/commit/23c8117)) * remove unnecessary code in launchcappedsto ([f04d30f](https://github.com/PolymathNetwork/polymath-sdk/commit/f04d30f)) * review comment ([49a285c](https://github.com/PolymathNetwork/polymath-sdk/commit/49a285c)) * verifications correctly for modifyShareholders ([5579d58](https://github.com/PolymathNetwork/polymath-sdk/commit/5579d58)) ### Features * add mocks to resolve issues in transferErc20 for launchcappedsto ([995eb61](https://github.com/PolymathNetwork/polymath-sdk/commit/995eb61)) * add prettier ([5cb7947](https://github.com/PolymathNetwork/polymath-sdk/commit/5cb7947)) * check tags and fees related to launch sto addTransaction call ([a588c7e](https://github.com/PolymathNetwork/polymath-sdk/commit/a588c7e)) * continue improving modify shareholder data ([2dabfc6](https://github.com/PolymathNetwork/polymath-sdk/commit/2dabfc6)) * getting launch STO to pass tests ([906ed35](https://github.com/PolymathNetwork/polymath-sdk/commit/906ed35)) * improve mint tokens coverage ([cacaeb2](https://github.com/PolymathNetwork/polymath-sdk/commit/cacaeb2)) * skeleton for mint tokens, issues persist with generateId ([403836c](https://github.com/PolymathNetwork/polymath-sdk/commit/403836c)) --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ec1080c..86bae1a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@polymathnetwork/sdk", - "version": "2.0.1-beta.55", + "version": "2.0.1-beta.56", "description": "A Javascript SDK for interacting with the Polymath network for the browser and Node.js", "bugs": { "url": "https://github.com/PolymathNetwork/polymath-sdk/issues"