@@ -168,6 +168,7 @@ contract('Sale', (accounts) => {
168168
169169 describe ( 'Initial token issuance' , ( ) => {
170170 const wrongTokenBalance = 'has an incorrect token balance.' ;
171+
171172 it ( 'should instantiate preBuyers with the proper number of tokens' , ( ) =>
172173 Promise . all (
173174 Object . keys ( preBuyersConf ) . map ( async ( curr ) => {
@@ -181,6 +182,7 @@ contract('Sale', (accounts) => {
181182 } ) ,
182183 ) ,
183184 ) ;
185+
184186 it ( 'should instantiate disburser contracts with the proper number of tokens' , async ( ) =>
185187 Promise . all (
186188 getTimelockedBeneficiaries ( ) . map ( async ( beneficiary ) => {
@@ -200,6 +202,7 @@ contract('Sale', (accounts) => {
200202 } ) ,
201203 ) ,
202204 ) ;
205+
203206 it ( 'should instantiate the public sale with the total supply of tokens ' +
204207 'minus the sum of tokens pre-sold.' , async ( ) => {
205208 const tokenBalance = await getTokenBalanceOf ( Sale . address ) ;
@@ -210,29 +213,34 @@ contract('Sale', (accounts) => {
210213 ) ;
211214 } ) ;
212215 } ) ;
216+
213217 describe ( 'Instantiation' , ( ) => {
214218 const badInitialization = 'was not initialized properly' ;
219+
215220 it ( `should instantiate with the price set to ${ saleConf . price } Wei.` , async ( ) => {
216221 const sale = await Sale . deployed ( ) ;
217222 const price = await sale . price . call ( ) ;
218223 const expected = saleConf . price ;
219224 const errMsg = `The price ${ badInitialization } ` ;
220225 assert . strictEqual ( price . toString ( 10 ) , expected . toString ( 10 ) , errMsg ) ;
221226 } ) ;
227+
222228 it ( `should instantiate with the owner set to ${ saleConf . owner } .` , async ( ) => {
223229 const sale = await Sale . deployed ( ) ;
224230 const actualOwner = await sale . owner . call ( ) ;
225231 const expected = saleConf . owner . toLowerCase ( ) ;
226232 const errMsg = `The owner ${ badInitialization } ` ;
227233 assert . strictEqual ( actualOwner . valueOf ( ) , expected , errMsg ) ;
228234 } ) ;
235+
229236 it ( `should instantiate with the wallet set to ${ saleConf . wallet } .` , async ( ) => {
230237 const sale = await Sale . deployed ( ) ;
231238 const wallet = await sale . wallet . call ( ) ;
232239 const expected = saleConf . wallet ;
233240 const errMsg = `The wallet ${ badInitialization } ` ;
234241 assert . strictEqual ( wallet . valueOf ( ) , expected . toLowerCase ( ) , errMsg ) ;
235242 } ) ;
243+
236244 it ( `should instantiate with the startBlock set to ${ saleConf . startBlock } .` , async ( ) => {
237245 const sale = await Sale . deployed ( ) ;
238246 const startBlock = await sale . startBlock . call ( ) ;
@@ -247,6 +255,7 @@ contract('Sale', (accounts) => {
247255 describe ( 'Owner-only functions' , ( ) => {
248256 const nonOwnerAccessError = 'A non-owner was able to' ;
249257 const ownerAccessError = 'An owner was unable able to' ;
258+
250259 it ( 'should not allow a non-owner to change the price.' , async ( ) => {
251260 const sale = await Sale . deployed ( ) ;
252261 try {
@@ -260,6 +269,7 @@ contract('Sale', (accounts) => {
260269 const errMsg = `${ nonOwnerAccessError } change the price` ;
261270 assert . strictEqual ( price . toString ( 10 ) , expected . toString ( 10 ) , errMsg ) ;
262271 } ) ;
272+
263273 it ( 'should not allow a non-owner to change the startBlock.' , async ( ) => {
264274 const sale = await Sale . deployed ( ) ;
265275 try {
@@ -273,6 +283,7 @@ contract('Sale', (accounts) => {
273283 const errMsg = `${ nonOwnerAccessError } change the start block` ;
274284 assert . strictEqual ( startBlock . toString ( 10 ) , expected . toString ( 10 ) , errMsg ) ;
275285 } ) ;
286+
276287 it ( 'should not allow a non-owner to change the owner' , async ( ) => {
277288 const sale = await Sale . deployed ( ) ;
278289 try {
@@ -286,6 +297,7 @@ contract('Sale', (accounts) => {
286297 const errMsg = `${ nonOwnerAccessError } change the owner` ;
287298 assert . strictEqual ( actualOwner . toString ( ) , expected . toString ( ) , errMsg ) ;
288299 } ) ;
300+
289301 it ( 'should not allow a non-owner to change the wallet' , async ( ) => {
290302 const sale = await Sale . deployed ( ) ;
291303 try {
@@ -299,6 +311,7 @@ contract('Sale', (accounts) => {
299311 const errMsg = `${ nonOwnerAccessError } change the wallet` ;
300312 assert . strictEqual ( wallet . toString ( ) , expected . toLowerCase ( ) , errMsg ) ;
301313 } ) ;
314+
302315 it ( 'should not allow a non-owner to activate the emergencyToggle' , async ( ) => {
303316 const sale = await Sale . deployed ( ) ;
304317 try {
@@ -312,6 +325,7 @@ contract('Sale', (accounts) => {
312325 const errMsg = `${ nonOwnerAccessError } change the emergencyToggle` ;
313326 assert . strictEqual ( emergencyFlag , expected , errMsg ) ;
314327 } ) ;
328+
315329 it ( 'should change the owner to miguel.' , async ( ) => {
316330 const sale = await Sale . deployed ( ) ;
317331 await as ( saleConf . owner , sale . changeOwner , miguel ) ;
@@ -321,6 +335,7 @@ contract('Sale', (accounts) => {
321335 assert . strictEqual ( actualOwner , expected , errMsg ) ;
322336 await as ( miguel , sale . changeOwner , saleConf . owner ) ;
323337 } ) ;
338+
324339 it ( 'should change the price to 2666.' , async ( ) => {
325340 const sale = await Sale . deployed ( ) ;
326341 await as ( owner , sale . changePrice , 2666 ) ;
@@ -330,6 +345,7 @@ contract('Sale', (accounts) => {
330345 assert . strictEqual ( price . toString ( 10 ) , expected . toString ( 10 ) , errMsg ) ;
331346 await as ( owner , sale . changePrice , saleConf . price ) ;
332347 } ) ;
348+
333349 it ( 'should change the startBlock to 2666.' , async ( ) => {
334350 const sale = await Sale . deployed ( ) ;
335351 await as ( owner , sale . changeStartBlock , 2666 ) ;
@@ -339,6 +355,7 @@ contract('Sale', (accounts) => {
339355 assert . strictEqual ( price . toString ( 10 ) , expected . toString ( 10 ) , errMsg ) ;
340356 await as ( owner , sale . changeStartBlock , saleConf . startBlock ) ;
341357 } ) ;
358+
342359 it ( 'should change the wallet address' , async ( ) => {
343360 const newWallet = '0x0000000000000000000000000000000000000001' ;
344361 const sale = await Sale . deployed ( ) ;
@@ -349,6 +366,7 @@ contract('Sale', (accounts) => {
349366 assert . strictEqual ( wallet , expected , errMsg ) ;
350367 await as ( owner , sale . changeWallet , saleConf . wallet ) ;
351368 } ) ;
369+
352370 it ( 'should activate the emergencyFlag.' , async ( ) => {
353371 const sale = await Sale . deployed ( ) ;
354372 await as ( owner , sale . emergencyToggle ) ;
@@ -362,6 +380,7 @@ contract('Sale', (accounts) => {
362380
363381 describe ( 'Pre-sale period' , ( ) => {
364382 const earlyPurchaseError = ' was able to purchase tokens early' ;
383+
365384 it ( 'should reject a purchase from James.' , async ( ) => {
366385 const startingBalance = await getTokenBalanceOf ( james ) ;
367386 try {
@@ -401,6 +420,7 @@ contract('Sale', (accounts) => {
401420 const errMsg = 'The owner was able to change the price after the freeze block' ;
402421 assert . strictEqual ( price . toString ( 10 ) , expected . toString ( 10 ) , errMsg ) ;
403422 } ) ;
423+
404424 it ( 'should transfer 1 token to James.' , async ( ) => {
405425 const startingBalance = await getTokenBalanceOf ( james ) ;
406426 const purchaseAmount = new BN ( '1' , 10 ) ;
@@ -410,6 +430,7 @@ contract('Sale', (accounts) => {
410430 const errMsg = balanceError ;
411431 assert . strictEqual ( finalBalance . toString ( 10 ) , expected . toString ( 10 ) , errMsg ) ;
412432 } ) ;
433+
413434 it ( 'should transfer 10 tokens to Miguel.' , async ( ) => {
414435 const startingBalance = await getTokenBalanceOf ( miguel ) ;
415436 const purchaseAmount = new BN ( '10' , 10 ) ;
@@ -419,6 +440,7 @@ contract('Sale', (accounts) => {
419440 const errMsg = balanceError ;
420441 assert . strictEqual ( finalBalance . toString ( 10 ) , expected . toString ( 10 ) , errMsg ) ;
421442 } ) ;
443+
422444 it ( 'should transfer 100 tokens to Edwhale.' , async ( ) => {
423445 const startingBalance = await getTokenBalanceOf ( edwhale ) ;
424446 const purchaseAmount = new BN ( '100' , 10 ) ;
@@ -433,10 +455,12 @@ contract('Sale', (accounts) => {
433455 describe ( 'Emergency stop' , ( ) => {
434456 const purchaseInStopError = ' was able to purchase during the emergency stop' ;
435457 const balanceError = 'A balance was not as expected following a purchase' ;
458+
436459 before ( async ( ) => {
437460 const sale = await Sale . deployed ( ) ;
438461 await as ( owner , sale . emergencyToggle ) ;
439462 } ) ;
463+
440464 it ( 'should not transfer 1 token to James.' , async ( ) => {
441465 const startingBalance = await getTokenBalanceOf ( james ) ;
442466 const purchaseAmount = new BN ( '1' , 10 ) ;
@@ -453,6 +477,7 @@ contract('Sale', (accounts) => {
453477 const errMsg = balanceError ;
454478 assert . strictEqual ( finalBalance . toString ( 10 ) , expected . toString ( 10 ) , errMsg ) ;
455479 } ) ;
480+
456481 it ( 'should not transfer 10 tokens to Miguel.' , async ( ) => {
457482 const startingBalance = await getTokenBalanceOf ( miguel ) ;
458483 const purchaseAmount = new BN ( '10' , 10 ) ;
@@ -469,6 +494,7 @@ contract('Sale', (accounts) => {
469494 const errMsg = balanceError ;
470495 assert . strictEqual ( finalBalance . toString ( 10 ) , expected . toString ( 10 ) , errMsg ) ;
471496 } ) ;
497+
472498 it ( 'should not transfer 100 tokens to Edwhale.' , async ( ) => {
473499 const startingBalance = await getTokenBalanceOf ( edwhale ) ;
474500 const purchaseAmount = new BN ( '100' , 10 ) ;
@@ -485,6 +511,7 @@ contract('Sale', (accounts) => {
485511 const errMsg = balanceError ;
486512 assert . strictEqual ( finalBalance . toString ( 10 ) , expected . toString ( 10 ) , errMsg ) ;
487513 } ) ;
514+
488515 after ( async ( ) => {
489516 const sale = await Sale . deployed ( ) ;
490517 await as ( owner , sale . emergencyToggle ) ;
@@ -515,6 +542,7 @@ contract('Sale', (accounts) => {
515542 finalBalance . toString ( 10 ) , expected . toString ( 10 ) , errMsg ,
516543 ) ;
517544 } ) ;
545+
518546 it ( 'should return excess Wei to Edwhale' , async ( ) => {
519547 const startingBalance = await ethQuery . getBalance ( edwhale ) ;
520548 const gasPrice = await ethQuery . gasPrice ( ) ;
@@ -536,6 +564,7 @@ contract('Sale', (accounts) => {
536564 finalBalance . toString ( 10 ) , expected . toString ( 10 ) , errMsg ,
537565 ) ;
538566 } ) ;
567+
539568 it ( 'should transfer all the remaining tokens to Edwhale.' , async ( ) => {
540569 const startingBalance = await getTokenBalanceOf ( edwhale ) ;
541570 const saleBalance = await getTokenBalanceOf ( Sale . address ) ;
@@ -550,6 +579,7 @@ contract('Sale', (accounts) => {
550579 describe ( 'Post-sale period' , ( ) => {
551580 const balanceError = 'A balance was not as expected following a purchase' ;
552581 const sellOutError = ' was able to purchase when the sale was sold out' ;
582+
553583 it ( 'should not transfer 1 token to James.' , async ( ) => {
554584 const startingBalance = await getTokenBalanceOf ( james ) ;
555585 const purchaseAmount = new BN ( '1' , 10 ) ;
@@ -566,6 +596,7 @@ contract('Sale', (accounts) => {
566596 const errMsg = balanceError ;
567597 assert . strictEqual ( finalBalance . toString ( 10 ) , expected . toString ( 10 ) , errMsg ) ;
568598 } ) ;
599+
569600 it ( 'should not transfer 10 tokens to Miguel.' , async ( ) => {
570601 const startingBalance = await getTokenBalanceOf ( miguel ) ;
571602 const purchaseAmount = new BN ( '10' , 10 ) ;
@@ -582,6 +613,7 @@ contract('Sale', (accounts) => {
582613 const errMsg = balanceError ;
583614 assert . strictEqual ( finalBalance . toString ( 10 ) , expected . toString ( 10 ) , errMsg ) ;
584615 } ) ;
616+
585617 it ( 'should not transfer 100 tokens to Edwhale.' , async ( ) => {
586618 const startingBalance = await getTokenBalanceOf ( edwhale ) ;
587619 const purchaseAmount = new BN ( '100' , 10 ) ;
@@ -598,18 +630,21 @@ contract('Sale', (accounts) => {
598630 const errMsg = balanceError ;
599631 assert . strictEqual ( finalBalance . toString ( 10 ) , expected . toString ( 10 ) , errMsg ) ;
600632 } ) ;
633+
601634 it ( 'should report the proper sum of Wei in the wallet.' , async ( ) => {
602635 const balance = await ethQuery . getBalance ( saleConf . wallet ) ;
603636 const expected = tokensForSale . mul ( saleConf . price ) ;
604637 const errMsg = 'The amount of Ether in the wallet is not what it should be at sale end' ;
605638 assert . strictEqual ( balance . toString ( 10 ) , expected . toString ( 10 ) , errMsg ) ;
606639 } ) ;
640+
607641 it ( 'should report a zero balance for the sale contract.' , async ( ) => {
608642 const balance = await getTokenBalanceOf ( Sale . address ) ;
609643 const expected = new BN ( '0' , 10 ) ;
610644 const errMsg = 'The sale contract still has tokens in it when it should be sold out' ;
611645 assert . strictEqual ( balance . toString ( 10 ) , expected . toString ( 10 ) , errMsg ) ;
612646 } ) ;
647+
613648 it ( 'should allow Edwhale to transfer 10 tokens to James.' , async ( ) => {
614649 const transferAmount = new BN ( '10' , 10 ) ;
615650 const edwhaleStartingBalance = await getTokenBalanceOf ( edwhale ) ;
@@ -633,15 +668,6 @@ contract('Sale', (accounts) => {
633668 } ) ;
634669
635670 describe ( 'Filters and disbursers' , ( ) => {
636- /*
637- const earlyAccessFailure = 'Founder was able to withdraw from a filter ' +
638- 'earlier than should have been possible';
639- const doubleAccessFailure = 'Founder was able to withdraw from a filter ' +
640- 'they had already withdrawn from';
641- const balanceFailure = 'The beneficiary\'s balance was not as expected after ' +
642- 'interacting with a filter';
643- */
644-
645671 function signerAccessFailureFor ( address ) {
646672 return `WARNING: could not unlock account ${ address } .\n` +
647673 'This is probably because this beneficiary\'s private key is not generated \n' +
@@ -662,7 +688,8 @@ contract('Sale', (accounts) => {
662688 `Expected maxWithdraw to be zero for ${ beneficiary . address } ` ) ;
663689 await as ( beneficiary . address , disburser . withdraw , beneficiary . address ,
664690 maxWithdraw + 1 ) ;
665- assert ( false , `${ beneficiary . address } was able to withdraw timelocked tokens early` ) ;
691+ assert ( false ,
692+ `${ beneficiary . address } was able to withdraw timelocked tokens early` ) ;
666693 } catch ( err ) {
667694 if ( isSignerAccessFailure ( err ) ) {
668695 console . log ( signerAccessFailureFor ( beneficiary . address ) ) ;
@@ -715,13 +742,16 @@ contract('Sale', (accounts) => {
715742 let snapshot = await getEVMSnapshot ( ) ;
716743
717744 async function tranchWithdraw ( tranches , beneficiary ) {
718- const beneficiaryStartingBalance = await getTokenBalanceOf ( beneficiary . address ) ;
719745 const tranch = tranches [ 0 ] ;
746+
720747 await makeEVMRevert ( snapshot ) ;
721748 snapshot = await getEVMSnapshot ( ) ;
722749 await makeEVMIncreaseTime ( Number . parseInt ( tranch . date , 10 ) ) ;
750+
751+ const beneficiaryStartingBalance = await getTokenBalanceOf ( beneficiary . address ) ;
723752 const disburser =
724753 getDisburserByBeneficiaryAndTranch ( beneficiary . address , tranch ) ;
754+
725755 try {
726756 await as ( beneficiary . address , disburser . withdraw ,
727757 beneficiary . address , new BN ( tranch . amount , 10 ) ) ;
0 commit comments