@@ -18,7 +18,7 @@ import {
18
18
makeSelectedTemplateForSecurityToken ,
19
19
makeSecurityTokenOffering ,
20
20
} from './util/make_examples' ;
21
- import { makeWeb3Wrapper } from './util/web3' ;
21
+ import { makeWeb3Wrapper , makeWeb3 } from './util/web3' ;
22
22
import { fakeAddress , fakeBytes32 } from './util/fake' ;
23
23
24
24
const { assert } = chai ;
@@ -97,6 +97,42 @@ describe('Compliance wrapper', () => {
97
97
} ) ;
98
98
99
99
it ( 'proposeTemplate, templateReputation, getTemplateAddressByProposal, cancelTemplateProposal, getAllTemplateProposals' , async ( ) => {
100
+
101
+
102
+ //subscribtion setup
103
+ let subscriptionID2 = null ;
104
+ const eventName2 = 'LogNewTemplateProposal' ;
105
+ const indexedFilterValues2 = [ "_securityToken" ] ;
106
+
107
+ //the callback is passed into the filter.watch function and is operated on when a new event comes in
108
+ const logNewTemplateProposalArgsPromise = new Promise ( ( resolve , reject ) => {
109
+
110
+ subscriptionID2 = compliance . subscribe ( eventName2 , indexedFilterValues2 , ( err , log ) => {
111
+ if ( err !== null ) {
112
+ reject ( err ) ;
113
+ return ;
114
+ }
115
+ resolve ( log . args ) ;
116
+ } ) ;
117
+ } ) ;
118
+
119
+ //subscribtion setup
120
+ let subscriptionID4 = null ;
121
+ const eventName4 = 'LogCancelTemplateProposal' ;
122
+ const indexedFilterValues4 = [ "_securityToken" ] ;
123
+
124
+ //the callback is passed into the filter.watch function, and is operated on when a new event comes in
125
+ const logCancleTemplateProposalArgsPromise = new Promise ( ( resolve , reject ) => {
126
+
127
+ subscriptionID4 = compliance . subscribe ( eventName4 , indexedFilterValues4 , ( err , log ) => {
128
+ if ( err !== null ) {
129
+ reject ( err ) ;
130
+ return ;
131
+ }
132
+ resolve ( log . args ) ;
133
+ } ) ;
134
+ } ) ;
135
+
100
136
await makeKYCProvider ( customers , accounts [ 1 ] , expiryTime ) ;
101
137
await makeLegalDelegate ( polyToken , customers , accounts [ 1 ] , accounts [ 2 ] , expiryTime ) ;
102
138
const templateAddress = await makeTemplateWithFinalized (
@@ -107,11 +143,17 @@ describe('Compliance wrapper', () => {
107
143
108
144
) ;
109
145
146
+
110
147
// Propose Template
111
148
await compliance . proposeTemplate ( accounts [ 2 ] , securityToken . address , templateAddress ) ;
112
149
const logs = await compliance . getLogs ( 'LogNewTemplateProposal' , { } , { fromBlock : 1 } ) ;
113
150
assert . equal ( logs [ 0 ] . args . _template , templateAddress , 'Template address does not match the logged version' ) ;
114
151
152
+
153
+ let logNewTemplateProposal = await logNewTemplateProposalArgsPromise ;
154
+ assert . equal ( logNewTemplateProposal . _securityToken , securityToken . address , 'ST address not picked up from LogNewTemplateProposal event' ) //needs to be renamed from core
155
+
156
+
115
157
// Reputation
116
158
let templateReputation = await compliance . getTemplateReputation ( templateAddress ) ;
117
159
assert . equal ( templateReputation . owner , accounts [ 2 ] , "TemplateReputation not stored or read properly" ) ;
@@ -124,30 +166,72 @@ describe('Compliance wrapper', () => {
124
166
let arrayOfTemplates = await compliance . getAllTemplateProposals ( securityToken . address )
125
167
assert . equal ( arrayOfTemplates [ 0 ] , templateAddress , 'Template address does not match the getter function return' ) ;
126
168
127
- // Cancel Proposal
169
+
128
170
await compliance . cancelTemplateProposal ( accounts [ 2 ] , securityToken . address , 0 ) ;
129
171
172
+ let logCancleTemplateProposal = await logCancleTemplateProposalArgsPromise ;
173
+ assert . equal ( logNewTemplateProposal . _securityToken , securityToken . address , 'ST address not picked up from LogCancleTemplateProposal event' ) //needs to be renamed from core
174
+
130
175
const addressShouldBeZero = await compliance . getTemplateAddressByProposal ( securityToken . address , 0 )
131
176
assert . equal ( addressShouldBeZero , 0 , 'Proposal returned the wrong template address' ) ;
132
177
178
+ await compliance . unsubscribeAll ( ) ;
133
179
134
-
135
- } ) ;
180
+ } ) ;
136
181
137
182
138
183
it ( 'getMinimumVestingPeriod' , async ( ) => {
139
184
let minimum = await compliance . getMinimumVestingPeriod ( ) ;
140
185
assert . equal ( minimum , 60 * 60 * 24 * 100 , "Does not equal 100 days, when it should" )
141
186
} )
142
187
143
- //so we need to have a securityToken actually created through STRegistrar
144
- //and so me of the stuff has to match up
145
- //then we have an actual one in offeringProposals
188
+ // so we need to have a securityToken actually created through STRegistrar
189
+ // and so me of the stuff has to match up
190
+ // then we have an actual one in offeringProposals
146
191
it ( 'setSTO, proposeSTO, cancleSTO, getSTOProposal, getSTOAddressByProposal, getAllOfferingProposals' , async ( ) => {
192
+
193
+ //subscribtion setup
194
+ let subscriptionID3 = null ;
195
+ const eventName3 = 'LogNewContractProposal' ;
196
+ const indexedFilterValues3 = [ "_securityToken" ] ;
197
+
198
+ //the callback is passed into the filter.watch function, and is operated on when a new event comes in
199
+ const logNewContractProposalArgsPromise = new Promise ( ( resolve , reject ) => {
200
+
201
+ subscriptionID3 = compliance . subscribe ( eventName3 , indexedFilterValues3 , ( err , log ) => {
202
+ if ( err !== null ) {
203
+ reject ( err ) ;
204
+ return ;
205
+ }
206
+ resolve ( log . args ) ;
207
+ } ) ;
208
+ } ) ;
209
+
210
+
211
+
212
+ //subscribtion setup
213
+ let subscriptionID5 = null ;
214
+ const eventName5 = 'LogCancelContractProposal' ;
215
+ const indexedFilterValues5 = [ "_securityToken" ] ;
216
+
217
+ //the callback is passed into the filter.watch function, and is operated on when a new event comes in
218
+ const logCancleContractProposalArgsPromise = new Promise ( ( resolve , reject ) => {
219
+
220
+ subscriptionID5 = compliance . subscribe ( eventName5 , indexedFilterValues5 , ( err , log ) => {
221
+ if ( err !== null ) {
222
+ reject ( err ) ;
223
+ return ;
224
+ }
225
+ resolve ( log . args ) ;
226
+ } ) ;
227
+ } ) ;
228
+
229
+
147
230
const owner = accounts [ 0 ] ;
148
231
const legalDelegate = accounts [ 2 ] ;
149
232
const kycProvider = accounts [ 1 ] ;
150
233
234
+
151
235
// STO variables
152
236
const auditor = accounts [ 4 ] ;
153
237
const startTime = new BigNumber (
@@ -160,11 +244,12 @@ describe('Compliance wrapper', () => {
160
244
161
245
await makeKYCProvider ( customers , kycProvider ) ;
162
246
163
- await makeLegalDelegate ( polyToken , customers , kycProvider , legalDelegate ) ;
247
+ await makeLegalDelegate ( polyToken , customers , accounts [ 1 ] , accounts [ 2 ] , expiryTime ) ;
164
248
const templateAddress = await makeTemplateWithFinalized (
165
249
compliance ,
166
250
kycProvider ,
167
251
legalDelegate ,
252
+ expiryTime ,
168
253
) ;
169
254
170
255
await makeSelectedTemplateForSecurityToken (
@@ -201,6 +286,10 @@ describe('Compliance wrapper', () => {
201
286
endTime ,
202
287
) ;
203
288
289
+
290
+ let logNewContractProposal = await logNewContractProposalArgsPromise ;
291
+ assert . equal ( logNewContractProposal . _delegate , auditor , 'legal delegate not picked up from LogNewProposal event' ) //needs to be renamed from core
292
+
204
293
//to confirm setSTO, we need to check offerings for the msg.sender addr
205
294
//which is using getOfferingByProposal
206
295
//in setSTO we
@@ -214,96 +303,62 @@ describe('Compliance wrapper', () => {
214
303
let getAllOfferings = await compliance . getAllOfferingProposals ( securityToken . address , 0 )
215
304
assert . equal ( getAllOfferings [ 0 ] , getSTO . stoContractAddress , "STO array of addresses not read properly" ) ;
216
305
306
+
217
307
// Cancel Proposal
218
308
await compliance . cancelSTOProposal ( auditor , securityToken . address , 0 ) ;
219
309
310
+ //LOGCANCLESTOPROPOSAL
311
+ let logCancleContractProposal = await logCancleContractProposalArgsPromise ;
312
+ assert . equal ( logNewContractProposal . _securityToken , securityToken . address , 'ST address not picked up from LogCancleContractProposal event' ) //needs to be renamed from core
313
+
314
+
315
+
220
316
const addressShouldBeZero = await compliance . getSTOAddressByProposal ( securityToken . address , 0 )
221
- console . log ( addressShouldBeZero )
222
317
assert . equal ( addressShouldBeZero , 0 , 'Proposal did not return zero, which it should have for being cancelled' ) ;
223
318
319
+ await compliance . unsubscribe ( subscriptionID3 ) ;
320
+ await compliance . unsubscribe ( subscriptionID5 ) ;
224
321
225
322
226
323
} )
227
324
228
- it ( 'subscribe, unsubscribe, unsubscribeAll' , async ( ) => {
229
-
230
- //LogTemplateCreated
231
- //LogNewTemplateProposal
232
- //LogCancleTemplateProposal
233
- //LogNewContractProposal
234
- //LogCancleContractProposal
235
-
236
- it ( 'subscribe, unsubscribe, unsubscribeAll' , async ( ) => {
237
-
238
- //subscribtion setup
239
- let subscriptionID1 = null ;
240
- const eventName1 = 'LogTemplateCreated' ;
241
- const indexedFilterValues1 = [ "_creator" ] ;
242
- const expiryTime = new BigNumber ( web3 . eth . getBlock ( 'latest' ) . timestamp ) . plus ( 10000 ) ;
243
- //the callback is passed into the filter.watch function, and is operated on when a new event comes in
244
- const logTemplateCreatedArgsPromise = new Promise ( ( resolve , reject ) => {
245
- subscriptionID1 = compliance . subscribe ( eventName1 , indexedFilterValues1 , ( err , log ) => {
246
- if ( err !== null ) {
247
- reject ( err ) ;
248
- return ;
249
- }
250
- resolve ( log . args ) ;
251
- } ) ;
325
+ it ( 'LogTemplateCreated event test, subscribe, unsubscribe' , async ( ) => {
326
+
327
+ //subscribtion setup
328
+ let subscriptionID1 = null ;
329
+ const eventName1 = 'LogTemplateCreated' ;
330
+ const indexedFilterValues1 = [ "_creator" ] ;
331
+ const expiryTime = new BigNumber ( web3 . eth . getBlock ( 'latest' ) . timestamp ) . plus ( 10000 ) ;
332
+ //the callback is passed into the filter.watch function, and is operated on when a new event comes in
333
+ const logTemplateCreatedArgsPromise = new Promise ( ( resolve , reject ) => {
334
+ subscriptionID1 = compliance . subscribe ( eventName1 , indexedFilterValues1 , ( err , log ) => {
335
+ if ( err !== null ) {
336
+ reject ( err ) ;
337
+ return ;
338
+ }
339
+ resolve ( log . args ) ;
252
340
} ) ;
341
+ } ) ;
253
342
254
- //subscribtion setup
255
- let subscriptionID2 = null ;
256
- const eventName2 = 'LogNewTemplateProposal' ;
257
- const indexedFilterValues2 = "_securityToken" ;
258
-
259
- //the callback is passed into the filter.watch function, and is operated on when a new event comes in
260
- const logNewTemplateProposalArgsPromise = new Promise ( ( resolve , reject ) => {
261
-
262
- subscriptionID2 = compliance . subscribe ( eventName2 , indexedFilterValues2 , ( err , log ) => {
263
- if ( err !== null ) {
264
- reject ( err ) ;
265
- return ;
266
- }
267
- resolve ( log . args ) ;
268
- } ) ;
269
- } ) ;
270
-
271
- //subscribtion setup
272
- let subscriptionID3 = null ;
273
- const eventName3 = 'LogNewContractProposal' ;
274
- const indexedFilterValues3 = [ "_securityToken" ] ;
275
-
276
- //the callback is passed into the filter.watch function, and is operated on when a new event comes in
277
- const logNewContractProposalArgsPromise = new Promise ( ( resolve , reject ) => {
278
-
279
- subscriptionID3 = compliance . subscribe ( eventName3 , indexedFilterValues3 , ( err , log ) => {
280
- if ( err !== null ) {
281
- reject ( err ) ;
282
- return ;
283
- }
284
- resolve ( log . args ) ;
285
- } ) ;
286
- } ) ;
343
+ await makeKYCProvider ( customers , accounts [ 1 ] , expiryTime ) ;
344
+ await makeLegalDelegate ( polyToken , customers , accounts [ 1 ] , accounts [ 2 ] , expiryTime ) ;
345
+ const templateAddress = await makeTemplate (
346
+ compliance ,
347
+ accounts [ 1 ] ,
348
+ accounts [ 2 ] ,
349
+ expiryTime ,
350
+ ) ;
287
351
288
- await makeKYCProvider ( customers , accounts [ 1 ] , expiryTime ) ;
289
- await makeLegalDelegate ( polyToken , customers , accounts [ 1 ] , accounts [ 2 ] , expiryTime ) ;
290
- const templateAddress = await makeTemplate (
291
- compliance ,
292
- accounts [ 1 ] ,
293
- accounts [ 2 ] ,
294
- expiryTime ,
295
- ) ;
296
352
353
+ const logTemplateCreated = await logTemplateCreatedArgsPromise ;
354
+ assert . equal ( logTemplateCreated . _creator , accounts [ 2 ] , 'legal delegate creator address wasnt found in event subscription' ) ; //'offeringtype' from make_examples.js
355
+ assert . isAbove ( logTemplateCreated . _template . length , 20 , 'template address wasnt found in event subscription' ) ;
356
+ assert . equal ( logTemplateCreated . _offeringType , "offeringtype" , 'offering type wasnt found in event subscription' ) ; //'offeringtype' from make_examples.js
357
+ await compliance . unsubscribe ( subscriptionID1 ) ;
297
358
298
- const logTemplateCreated = await logTemplateCreatedArgsPromise ;
299
- assert . equal ( logTemplateCreated . _creator , accounts [ 2 ] , 'legal delegate creator address wasnt found in event subscription' ) ; //'offeringtype' from make_examples.js
300
- assert . isAbove ( logTemplateCreated . _template . length , 20 , 'template address wasnt found in event subscription' ) ;
301
- assert . equal ( logTemplateCreated . _offeringType , "offeringtype" , 'offering type wasnt found in event subscription' ) ; //'offeringtype' from make_examples.js
302
- await compliance . unsubscribe ( subscriptionID1 ) ;
303
359
360
+ } )
304
361
305
- } )
306
362
307
363
308
- } )
309
364
} ) ;
0 commit comments