@@ -18,6 +18,7 @@ import { VaultContract } from "../../../types/generated/vault";
18
18
19
19
// Core wrapper
20
20
import { CoreWrapper } from "../../utils/coreWrapper" ;
21
+ import { ERC20Wrapper } from "../../utils/erc20Wrapper" ;
21
22
22
23
// Testing Set up
23
24
import { BigNumberSetup } from "../../config/bigNumberSetup" ;
@@ -42,7 +43,6 @@ contract("CoreAccounting", (accounts) => {
42
43
otherAccount ,
43
44
unauthorizedAccount ,
44
45
] = accounts ;
45
- const TX_DEFAULTS = { from : ownerAccount , gas : 7000000 } ;
46
46
47
47
let core : CoreContract ;
48
48
let mockToken : StandardTokenMockContract ;
@@ -52,50 +52,23 @@ contract("CoreAccounting", (accounts) => {
52
52
let setTokenFactory : SetTokenFactoryContract ;
53
53
54
54
const coreWrapper = new CoreWrapper ( ownerAccount , ownerAccount ) ;
55
+ const erc20Wrapper = new ERC20Wrapper ( ownerAccount ) ;
55
56
56
- const setCoreDependencies = async ( from : Address = ownerAccount ) => {
57
- await core . setVaultAddress . sendTransactionAsync (
58
- vault . address ,
59
- { from } ,
60
- ) ;
61
- await core . setTransferProxyAddress . sendTransactionAsync (
62
- transferProxy . address ,
63
- { from } ,
64
- ) ;
65
-
66
- await core . enableFactory . sendTransactionAsync (
67
- setTokenFactory . address ,
68
- { from } ,
69
- ) ;
70
- } ;
71
-
72
- // TODO: Leaving this setup modular right now so we can toggle the deployers, authorizers, etc. if we want.
73
- // If we decide later that we don't need to, then we can move the abstracted setup functions into this one.
74
- const deployCoreAndInitializeDependencies = async ( from : Address = ownerAccount ) => {
57
+ beforeEach ( async ( ) => {
75
58
core = await coreWrapper . deployCoreAsync ( ) ;
76
-
77
59
vault = await coreWrapper . deployVaultAsync ( ) ;
78
- await coreWrapper . addAuthorizationAsync ( vault , core . address ) ;
79
-
80
60
transferProxy = await coreWrapper . deployTransferProxyAsync ( vault . address ) ;
81
- await coreWrapper . addAuthorizationAsync ( transferProxy , core . address ) ;
82
-
83
61
setTokenFactory = await coreWrapper . deploySetTokenFactoryAsync ( ) ;
84
- await coreWrapper . addAuthorizationAsync ( setTokenFactory , core . address ) ;
85
- await coreWrapper . setCoreAddress ( setTokenFactory , core . address ) ;
86
-
87
- await setCoreDependencies ( ) ;
88
- } ;
62
+ await coreWrapper . setDefaultStateAndAuthorizationsAsync ( core , vault , transferProxy , setTokenFactory ) ;
63
+ } ) ;
89
64
90
65
describe ( "#deposit" , async ( ) => {
91
66
const tokenOwner : Address = ownerAccount ;
92
67
const approver : Address = ownerAccount ;
93
68
94
69
beforeEach ( async ( ) => {
95
- await deployCoreAndInitializeDependencies ( ) ;
96
-
97
- mockToken = await coreWrapper . deployTokenAsync ( tokenOwner ) ;
98
- await coreWrapper . approveTransferAsync ( mockToken , transferProxy . address , approver ) ;
70
+ mockToken = await erc20Wrapper . deployTokenAsync ( tokenOwner ) ;
71
+ await erc20Wrapper . approveTransferAsync ( mockToken , transferProxy . address , approver ) ;
99
72
} ) ;
100
73
101
74
let amountToDeposit = DEPLOYED_TOKEN_QUANTITY ;
@@ -186,10 +159,8 @@ contract("CoreAccounting", (accounts) => {
186
159
const ownerBalanceInVault : BigNumber = DEPLOYED_TOKEN_QUANTITY ;
187
160
188
161
beforeEach ( async ( ) => {
189
- await deployCoreAndInitializeDependencies ( ) ;
190
-
191
- mockToken = await coreWrapper . deployTokenAsync ( tokenOwner ) ;
192
- await coreWrapper . approveTransferAsync ( mockToken , transferProxy . address , approver ) ;
162
+ mockToken = await erc20Wrapper . deployTokenAsync ( tokenOwner ) ;
163
+ await erc20Wrapper . approveTransferAsync ( mockToken , transferProxy . address , approver ) ;
193
164
await coreWrapper . depositFromUser ( core , mockToken . address , ownerBalanceInVault ) ;
194
165
} ) ;
195
166
@@ -270,9 +241,7 @@ contract("CoreAccounting", (accounts) => {
270
241
let tokenCount : number = 1 ;
271
242
272
243
beforeEach ( async ( ) => {
273
- await deployCoreAndInitializeDependencies ( ) ;
274
-
275
- mockTokens = await coreWrapper . deployTokensAsync ( tokenCount , tokenOwner ) ;
244
+ mockTokens = await erc20Wrapper . deployTokensAsync ( tokenCount , tokenOwner ) ;
276
245
const approvePromises = _ . map ( mockTokens , ( token ) =>
277
246
token . approve . sendTransactionAsync (
278
247
transferProxy . address ,
@@ -305,26 +274,26 @@ contract("CoreAccounting", (accounts) => {
305
274
}
306
275
307
276
it ( "transfers the correct amount of each token from the caller" , async ( ) => {
308
- const existingTokenBalances = await coreWrapper . getTokenBalances ( mockTokens , ownerAccount ) ;
277
+ const existingTokenBalances = await erc20Wrapper . getTokenBalances ( mockTokens , ownerAccount ) ;
309
278
const expectedNewBalances = _ . map ( existingTokenBalances , ( balance ) =>
310
279
balance . sub ( DEPLOYED_TOKEN_QUANTITY ) ,
311
280
) ;
312
281
313
282
await subject ( ) ;
314
283
315
- const newTokenBalances = await await coreWrapper . getTokenBalances ( mockTokens , ownerAccount ) ;
284
+ const newTokenBalances = await await erc20Wrapper . getTokenBalances ( mockTokens , ownerAccount ) ;
316
285
expect ( newTokenBalances ) . to . eql ( expectedNewBalances ) ;
317
286
} ) ;
318
287
319
288
it ( "transfers the correct amount of each token to the vault" , async ( ) => {
320
- const existingTokenBalances = await coreWrapper . getTokenBalances ( mockTokens , vault . address ) ;
289
+ const existingTokenBalances = await erc20Wrapper . getTokenBalances ( mockTokens , vault . address ) ;
321
290
const expectedNewBalances = _ . map ( existingTokenBalances , ( balance ) =>
322
291
balance . add ( DEPLOYED_TOKEN_QUANTITY ) ,
323
292
) ;
324
293
325
294
await subject ( ) ;
326
295
327
- const newTokenBalances = await coreWrapper . getTokenBalances ( mockTokens , vault . address ) ;
296
+ const newTokenBalances = await erc20Wrapper . getTokenBalances ( mockTokens , vault . address ) ;
328
297
expect ( newTokenBalances ) . to . eql ( expectedNewBalances ) ;
329
298
} ) ;
330
299
@@ -401,9 +370,7 @@ contract("CoreAccounting", (accounts) => {
401
370
let tokenCount : number = 3 ;
402
371
403
372
beforeEach ( async ( ) => {
404
- await deployCoreAndInitializeDependencies ( ) ;
405
-
406
- mockTokens = await coreWrapper . deployTokensAsync ( tokenCount , tokenOwner ) ;
373
+ mockTokens = await erc20Wrapper . deployTokensAsync ( tokenCount , tokenOwner ) ;
407
374
const approvePromises = _ . map ( mockTokens , ( token ) =>
408
375
token . approve . sendTransactionAsync (
409
376
transferProxy . address ,
@@ -443,26 +410,26 @@ contract("CoreAccounting", (accounts) => {
443
410
}
444
411
445
412
it ( "transfers the correct amount of each token from the caller" , async ( ) => {
446
- const existingTokenBalances = await coreWrapper . getTokenBalances ( mockTokens , ownerAccount ) ;
413
+ const existingTokenBalances = await erc20Wrapper . getTokenBalances ( mockTokens , ownerAccount ) ;
447
414
const expectedNewBalances = _ . map ( existingTokenBalances , ( balance ) =>
448
415
balance . add ( DEPLOYED_TOKEN_QUANTITY ) ,
449
416
) ;
450
417
451
418
await subject ( ) ;
452
419
453
- const newTokenBalances = await await coreWrapper . getTokenBalances ( mockTokens , ownerAccount ) ;
420
+ const newTokenBalances = await await erc20Wrapper . getTokenBalances ( mockTokens , ownerAccount ) ;
454
421
expect ( newTokenBalances ) . to . eql ( expectedNewBalances ) ;
455
422
} ) ;
456
423
457
424
it ( "transfers the correct amount of each token to the vault" , async ( ) => {
458
- const existingTokenBalances = await await coreWrapper . getTokenBalances ( mockTokens , vault . address ) ;
425
+ const existingTokenBalances = await await erc20Wrapper . getTokenBalances ( mockTokens , vault . address ) ;
459
426
const expectedNewBalances = _ . map ( existingTokenBalances , ( balance ) =>
460
427
balance . sub ( DEPLOYED_TOKEN_QUANTITY ) ,
461
428
) ;
462
429
463
430
await subject ( ) ;
464
431
465
- const newTokenBalances = await coreWrapper . getTokenBalances ( mockTokens , vault . address ) ;
432
+ const newTokenBalances = await erc20Wrapper . getTokenBalances ( mockTokens , vault . address ) ;
466
433
expect ( newTokenBalances ) . to . eql ( expectedNewBalances ) ;
467
434
} ) ;
468
435
0 commit comments