@@ -1906,6 +1906,45 @@ describe("GeneralIndexModule", () => {
1906
1906
} ) ;
1907
1907
} ) ;
1908
1908
1909
+ describe ( "#getAllowedTraders" , async ( ) => {
1910
+ let subjectTraders : Address [ ] ;
1911
+ let subjectStatuses : boolean [ ] ;
1912
+
1913
+ beforeEach ( async ( ) => {
1914
+ subjectCaller = owner ;
1915
+ subjectSetToken = index ;
1916
+ subjectTraders = [ trader . address ] ;
1917
+ subjectStatuses = [ true ] ;
1918
+
1919
+ return await indexModule . connect ( subjectCaller . wallet ) . setTraderStatus (
1920
+ subjectSetToken . address ,
1921
+ subjectTraders ,
1922
+ subjectStatuses
1923
+ ) ;
1924
+ } ) ;
1925
+
1926
+ async function subject ( ) : Promise < Boolean > {
1927
+ return await indexModule . connect ( subjectCaller . wallet ) . getAllowedTraders ( subjectSetToken . address ) ;
1928
+ }
1929
+
1930
+ it ( "returns trader status" , async ( ) => {
1931
+ await subject ( ) ;
1932
+
1933
+ const expectedTraders = await subject ( ) ;
1934
+ expect ( expectedTraders ) . to . deep . equal ( subjectTraders ) ;
1935
+ } ) ;
1936
+
1937
+ describe ( "when the setToken is not valid" , async ( ) => {
1938
+ beforeEach ( ( ) => {
1939
+ subjectSetToken = { address : ADDRESS_ZERO } as SetToken ;
1940
+ } ) ;
1941
+
1942
+ it ( "should revert" , async ( ) => {
1943
+ expect ( subject ( ) ) . to . be . revertedWith ( "Must be a valid and initialized SetToken" ) ;
1944
+ } ) ;
1945
+ } ) ;
1946
+ } ) ;
1947
+
1909
1948
describe ( "#setRaiseTargetPercentage" , async ( ) => {
1910
1949
let subjectRaiseTargetPercentage : BigNumber ;
1911
1950
@@ -2197,12 +2236,27 @@ describe("GeneralIndexModule", () => {
2197
2236
const preConditionTrader = await indexModule . getIsAllowedTrader ( subjectSetToken . address , subjectTraders [ 0 ] ) ;
2198
2237
expect ( preConditionTrader ) . to . be . true ;
2199
2238
2200
-
2201
2239
await subject ( ) ;
2202
2240
2203
2241
const postConditionTrader = await indexModule . getIsAllowedTrader ( subjectSetToken . address , subjectTraders [ 0 ] ) ;
2204
2242
expect ( postConditionTrader ) . to . be . false ;
2205
2243
} ) ;
2244
+
2245
+ it ( "the tradersHistory should be updated correctly" , async ( ) => {
2246
+ const preConditionTraders = await indexModule . getAllowedTraders ( subjectSetToken . address ) ;
2247
+ expect ( preConditionTraders ) . to . deep . equal ( subjectTraders ) ;
2248
+
2249
+ await subject ( ) ;
2250
+
2251
+ const postConditionTraders = await indexModule . getAllowedTraders ( subjectSetToken . address ) ;
2252
+ const expectedTraders = subjectTraders . slice ( 1 ) ;
2253
+
2254
+ expect ( expectedTraders [ 0 ] ) . to . not . equal ( expectedTraders [ 1 ] ) ;
2255
+ expect ( postConditionTraders [ 0 ] ) . to . not . equal ( postConditionTraders [ 1 ] ) ;
2256
+
2257
+ expect ( postConditionTraders . includes ( expectedTraders [ 0 ] ) ) . to . be . true ;
2258
+ expect ( postConditionTraders . includes ( expectedTraders [ 1 ] ) ) . to . be . true ;
2259
+ } ) ;
2206
2260
} ) ;
2207
2261
2208
2262
describe ( "when array lengths don't match" , async ( ) => {
0 commit comments