Skip to content

Commit 3ebab63

Browse files
author
Victor Wiebe
committed
fix: last review changes for branch
1 parent 09cf7b4 commit 3ebab63

File tree

3 files changed

+22
-53
lines changed

3 files changed

+22
-53
lines changed

src/procedures/__tests__/EnableDividendManagers.ts

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ImportMock, MockManager } from 'ts-mock-imports';
2-
import { SinonStub, stub, spy, restore } from 'sinon';
2+
import { stub, spy, restore } from 'sinon';
33
import { BigNumber } from '@polymathnetwork/contract-wrappers';
44
import * as contractWrappersModule from '@polymathnetwork/contract-wrappers';
55
import * as contextModule from '../../Context';
@@ -10,14 +10,9 @@ import { Procedure } from '~/procedures/Procedure';
1010
import { PolymathError } from '~/PolymathError';
1111
import { ErrorCode, PolyTransactionTag } from '~/types';
1212

13-
const params1 = {
13+
const params = {
1414
symbol: 'TEST1',
15-
name: 'Test Token 1',
16-
amount: new BigNumber(1),
17-
checkpointIndex: 1,
18-
maturityDate: new Date(2030, 1),
19-
expiryDate: new Date(2031, 1),
20-
address: '0x4444444444444444444444444444444444444444',
15+
storageWalletAddress: '0x5555555555555555555555555555555555555555',
2116
};
2217

2318
describe('EnableDividendManagers', () => {
@@ -27,41 +22,30 @@ describe('EnableDividendManagers', () => {
2722
let tokenFactoryMock: MockManager<tokenFactoryModule.MockedTokenFactoryObject>;
2823
let etherDividendsMock: MockManager<contractWrappersModule.EtherDividendCheckpoint_3_0_0>;
2924
let securityTokenMock: MockManager<contractWrappersModule.SecurityToken_3_0_0>;
30-
let tokenFactoryMockStub: SinonStub<any, any>;
31-
let getAttachedModulesMockStub: SinonStub<any, any>;
3225

3326
beforeAll(() => {
34-
// Mock the context, wrappers, and tokenFactory to test CreateEtherDividendDistribution
27+
// Mock the context, wrappers, and tokenFactory to test EnableDividendManagers
3528
contextMock = ImportMock.mockClass(contextModule, 'Context');
3629
wrappersMock = ImportMock.mockClass(wrappersModule, 'PolymathBase');
3730
tokenFactoryMock = ImportMock.mockClass(tokenFactoryModule, 'MockedTokenFactoryObject');
3831
contextMock.set('contractWrappers', wrappersMock.getMockInstance());
3932
wrappersMock.set('tokenFactory', tokenFactoryMock.getMockInstance());
4033

4134
securityTokenMock = ImportMock.mockClass(contractWrappersModule, 'SecurityToken_3_0_0');
42-
securityTokenMock.mock('address', Promise.resolve(params1.address));
35+
securityTokenMock.mock('address', Promise.resolve(params.storageWalletAddress));
4336

4437
etherDividendsMock = ImportMock.mockClass(
4538
contractWrappersModule,
4639
'EtherDividendCheckpoint_3_0_0'
4740
);
48-
getAttachedModulesMockStub = wrappersMock.mock(
49-
'getModuleFactoryAddress',
50-
Promise.resolve(params1.address)
51-
);
52-
tokenFactoryMockStub = tokenFactoryMock.mock(
41+
wrappersMock.mock('getModuleFactoryAddress', Promise.resolve(params.storageWalletAddress));
42+
tokenFactoryMock.mock(
5343
'getSecurityTokenInstanceFromTicker',
5444
securityTokenMock.getMockInstance()
5545
);
5646

5747
// Instantiate EnableDividendManagers
58-
target = new EnableDividendManagers(
59-
{
60-
symbol: params1.symbol,
61-
storageWalletAddress: params1.address,
62-
},
63-
contextMock.getMockInstance()
64-
);
48+
target = new EnableDividendManagers(params, contextMock.getMockInstance());
6549
});
6650
afterEach(() => {
6751
restore();
@@ -75,7 +59,7 @@ describe('EnableDividendManagers', () => {
7559
});
7660

7761
describe('EnableDividendManagers', () => {
78-
test('should send the transaction to EnableDividendManagers', async () => {
62+
test('should add a transaction to the queue to enable dividend managers', async () => {
7963
const addTransactionSpy = spy(target, 'addTransaction');
8064
// Real call
8165
await target.prepareTransactions();
@@ -102,14 +86,14 @@ describe('EnableDividendManagers', () => {
10286
tokenFactoryMock.set(
10387
'getSecurityTokenInstanceFromTicker',
10488
stub()
105-
.withArgs({ address: params1.symbol })
89+
.withArgs({ address: params.symbol })
10690
.throws()
10791
);
10892

10993
expect(target.prepareTransactions()).rejects.toThrow(
11094
new PolymathError({
11195
code: ErrorCode.ProcedureValidationError,
112-
message: `There is no Security Token with symbol ${params1.symbol}`,
96+
message: `There is no Security Token with symbol ${params.symbol}`,
11397
})
11498
);
11599
});

src/procedures/__tests__/EnableGeneralPermissionManager.ts

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ImportMock, MockManager } from 'ts-mock-imports';
2-
import { SinonStub, stub, spy, restore } from 'sinon';
2+
import { stub, spy, restore } from 'sinon';
33
import { BigNumber } from '@polymathnetwork/contract-wrappers';
44
import * as contractWrappersModule from '@polymathnetwork/contract-wrappers';
55
import * as contextModule from '../../Context';
@@ -10,13 +10,8 @@ import { Procedure } from '~/procedures/Procedure';
1010
import { PolymathError } from '~/PolymathError';
1111
import { ErrorCode, PolyTransactionTag } from '~/types';
1212

13-
const params1 = {
13+
const params = {
1414
symbol: 'TEST1',
15-
name: 'Test Token 1',
16-
amount: new BigNumber(1),
17-
checkpointIndex: 1,
18-
maturityDate: new Date(2030, 1),
19-
expiryDate: new Date(2031, 1),
2015
address: '0x4444444444444444444444444444444444444444',
2116
};
2217

@@ -27,40 +22,30 @@ describe('EnableGeneralPermissionManager', () => {
2722
let tokenFactoryMock: MockManager<tokenFactoryModule.MockedTokenFactoryObject>;
2823
let etherDividendsMock: MockManager<contractWrappersModule.EtherDividendCheckpoint_3_0_0>;
2924
let securityTokenMock: MockManager<contractWrappersModule.SecurityToken_3_0_0>;
30-
let tokenFactoryMockStub: SinonStub<any, any>;
31-
let getAttachedModulesMockStub: SinonStub<any, any>;
3225

3326
beforeAll(() => {
34-
// Mock the context, wrappers, and tokenFactory to test CreateEtherDividendDistribution
27+
// Mock the context, wrappers, and tokenFactory to test EnableGeneralPermissionManagers
3528
contextMock = ImportMock.mockClass(contextModule, 'Context');
3629
wrappersMock = ImportMock.mockClass(wrappersModule, 'PolymathBase');
3730
tokenFactoryMock = ImportMock.mockClass(tokenFactoryModule, 'MockedTokenFactoryObject');
3831
contextMock.set('contractWrappers', wrappersMock.getMockInstance());
3932
wrappersMock.set('tokenFactory', tokenFactoryMock.getMockInstance());
4033

4134
securityTokenMock = ImportMock.mockClass(contractWrappersModule, 'SecurityToken_3_0_0');
42-
securityTokenMock.mock('address', Promise.resolve(params1.address));
35+
securityTokenMock.mock('address', Promise.resolve(params.address));
4336

4437
etherDividendsMock = ImportMock.mockClass(
4538
contractWrappersModule,
4639
'EtherDividendCheckpoint_3_0_0'
4740
);
48-
getAttachedModulesMockStub = wrappersMock.mock(
49-
'getModuleFactoryAddress',
50-
Promise.resolve(params1.address)
51-
);
52-
tokenFactoryMockStub = tokenFactoryMock.mock(
41+
wrappersMock.mock('getModuleFactoryAddress', Promise.resolve(params.address));
42+
tokenFactoryMock.mock(
5343
'getSecurityTokenInstanceFromTicker',
5444
securityTokenMock.getMockInstance()
5545
);
5646

57-
// Instantiate EnableGeneralPermissionManager
58-
target = new EnableGeneralPermissionManager(
59-
{
60-
symbol: params1.symbol,
61-
},
62-
contextMock.getMockInstance()
63-
);
47+
// Instantiate EnableGeneralPermissionManagers
48+
target = new EnableGeneralPermissionManager(params, contextMock.getMockInstance());
6449
});
6550
afterEach(() => {
6651
restore();
@@ -74,7 +59,7 @@ describe('EnableGeneralPermissionManager', () => {
7459
});
7560

7661
describe('EnableGeneralPermissionManager', () => {
77-
test('should send the transaction to EnableGeneralPermissionManager', async () => {
62+
test('should add a transaction to the queue to enable general permission manager', async () => {
7863
const addTransactionSpy = spy(target, 'addTransaction');
7964
// Real call
8065
await target.prepareTransactions();
@@ -94,14 +79,14 @@ describe('EnableGeneralPermissionManager', () => {
9479
tokenFactoryMock.set(
9580
'getSecurityTokenInstanceFromTicker',
9681
stub()
97-
.withArgs({ address: params1.symbol })
82+
.withArgs({ address: params.symbol })
9883
.throws()
9984
);
10085

10186
expect(target.prepareTransactions()).rejects.toThrow(
10287
new PolymathError({
10388
code: ErrorCode.ProcedureValidationError,
104-
message: `There is no Security Token with symbol ${params1.symbol}`,
89+
message: `There is no Security Token with symbol ${params.symbol}`,
10590
})
10691
);
10792
});
File renamed without changes.

0 commit comments

Comments
 (0)