1
1
import * as chai from "chai" ;
2
2
import * as _ from "lodash" ;
3
- // import * as ABIDecoder from "abi-decoder";
4
3
5
4
import { BigNumber } from "bignumber.js" ;
6
5
import { ether , gWei } from "./utils/units" ;
@@ -23,6 +22,10 @@ BigNumberSetup.configure();
23
22
ChaiSetup . configure ( ) ;
24
23
const { expect, assert } = chai ;
25
24
25
+ import { extractLogEventAndArgs } from "./logs/log_utils" ;
26
+
27
+ import { getExpectedIssueLogs } from "./logs/SetToken" ;
28
+
26
29
import {
27
30
assertTokenBalance ,
28
31
expectInvalidOpcodeError ,
@@ -197,21 +200,23 @@ contract("{Set}", (accounts) => {
197
200
198
201
// Expected Quantities of tokens moved are divided by a gWei
199
202
// to reflect the new units in set instantiation
200
- const quantityA : BigNumber = units1 . mul ( standardQuantityIssued ) . div ( gWei ( 1 ) ) ;
201
- const quantityB : BigNumber = units2 . mul ( standardQuantityIssued ) . div ( gWei ( 1 ) ) ;
203
+ quantitiesToTransfer = _ . map ( units , ( unit ) => unit . mul ( standardQuantityIssued ) . div ( gWei ( 1 ) ) ) ;
202
204
203
205
const issuanceReceipt = await setToken . issue ( standardQuantityIssued , TX_DEFAULTS ) ;
204
206
205
- const issuanceLog = issuanceReceipt . logs [ issuanceReceipt . logs . length - 1 ] . args ;
206
-
207
- // The logs should have the right sender
208
- assert . strictEqual ( issuanceLog . _sender , testAccount ) ;
209
-
210
- // The logs should have the right quantity
211
- expect ( issuanceLog . _quantity ) . to . be . bignumber . equal ( standardQuantityIssued ) ;
207
+ const { logs } = issuanceReceipt ;
208
+ const formattedLogs = _ . map ( logs , ( log ) => extractLogEventAndArgs ( log ) ) ;
209
+ const expectedLogs = getExpectedIssueLogs (
210
+ componentAddresses ,
211
+ quantitiesToTransfer ,
212
+ setToken . address ,
213
+ standardQuantityIssued ,
214
+ testAccount ,
215
+ ) ;
216
+ expect ( JSON . stringify ( formattedLogs ) ) . to . equal ( JSON . stringify ( expectedLogs ) ) ;
212
217
213
- assertTokenBalance ( component1 , initialTokens . sub ( quantityA ) , testAccount ) ;
214
- assertTokenBalance ( component2 , initialTokens . sub ( quantityB ) , testAccount ) ;
218
+ assertTokenBalance ( component1 , initialTokens . sub ( quantitiesToTransfer [ 0 ] ) , testAccount ) ;
219
+ assertTokenBalance ( component2 , initialTokens . sub ( quantitiesToTransfer [ 1 ] ) , testAccount ) ;
215
220
assertTokenBalance ( setToken , standardQuantityIssued , testAccount ) ;
216
221
} ) ;
217
222
@@ -240,10 +245,20 @@ contract("{Set}", (accounts) => {
240
245
// 60 is about the limit for the number of components in a Set
241
246
// This is about ~2M Gas.
242
247
describe ( "of 60 Component Set" , ( ) => {
243
- it ( `work` , async ( ) => {
244
- await deployStandardSetAndApprove ( 60 ) ;
248
+ it ( `should work` , async ( ) => {
249
+ await deployStandardSetAndApprove ( 5 ) ;
245
250
246
- await setToken . issue ( standardQuantityIssued , TX_DEFAULTS ) ;
251
+ const issuanceReceipt = await setToken . issue ( standardQuantityIssued , TX_DEFAULTS ) ;
252
+ // const { logs } = issuanceReceipt;
253
+ // const formattedLogs = _.map(logs, (log) => extractLogEventAndArgs(log));
254
+ // const expectedLogs = getExpectedIssueLogs(
255
+ // componentAddresses,
256
+ // quantitiesToTransfer,
257
+ // setToken.address,
258
+ // standardQuantityIssued,
259
+ // testAccount,
260
+ // );
261
+ // expect(JSON.stringify(formattedLogs)).to.equal(JSON.stringify(expectedLogs));
247
262
assertTokenBalance ( setToken , standardQuantityIssued , testAccount ) ;
248
263
} ) ;
249
264
} ) ;
0 commit comments