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

Commit 5574fef

Browse files
author
Victor Wiebe
committed
feat: add upper and lower STVersionBounds with tests
1 parent 372b257 commit 5574fef

File tree

2 files changed

+72
-16
lines changed

2 files changed

+72
-16
lines changed

src/contract_wrappers/modules/__tests__/module_factory_wrapper.test.ts

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ describe('ModuleFactoryWrapper', () => {
150150
// Address expected
151151
const expectedResult = new BigNumber(100);
152152
// Mocked method
153-
const mockedMethod = mock(MockedSendMethod);
153+
const mockedMethod = mock(MockedCallMethod);
154154
// Stub the method
155155
when(mockedContract.setupCost).thenReturn(instance(mockedMethod));
156156
// Stub the request
@@ -166,6 +166,48 @@ describe('ModuleFactoryWrapper', () => {
166166
});
167167
});
168168

169+
describe('getUpperSTVersionBounds', () => {
170+
test('should get UpperSTVersionBounds', async () => {
171+
// Address expected
172+
const expectedResult = [new BigNumber(1), new BigNumber(2)];
173+
// Mocked method
174+
const mockedMethod = mock(MockedCallMethod);
175+
// Stub the method
176+
when(mockedContract.getUpperSTVersionBounds).thenReturn(instance(mockedMethod));
177+
// Stub the request
178+
when(mockedMethod.callAsync()).thenResolve(expectedResult);
179+
180+
// Real call
181+
const result = await target.getUpperSTVersionBounds();
182+
// Result expectation
183+
expect(result).toEqual(expectedResult);
184+
// Verifications
185+
verify(mockedContract.getUpperSTVersionBounds).once();
186+
verify(mockedMethod.callAsync()).once();
187+
});
188+
});
189+
190+
describe('getLowerSTVersionBounds', () => {
191+
test('should get LowerSTVersionBounds', async () => {
192+
// Address expected
193+
const expectedResult = [new BigNumber(1), new BigNumber(2)];
194+
// Mocked method
195+
const mockedMethod = mock(MockedCallMethod);
196+
// Stub the method
197+
when(mockedContract.getLowerSTVersionBounds).thenReturn(instance(mockedMethod));
198+
// Stub the request
199+
when(mockedMethod.callAsync()).thenResolve(expectedResult);
200+
201+
// Real call
202+
const result = await target.getLowerSTVersionBounds();
203+
// Result expectation
204+
expect(result).toEqual(expectedResult);
205+
// Verifications
206+
verify(mockedContract.getLowerSTVersionBounds).once();
207+
verify(mockedMethod.callAsync()).once();
208+
});
209+
});
210+
169211
describe('setupCostInPoly', () => {
170212
test('should get setupCostInPoly', async () => {
171213
// Address expected

src/contract_wrappers/modules/module_factory_wrapper.ts

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -120,21 +120,35 @@ export default class ModuleFactoryWrapper extends ContractWrapper {
120120
return (await this.contract).version.callAsync();
121121
};
122122

123-
/**
124-
* Get setup cost
125-
*/
126-
public setupCost = async (): Promise<BigNumber> => {
127-
const value = await (await this.contract).setupCost.callAsync();
128-
return weiToValue(value, FULL_DECIMALS);
129-
};
130-
131-
/**
132-
* Get setup cost in poly
133-
*/
134-
public setupCostInPoly = async (): Promise<BigNumber> => {
135-
const value = await (await this.contract).setupCostInPoly.callAsync();
136-
return weiToValue(value, FULL_DECIMALS);
137-
};
123+
/**
124+
* Get setup cost
125+
*/
126+
public setupCost = async (): Promise<BigNumber> => {
127+
const value = await (await this.contract).setupCost.callAsync();
128+
return weiToValue(value, FULL_DECIMALS);
129+
};
130+
131+
/**
132+
* Get upper ST version bounds
133+
*/
134+
public getUpperSTVersionBounds = async (): Promise<BigNumber[]> => {
135+
return (await (await this.contract).getUpperSTVersionBounds.callAsync()).map(v => new BigNumber(v));
136+
};
137+
138+
/**
139+
* Get lower ST version bounds
140+
*/
141+
public getLowerSTVersionBounds = async (): Promise<BigNumber[]> => {
142+
return (await (await this.contract).getLowerSTVersionBounds.callAsync()).map(v => new BigNumber(v));
143+
};
144+
145+
/**
146+
* Get setup cost in poly
147+
*/
148+
public setupCostInPoly = async (): Promise<BigNumber> => {
149+
const value = await (await this.contract).setupCostInPoly.callAsync();
150+
return weiToValue(value, FULL_DECIMALS);
151+
};
138152

139153
/**
140154
* Subscribe to an event type emitted by the contract.

0 commit comments

Comments
 (0)