@@ -52,75 +52,88 @@ import {
5252 assertLogEquivalence ,
5353} from "../../logs/logAssertions" ;
5454
55- // contract("CoreIssuance", (accounts) => {
56- // const [
57- // ownerAccount
58- // takerAccount,
59- // makerAccount,
60- // unauthorizedAccount,
61- // ] = accounts;
62-
63- // let core: CoreContract;
64- // let transferProxy: TransferProxyContract;
65- // let vault: VaultContract;
66- // let setTokenFactory: SetTokenFactoryContract;
67-
68- // const coreWrapper = new CoreWrapper(ownerAccount, ownerAccount);
69- // const erc20Wrapper = new ERC20Wrapper(takerAccount);
70-
71- // before(async () => {
72- // ABIDecoder.addABI(Core.abi);
73- // });
74-
75- // after(async () => {
76- // ABIDecoder.removeABI(Core.abi);
77- // });
78-
79- // beforeEach(async () => {
80- // core = await coreWrapper.deployCoreAsync();
81- // vault = await coreWrapper.deployVaultAsync();
82- // transferProxy = await coreWrapper.deployTransferProxyAsync(vault.address);
83- // setTokenFactory = await coreWrapper.deploySetTokenFactoryAsync();
84- // await coreWrapper.setDefaultStateAndAuthorizationsAsync(core, vault, transferProxy, setTokenFactory);
85- // });
86-
87- // describe("#fillOrder", async () => {
88- // let subjectCaller: Address;
89- // let subjectQuantityToIssue: BigNumber;
90- // let subjectSetToIssue: Address;
91-
92- // const naturalUnit: BigNumber = ether(2);
93- // let components: StandardTokenMockContract[] = [];
94- // let componentUnits: BigNumber[];
95- // let setToken: SetTokenContract;
96-
97- // beforeEach(async () => {
98- // components = await erc20Wrapper.deployTokensAsync(2, ownerAccount);
99- // await erc20Wrapper.approveTransfersAsync(components, transferProxy.address);
100-
101- // const componentAddresses = _.map(components, (token) => token.address);
102- // componentUnits = _.map(components, () => ether(4)); // Multiple of naturalUnit
103- // setToken = await coreWrapper.createSetTokenAsync(
104- // core,
105- // setTokenFactory.address,
106- // componentAddresses,
107- // componentUnits,
108- // naturalUnit,
109- // );
110-
111- // subjectCaller = ownerAccount;
112- // subjectQuantityToIssue = ether(2);
113- // subjectSetToIssue = setToken.address;
114- // });
115-
116- // async function subject(): Promise<string> {
117- // return core.fillOrder.sendTransactionAsync(
118- // subjectSetToIssue,
119- // subjectQuantityToIssue,
120- // { from: ownerAccount },
121- // );
122- // }
123-
124- // it()
125- // });
126- // });
55+ contract ( "CoreIssuance" , ( accounts ) => {
56+ const [
57+ ownerAccount ,
58+ takerAccount ,
59+ makerAccount ,
60+ unauthorizedAccount ,
61+ ] = accounts ;
62+
63+ let core : CoreContract ;
64+ let transferProxy : TransferProxyContract ;
65+ let vault : VaultContract ;
66+ let setTokenFactory : SetTokenFactoryContract ;
67+
68+ const coreWrapper = new CoreWrapper ( ownerAccount , ownerAccount ) ;
69+ const erc20Wrapper = new ERC20Wrapper ( ownerAccount ) ;
70+
71+ before ( async ( ) => {
72+ ABIDecoder . addABI ( Core . abi ) ;
73+ } ) ;
74+
75+ after ( async ( ) => {
76+ ABIDecoder . removeABI ( Core . abi ) ;
77+ } ) ;
78+
79+ beforeEach ( async ( ) => {
80+ core = await coreWrapper . deployCoreAsync ( ) ;
81+ vault = await coreWrapper . deployVaultAsync ( ) ;
82+ transferProxy = await coreWrapper . deployTransferProxyAsync ( vault . address ) ;
83+ setTokenFactory = await coreWrapper . deploySetTokenFactoryAsync ( ) ;
84+ await coreWrapper . setDefaultStateAndAuthorizationsAsync ( core , vault , transferProxy , setTokenFactory ) ;
85+ } ) ;
86+
87+ describe . only ( "#fillOrder" , async ( ) => {
88+ let subjectCaller : Address ;
89+ let subjectQuantityToIssue : BigNumber ;
90+ let subjectSetToIssue : Address ;
91+
92+ const naturalUnit : BigNumber = ether ( 2 ) ;
93+ let components : StandardTokenMockContract [ ] = [ ] ;
94+ let componentUnits : BigNumber [ ] ;
95+ let setToken : SetTokenContract ;
96+
97+ beforeEach ( async ( ) => {
98+ components = await erc20Wrapper . deployTokensAsync ( 2 , makerAccount ) ;
99+ await erc20Wrapper . approveTransfersAsync ( components , transferProxy . address , makerAccount ) ;
100+
101+ const componentAddresses = _ . map ( components , ( token ) => token . address ) ;
102+ componentUnits = _ . map ( components , ( ) => ether ( 4 ) ) ; // Multiple of naturalUnit
103+ setToken = await coreWrapper . createSetTokenAsync (
104+ core ,
105+ setTokenFactory . address ,
106+ componentAddresses ,
107+ componentUnits ,
108+ naturalUnit ,
109+ ) ;
110+
111+ subjectCaller = takerAccount ;
112+ subjectQuantityToIssue = ether ( 2 ) ;
113+ subjectSetToIssue = setToken . address ;
114+ } ) ;
115+
116+ async function subject ( ) : Promise < string > {
117+ return core . fillOrder . sendTransactionAsync (
118+ makerAccount ,
119+ subjectSetToIssue ,
120+ subjectQuantityToIssue ,
121+ { from : ownerAccount } ,
122+ ) ;
123+ }
124+
125+ it ( "transfers the required tokens from the user" , async ( ) => {
126+ const component : StandardTokenMockContract = _ . first ( components ) ;
127+ const unit : BigNumber = _ . first ( componentUnits ) ;
128+
129+ const existingBalance = await component . balanceOf . callAsync ( makerAccount ) ;
130+ assertTokenBalance ( component , DEPLOYED_TOKEN_QUANTITY , makerAccount ) ;
131+
132+ await subject ( ) ;
133+
134+ const newBalance = await component . balanceOf . callAsync ( makerAccount ) ;
135+ const expectedNewBalance = existingBalance . sub ( subjectQuantityToIssue . div ( naturalUnit ) . mul ( unit ) ) ;
136+ expect ( newBalance ) . to . be . bignumber . equal ( expectedNewBalance ) ;
137+ } ) ;
138+ } ) ;
139+ } ) ;
0 commit comments