@@ -3,6 +3,8 @@ const assert = require('chai').assert;
3
3
const SetToken = artifacts . require ( 'SetToken' ) ;
4
4
const StandardTokenMock = artifacts . require ( 'StandardTokenMock' ) ;
5
5
6
+ const BigNumber = require ( 'bignumber.js' ) ;
7
+
6
8
const expectedExceptionPromise = require ( './helpers/expectedException.js' ) ;
7
9
web3 . eth . getTransactionReceiptMined = require ( './helpers/getTransactionReceiptMined.js' ) ;
8
10
@@ -41,7 +43,7 @@ contract('{Set}', function(accounts) {
41
43
42
44
it ( 'should not allow creation of a {Set} with no inputs' , async ( ) => {
43
45
return expectedExceptionPromise (
44
- ( ) => SetToken . new ( [ ] , [ ] , { from : testAccount } ) ,
46
+ ( ) => SetToken . new ( [ ] , [ ] , name , symbol , { from : testAccount } ) ,
45
47
3000000 ,
46
48
) ;
47
49
} ) ;
@@ -141,7 +143,6 @@ contract('{Set}', function(accounts) {
141
143
142
144
assert . exists ( setToken , 'Set Token does not exist' ) ;
143
145
} ) ;
144
-
145
146
it ( 'should have the basic information correct' , async ( ) => {
146
147
// Assert correct name
147
148
let setTokenName = await setToken . name ( { from : testAccount } ) ;
@@ -280,5 +281,38 @@ contract('{Set}', function(accounts) {
280
281
assert . strictEqual ( postIssueBalanceIndexofOwner . toString ( ) , '0' ) ;
281
282
} ) ;
282
283
}
284
+
285
+ it ( 'should disallow issuing a quantity of tokens that would trigger an overflow' , async ( ) => {
286
+ var units = 2 ;
287
+
288
+ // This creates a SetToken with only one backing token.
289
+ setToken = await SetToken . new (
290
+ [ tokenB . address ] ,
291
+ [ units ] ,
292
+ setName ,
293
+ setSymbol ,
294
+ { from : testAccount } ,
295
+ ) ;
296
+
297
+ var quantity = 100 ;
298
+ var quantityB = quantity * units ;
299
+
300
+ await tokenB . approve ( setToken . address , quantityB , {
301
+ from : testAccount ,
302
+ } ) ;
303
+
304
+ // Set quantity to 2^254 + 100. This quantity * 2 will overflow a
305
+ // uint256 and equal 200.
306
+ var overflow = new BigNumber ( '0x8000000000000000000000000000000000000000000000000000000000000000' ) ;
307
+ var quantityOverflow = overflow . plus ( quantity ) ;
308
+
309
+ await expectedExceptionPromise (
310
+ ( ) =>
311
+ setToken . issue ( quantityOverflow , {
312
+ from : testAccount ,
313
+ } ) ,
314
+ 3000000 ,
315
+ ) ;
316
+ } ) ;
283
317
} ) ;
284
318
} ) ;
0 commit comments