const CollateralToken = artifacts.require('CollateralToken');

// basic tests to ensure collateral token works and is set up to allow trading
contract('CollateralToken', function(accounts) {
  let initBalance;
  let collateralToken;
  let balancePerAcct;
  // test setup of token for collateral
  it('Initial supply should be 1e+22', async function() {
    collateralToken = await CollateralToken.deployed();
    initBalance = await collateralToken.INITIAL_SUPPLY.call().valueOf();
    assert.equal(initBalance, 1e22, 'Initial balance not as expected');
  });

  it('Main account should have entire balance', async function() {
    const mainAcctBalance = await collateralToken.balanceOf.call(accounts[0]).valueOf();
    assert.equal(
      mainAcctBalance.toNumber(),
      initBalance.toNumber(),
      'Entire coin balance should be in primary account'
    );
  });

  it('Main account should be able to transfer balance', async function() {
    const balanceToTransfer = initBalance / 2;
    balancePerAcct = balanceToTransfer;
    await collateralToken.transfer(accounts[1], balanceToTransfer, { from: accounts[0] });
    const secondAcctBalance = await collateralToken.balanceOf.call(accounts[1]).valueOf();
    assert.equal(
      secondAcctBalance.toNumber(),
      balanceToTransfer,
      "Transfer didn't register correctly"
    );
  });
});

@@ -54,16 +54,45 @@
 Token');
+%0Aconst BN = require('bn.js');
 %0A%0A// bas
@@ -259,30 +259,8 @@
 en;%0A
-  let balancePerAcct;%0A
   //
@@ -453,37 +453,19 @@
 ken.
-INITIAL_SUPPLY.call().valueOf
+totalSupply
 ();%0A
@@ -661,37 +661,32 @@
 lToken.balanceOf
-.call
 (accounts%5B0%5D).va
@@ -682,26 +682,16 @@
 unts%5B0%5D)
-.valueOf()
 ;%0A    as
@@ -687,37 +687,38 @@
 0%5D);%0A    assert.
-equal
+isTrue
 (%0A      mainAcct
@@ -725,34 +725,19 @@
 Balance.
-toNumber(),%0A      
+eq(
 initBala
@@ -735,34 +735,24 @@
 (initBalance
-.toNumber(
 ),%0A      'En
@@ -933,52 +933,25 @@
 ance
- / 2;%0A    balancePerAcct = balanceToTransfer
+.div(new BN('2'))
 ;%0A  
@@ -1104,13 +1104,8 @@
 ceOf
-.call
 (acc
@@ -1117,18 +1117,8 @@
 %5B1%5D)
-.valueOf()
 ;%0A  
@@ -1130,21 +1130,15 @@
 ert.
-equal(%0A      
+isTrue(
 seco
@@ -1155,26 +1155,11 @@
 nce.
-toNumber(),%0A      
+eq(
 bala
@@ -1171,23 +1171,18 @@
 Transfer
+)
 ,
-%0A     
  %22Transf
@@ -1210,21 +1210,16 @@
 rrectly%22
-%0A    
 );%0A  %7D);

Fix CollateralToken tests