Skip to content

Commit

Permalink
Tests: use --fix for all linter indentation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Banks committed Feb 4, 2019
1 parent 51bc30c commit 22c4e4a
Show file tree
Hide file tree
Showing 42 changed files with 3,901 additions and 3,901 deletions.
496 changes: 248 additions & 248 deletions test/branded_token/accept_stake_request.js

Large diffs are not rendered by default.

218 changes: 109 additions & 109 deletions test/branded_token/constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,116 +20,116 @@ const utils = require('../test_lib/utils');
const BrandedToken = artifacts.require('BrandedToken');

contract('BrandedToken::constructor', async () => {
contract('Negative Tests', async (accounts) => {
const accountProvider = new AccountProvider(accounts);

const symbol = 'BT';
const name = 'BrandedToken';
const decimals = 18;
const organization = accountProvider.get();

it('Reverts if valueToken is zero', async () => {
const valueToken = utils.NULL_ADDRESS;
const conversionRate = 35;
const conversionRateDecimals = 1;

await utils.expectRevert(
BrandedToken.new(
valueToken,
symbol,
name,
decimals,
conversionRate,
conversionRateDecimals,
organization,
),
'Should revert as valueToken is zero.',
'ValueToken is zero.',
);
});

it('Reverts if conversionRate is zero', async () => {
const valueToken = accountProvider.get();
const conversionRate = 0;
const conversionRateDecimals = 1;

await utils.expectRevert(
BrandedToken.new(
valueToken,
symbol,
name,
decimals,
conversionRate,
conversionRateDecimals,
organization,
),
'Should revert as conversionRate is zero.',
'ConversionRate is zero.',
);
});

it('Reverts if conversionRateDecimals is greater than 5', async () => {
const valueToken = accountProvider.get();
const conversionRate = 35;
const conversionRateDecimals = 6;

await utils.expectRevert(
BrandedToken.new(
valueToken,
symbol,
name,
decimals,
conversionRate,
conversionRateDecimals,
organization,
),
'Should revert as conversionRateDecimals is greater than 5.',
'ConversionRateDecimals is greater than 5.',
);
});
contract('Negative Tests', async (accounts) => {
const accountProvider = new AccountProvider(accounts);

const symbol = 'BT';
const name = 'BrandedToken';
const decimals = 18;
const organization = accountProvider.get();

it('Reverts if valueToken is zero', async () => {
const valueToken = utils.NULL_ADDRESS;
const conversionRate = 35;
const conversionRateDecimals = 1;

await utils.expectRevert(
BrandedToken.new(
valueToken,
symbol,
name,
decimals,
conversionRate,
conversionRateDecimals,
organization,
),
'Should revert as valueToken is zero.',
'ValueToken is zero.',
);
});

contract('Storage', async (accounts) => {
const accountProvider = new AccountProvider(accounts);

const symbol = 'BT';
const name = 'BrandedToken';
const decimals = 18;
const organization = accountProvider.get();

it('Successfully sets state variables', async () => {
const valueToken = accountProvider.get();
const conversionRate = 35;
const conversionRateDecimals = 1;

const brandedToken = await BrandedToken.new(
valueToken,
symbol,
name,
decimals,
conversionRate,
conversionRateDecimals,
organization,
);

assert.strictEqual(
(await brandedToken.valueToken()),
valueToken,
);

assert.strictEqual(
(await brandedToken.conversionRate()).cmp(
new BN(conversionRate),
),
0,
);

assert.strictEqual(
(await brandedToken.conversionRateDecimals()).cmp(
new BN(conversionRateDecimals),
),
0,
);
});
it('Reverts if conversionRate is zero', async () => {
const valueToken = accountProvider.get();
const conversionRate = 0;
const conversionRateDecimals = 1;

await utils.expectRevert(
BrandedToken.new(
valueToken,
symbol,
name,
decimals,
conversionRate,
conversionRateDecimals,
organization,
),
'Should revert as conversionRate is zero.',
'ConversionRate is zero.',
);
});

it('Reverts if conversionRateDecimals is greater than 5', async () => {
const valueToken = accountProvider.get();
const conversionRate = 35;
const conversionRateDecimals = 6;

await utils.expectRevert(
BrandedToken.new(
valueToken,
symbol,
name,
decimals,
conversionRate,
conversionRateDecimals,
organization,
),
'Should revert as conversionRateDecimals is greater than 5.',
'ConversionRateDecimals is greater than 5.',
);
});
});

contract('Storage', async (accounts) => {
const accountProvider = new AccountProvider(accounts);

const symbol = 'BT';
const name = 'BrandedToken';
const decimals = 18;
const organization = accountProvider.get();

it('Successfully sets state variables', async () => {
const valueToken = accountProvider.get();
const conversionRate = 35;
const conversionRateDecimals = 1;

const brandedToken = await BrandedToken.new(
valueToken,
symbol,
name,
decimals,
conversionRate,
conversionRateDecimals,
organization,
);

assert.strictEqual(
(await brandedToken.valueToken()),
valueToken,
);

assert.strictEqual(
(await brandedToken.conversionRate()).cmp(
new BN(conversionRate),
),
0,
);

assert.strictEqual(
(await brandedToken.conversionRateDecimals()).cmp(
new BN(conversionRateDecimals),
),
0,
);
});
});
});
126 changes: 63 additions & 63 deletions test/branded_token/convert_to_branded_tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,77 +18,77 @@ const { AccountProvider } = require('../test_lib/utils.js');
const BrandedTokenUtils = require('./utils.js');

contract('BrandedToken::convertToBrandedTokens', async () => {
contract('Returns', async (accounts) => {
it('Correctly converts to branded tokens', async () => {
const accountProvider = new AccountProvider(accounts);
contract('Returns', async (accounts) => {
it('Correctly converts to branded tokens', async () => {
const accountProvider = new AccountProvider(accounts);

const {
brandedToken,
} = await BrandedTokenUtils.setupBrandedToken(
accountProvider,
);
const {
brandedToken,
} = await BrandedTokenUtils.setupBrandedToken(
accountProvider,
);

const conversionRate = await brandedToken.conversionRate();
const conversionRateDecimals = await brandedToken.conversionRateDecimals();
const conversionRate = await brandedToken.conversionRate();
const conversionRateDecimals = await brandedToken.conversionRateDecimals();

// Conversion without loss
// Depending on the conversion rate, some amounts
// converts without loss; e.g., when conversion is 1:3.5
// - conversionRate == 35
// - conversionRateDecimals == 1
// - 2 --> 7
const valueTokensLossless = new BN(2);
const brandedTokensLossless = await brandedToken
.convertToBrandedTokens(valueTokensLossless);
// Conversion without loss
// Depending on the conversion rate, some amounts
// converts without loss; e.g., when conversion is 1:3.5
// - conversionRate == 35
// - conversionRateDecimals == 1
// - 2 --> 7
const valueTokensLossless = new BN(2);
const brandedTokensLossless = await brandedToken
.convertToBrandedTokens(valueTokensLossless);

assert.strictEqual(
brandedTokensLossless.cmp(
valueTokensLossless
.mul(conversionRate)
.div(new BN(10).pow(conversionRateDecimals)),
),
0,
);
assert.strictEqual(
brandedTokensLossless.cmp(
valueTokensLossless
.mul(conversionRate)
.div(new BN(10).pow(conversionRateDecimals)),
),
0,
);

assert.strictEqual(
brandedTokensLossless.cmp(
new BN(7),
),
0,
);
assert.strictEqual(
brandedTokensLossless.cmp(
new BN(7),
),
0,
);

// Conversion with loss
// At other amounts of value tokens, there will be loss
// due to Solidity not supportin fixed or floating point
// math; e.g., when conversion is 1:3.5
// - conversionRate == 35
// - conversionRateDecimals == 1
// - 1 --> 3, not 3.5
const valueTokensLoss = new BN(1);
const brandedTokensLoss = await brandedToken
.convertToBrandedTokens(valueTokensLoss);
// Conversion with loss
// At other amounts of value tokens, there will be loss
// due to Solidity not supportin fixed or floating point
// math; e.g., when conversion is 1:3.5
// - conversionRate == 35
// - conversionRateDecimals == 1
// - 1 --> 3, not 3.5
const valueTokensLoss = new BN(1);
const brandedTokensLoss = await brandedToken
.convertToBrandedTokens(valueTokensLoss);

assert.strictEqual(
brandedTokensLoss.cmp(
valueTokensLoss
.mul(conversionRate)
.div(new BN(10).pow(conversionRateDecimals)),
),
0,
);
assert.strictEqual(
brandedTokensLoss.cmp(
valueTokensLoss
.mul(conversionRate)
.div(new BN(10).pow(conversionRateDecimals)),
),
0,
);

// 1 converts to 3, not 3.5, so there is a loss
assert.strictEqual(
brandedTokensLoss.cmp(
new BN(3),
),
0,
);
// 1 converts to 3, not 3.5, so there is a loss
assert.strictEqual(
brandedTokensLoss.cmp(
new BN(3),
),
0,
);

// N.B.: values above are miniscule, because the
// decimals for the test tokens are 18; consequently,
// the potential for and degree of loss
// as indicated above is considered acceptable
});
// N.B.: values above are miniscule, because the
// decimals for the test tokens are 18; consequently,
// the potential for and degree of loss
// as indicated above is considered acceptable
});
});
});
Loading

0 comments on commit 22c4e4a

Please sign in to comment.