@@ -18,6 +18,7 @@ import { VaultContract } from "../../../types/generated/vault";
1818
1919// Core wrapper
2020import { CoreWrapper } from "../../utils/coreWrapper" ;
21+ import { ERC20Wrapper } from "../../utils/erc20Wrapper" ;
2122
2223// Testing Set up
2324import { BigNumberSetup } from "../../config/bigNumberSetup" ;
@@ -42,7 +43,6 @@ contract("CoreAccounting", (accounts) => {
4243 otherAccount ,
4344 unauthorizedAccount ,
4445 ] = accounts ;
45- const TX_DEFAULTS = { from : ownerAccount , gas : 7000000 } ;
4646
4747 let core : CoreContract ;
4848 let mockToken : StandardTokenMockContract ;
@@ -52,50 +52,23 @@ contract("CoreAccounting", (accounts) => {
5252 let setTokenFactory : SetTokenFactoryContract ;
5353
5454 const coreWrapper = new CoreWrapper ( ownerAccount , ownerAccount ) ;
55+ const erc20Wrapper = new ERC20Wrapper ( ownerAccount ) ;
5556
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 ( ) => {
7558 core = await coreWrapper . deployCoreAsync ( ) ;
76-
7759 vault = await coreWrapper . deployVaultAsync ( ) ;
78- await coreWrapper . addAuthorizationAsync ( vault , core . address ) ;
79-
8060 transferProxy = await coreWrapper . deployTransferProxyAsync ( vault . address ) ;
81- await coreWrapper . addAuthorizationAsync ( transferProxy , core . address ) ;
82-
8361 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+ } ) ;
8964
9065 describe ( "#deposit" , async ( ) => {
9166 const tokenOwner : Address = ownerAccount ;
9267 const approver : Address = ownerAccount ;
9368
9469 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 ) ;
9972 } ) ;
10073
10174 let amountToDeposit = DEPLOYED_TOKEN_QUANTITY ;
@@ -186,10 +159,8 @@ contract("CoreAccounting", (accounts) => {
186159 const ownerBalanceInVault : BigNumber = DEPLOYED_TOKEN_QUANTITY ;
187160
188161 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 ) ;
193164 await coreWrapper . depositFromUser ( core , mockToken . address , ownerBalanceInVault ) ;
194165 } ) ;
195166
@@ -270,9 +241,7 @@ contract("CoreAccounting", (accounts) => {
270241 let tokenCount : number = 1 ;
271242
272243 beforeEach ( async ( ) => {
273- await deployCoreAndInitializeDependencies ( ) ;
274-
275- mockTokens = await coreWrapper . deployTokensAsync ( tokenCount , tokenOwner ) ;
244+ mockTokens = await erc20Wrapper . deployTokensAsync ( tokenCount , tokenOwner ) ;
276245 const approvePromises = _ . map ( mockTokens , ( token ) =>
277246 token . approve . sendTransactionAsync (
278247 transferProxy . address ,
@@ -305,26 +274,26 @@ contract("CoreAccounting", (accounts) => {
305274 }
306275
307276 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 ) ;
309278 const expectedNewBalances = _ . map ( existingTokenBalances , ( balance ) =>
310279 balance . sub ( DEPLOYED_TOKEN_QUANTITY ) ,
311280 ) ;
312281
313282 await subject ( ) ;
314283
315- const newTokenBalances = await await coreWrapper . getTokenBalances ( mockTokens , ownerAccount ) ;
284+ const newTokenBalances = await await erc20Wrapper . getTokenBalances ( mockTokens , ownerAccount ) ;
316285 expect ( newTokenBalances ) . to . eql ( expectedNewBalances ) ;
317286 } ) ;
318287
319288 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 ) ;
321290 const expectedNewBalances = _ . map ( existingTokenBalances , ( balance ) =>
322291 balance . add ( DEPLOYED_TOKEN_QUANTITY ) ,
323292 ) ;
324293
325294 await subject ( ) ;
326295
327- const newTokenBalances = await coreWrapper . getTokenBalances ( mockTokens , vault . address ) ;
296+ const newTokenBalances = await erc20Wrapper . getTokenBalances ( mockTokens , vault . address ) ;
328297 expect ( newTokenBalances ) . to . eql ( expectedNewBalances ) ;
329298 } ) ;
330299
@@ -401,9 +370,7 @@ contract("CoreAccounting", (accounts) => {
401370 let tokenCount : number = 3 ;
402371
403372 beforeEach ( async ( ) => {
404- await deployCoreAndInitializeDependencies ( ) ;
405-
406- mockTokens = await coreWrapper . deployTokensAsync ( tokenCount , tokenOwner ) ;
373+ mockTokens = await erc20Wrapper . deployTokensAsync ( tokenCount , tokenOwner ) ;
407374 const approvePromises = _ . map ( mockTokens , ( token ) =>
408375 token . approve . sendTransactionAsync (
409376 transferProxy . address ,
@@ -443,26 +410,26 @@ contract("CoreAccounting", (accounts) => {
443410 }
444411
445412 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 ) ;
447414 const expectedNewBalances = _ . map ( existingTokenBalances , ( balance ) =>
448415 balance . add ( DEPLOYED_TOKEN_QUANTITY ) ,
449416 ) ;
450417
451418 await subject ( ) ;
452419
453- const newTokenBalances = await await coreWrapper . getTokenBalances ( mockTokens , ownerAccount ) ;
420+ const newTokenBalances = await await erc20Wrapper . getTokenBalances ( mockTokens , ownerAccount ) ;
454421 expect ( newTokenBalances ) . to . eql ( expectedNewBalances ) ;
455422 } ) ;
456423
457424 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 ) ;
459426 const expectedNewBalances = _ . map ( existingTokenBalances , ( balance ) =>
460427 balance . sub ( DEPLOYED_TOKEN_QUANTITY ) ,
461428 ) ;
462429
463430 await subject ( ) ;
464431
465- const newTokenBalances = await coreWrapper . getTokenBalances ( mockTokens , vault . address ) ;
432+ const newTokenBalances = await erc20Wrapper . getTokenBalances ( mockTokens , vault . address ) ;
466433 expect ( newTokenBalances ) . to . eql ( expectedNewBalances ) ;
467434 } ) ;
468435
0 commit comments