Skip to content
This repository was archived by the owner on Jul 6, 2022. It is now read-only.

Commit 9cfde5e

Browse files
author
Victor Wiebe
committed
feat: getListOfAddresses method and test. prettier
1 parent 92119d7 commit 9cfde5e

File tree

2 files changed

+43
-6
lines changed

2 files changed

+43
-6
lines changed

src/contract_wrappers/modules/transfer_manager/__tests__/lock_up_transfer_manager_wrapper.test.ts

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,7 @@ describe('LockUpTransferManagerWrapper', () => {
329329
describe('getAllLockUpData', () => {
330330
test('should call to getAllLockupData', async () => {
331331
const expectedDecimalsResult = new BigNumber(18);
332-
const expectedNames = stringArrayToBytes32Array([
333-
'Lockup1',
334-
'Lockup2',
335-
]);
332+
const expectedNames = stringArrayToBytes32Array(['Lockup1', 'Lockup2']);
336333
const expectedLockupAmount = valueToWei(new BigNumber(2), expectedDecimalsResult);
337334
const startTime = new Date(2030, 1);
338335
const expectedStartTime = dateToBigNumber(startTime);
@@ -372,14 +369,14 @@ describe('LockUpTransferManagerWrapper', () => {
372369
const result = await target.getAllLockupData();
373370
// Result expectation
374371
expect(result[0].lockupName).toEqual(expectedResult[0][0]);
375-
for(let i=0; i<result.length; i+=1) {
372+
for (let i = 0; i < result.length; i += 1) {
376373
expect(result[1].lockupName).toEqual(bytes32ArrayToStringArray(expectedNames));
377374
expect(result[i].lockupAmount).toEqual(weiToValue(expectedLockupAmount, expectedDecimalsResult));
378375
expect(result[i].startTime).toEqual(startTime);
379376
expect(result[i].lockUpPeriodSeconds).toBe(expectedResult[2]);
380377
expect(result[i].releaseFrequencySeconds).toBe(expectedResult[3]);
381378
expect(result[i].unlockedAmount).toEqual(weiToValue(expectedUnlockedAmount, expectedDecimalsResult));
382-
};
379+
}
383380

384381
// Verifications
385382
verify(mockedContract.getAllLockupData).once();
@@ -392,6 +389,38 @@ describe('LockUpTransferManagerWrapper', () => {
392389
});
393390
});
394391

392+
describe('getListOfAddresses', () => {
393+
test.todo('should fail as lockup name is an empty string');
394+
395+
test('should call to getListOfAddresses', async () => {
396+
const expectedResult = [
397+
'0x8888888888888888888888888888888888888888',
398+
'0x9999999999999999999999999999999999999999',
399+
];
400+
const mockedParams = {
401+
lockupName: 'LockupDetails',
402+
};
403+
404+
// Mocked method
405+
const mockedMethod = mock(MockedCallMethod);
406+
// Stub the method
407+
when(mockedContract.getListOfAddresses).thenReturn(instance(mockedMethod));
408+
// Stub the request
409+
when(mockedMethod.callAsync(objectContaining(stringToBytes32(mockedParams.lockupName)))).thenResolve(
410+
expectedResult,
411+
);
412+
413+
// Real call
414+
const result = await target.getListOfAddresses(mockedParams);
415+
// Result expectation
416+
expect(result).toEqual(expectedResult);
417+
418+
// Verifications
419+
verify(mockedContract.getListOfAddresses).once();
420+
verify(mockedMethod.callAsync(objectContaining(stringToBytes32(mockedParams.lockupName)))).once();
421+
});
422+
});
423+
395424
describe('verifyTransfer', () => {
396425
test('should verify Transfer', async () => {
397426
const statusCode = new BigNumber(2);

src/contract_wrappers/modules/transfer_manager/lock_up_transfer_manager_wrapper.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,14 @@ export default class LockUpTransferManagerWrapper extends ModuleWrapper {
252252
return typedResult;
253253
};
254254

255+
/**
256+
* getListOfAddresses
257+
*/
258+
public getListOfAddresses = async (params: LockupsParams): Promise<string[]> => {
259+
assert.assert(params.lockupName.length > 0, 'LockUp Details must not be an empty string');
260+
return (await this.contract).getListOfAddresses.callAsync(stringToBytes32(params.lockupName));
261+
};
262+
255263
public verifyTransfer = async (params: VerifyTransferParams): Promise<VerifyTransfer> => {
256264
assert.isETHAddressHex('from', params.from);
257265
assert.isETHAddressHex('to', params.to);

0 commit comments

Comments
 (0)