aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test/ts/unlimitedAllowanceToken.ts
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2017-11-30 14:26:51 +0800
committerAmir Bandeali <abandeali1@gmail.com>2017-11-30 23:10:18 +0800
commite85a69655c29a04b7f1a3506c5ecb55433425f7f (patch)
treed085c0f6fd46980c85f92f60adf95a6b8f272c49 /packages/contracts/test/ts/unlimitedAllowanceToken.ts
parent4b3e0383235ca4ca0127f24c2e05543bb45a56bb (diff)
downloaddexon-sol-tools-e85a69655c29a04b7f1a3506c5ecb55433425f7f.tar
dexon-sol-tools-e85a69655c29a04b7f1a3506c5ecb55433425f7f.tar.gz
dexon-sol-tools-e85a69655c29a04b7f1a3506c5ecb55433425f7f.tar.bz2
dexon-sol-tools-e85a69655c29a04b7f1a3506c5ecb55433425f7f.tar.lz
dexon-sol-tools-e85a69655c29a04b7f1a3506c5ecb55433425f7f.tar.xz
dexon-sol-tools-e85a69655c29a04b7f1a3506c5ecb55433425f7f.tar.zst
dexon-sol-tools-e85a69655c29a04b7f1a3506c5ecb55433425f7f.zip
Fix indentations
Diffstat (limited to 'packages/contracts/test/ts/unlimitedAllowanceToken.ts')
-rw-r--r--packages/contracts/test/ts/unlimitedAllowanceToken.ts186
1 files changed, 93 insertions, 93 deletions
diff --git a/packages/contracts/test/ts/unlimitedAllowanceToken.ts b/packages/contracts/test/ts/unlimitedAllowanceToken.ts
index cf217a8b6..ca3fcd7d2 100644
--- a/packages/contracts/test/ts/unlimitedAllowanceToken.ts
+++ b/packages/contracts/test/ts/unlimitedAllowanceToken.ts
@@ -14,102 +14,102 @@ chaiSetup.configure();
const expect = chai.expect;
contract('UnlimitedAllowanceToken', (accounts: string[]) => {
- const zeroEx = new ZeroEx(web3.currentProvider);
- const owner = accounts[0];
- const spender = accounts[1];
-
- const MAX_MINT_VALUE = new BigNumber(100000000000000000000);
- let tokenAddress: string;
- let token: ContractInstance;
-
- beforeEach(async () => {
- token = await DummyToken.new({from: owner});
- await token.mint(MAX_MINT_VALUE, {from: owner});
- tokenAddress = token.address;
- });
-
- describe('transfer', () => {
- it('should transfer balance from sender to receiver', async () => {
- const receiver = spender;
- const initOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
- const amountToTransfer = new BigNumber(1);
- await zeroEx.token.transferAsync(tokenAddress, owner, receiver, amountToTransfer);
- const finalOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
- const finalReceiverBalance = await zeroEx.token.getBalanceAsync(tokenAddress, receiver);
-
- const expectedFinalOwnerBalance = initOwnerBalance.minus(amountToTransfer);
- const expectedFinalReceiverBalance = amountToTransfer;
- expect(finalOwnerBalance).to.be.bignumber.equal(expectedFinalOwnerBalance);
- expect(finalReceiverBalance).to.be.bignumber.equal(expectedFinalReceiverBalance);
+ const zeroEx = new ZeroEx(web3.currentProvider);
+ const owner = accounts[0];
+ const spender = accounts[1];
+
+ const MAX_MINT_VALUE = new BigNumber(100000000000000000000);
+ let tokenAddress: string;
+ let token: ContractInstance;
+
+ beforeEach(async () => {
+ token = await DummyToken.new({from: owner});
+ await token.mint(MAX_MINT_VALUE, {from: owner});
+ tokenAddress = token.address;
});
- it('should return true on a 0 value transfer', async () => {
- const didReturnTrue = await token.transfer.call(spender, 0, {from: owner});
- expect(didReturnTrue).to.be.true();
+ describe('transfer', () => {
+ it('should transfer balance from sender to receiver', async () => {
+ const receiver = spender;
+ const initOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
+ const amountToTransfer = new BigNumber(1);
+ await zeroEx.token.transferAsync(tokenAddress, owner, receiver, amountToTransfer);
+ const finalOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
+ const finalReceiverBalance = await zeroEx.token.getBalanceAsync(tokenAddress, receiver);
+
+ const expectedFinalOwnerBalance = initOwnerBalance.minus(amountToTransfer);
+ const expectedFinalReceiverBalance = amountToTransfer;
+ expect(finalOwnerBalance).to.be.bignumber.equal(expectedFinalOwnerBalance);
+ expect(finalReceiverBalance).to.be.bignumber.equal(expectedFinalReceiverBalance);
+ });
+
+ it('should return true on a 0 value transfer', async () => {
+ const didReturnTrue = await token.transfer.call(spender, 0, {from: owner});
+ expect(didReturnTrue).to.be.true();
+ });
});
- });
-
- describe('transferFrom', () => {
- it('should return false if owner has insufficient balance', async () => {
- const ownerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
- const amountToTransfer = ownerBalance.plus(1);
- await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, amountToTransfer);
- const didReturnTrue = await token.transferFrom.call(owner, spender, amountToTransfer, {from: spender});
- expect(didReturnTrue).to.be.false();
- });
-
- it('should return false if spender has insufficient allowance', async () => {
- const ownerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
- const amountToTransfer = ownerBalance;
-
- const spenderAllowance = await zeroEx.token.getAllowanceAsync(tokenAddress, owner, spender);
- const spenderAllowanceIsInsufficient = spenderAllowance.cmp(amountToTransfer) < 0;
- expect(spenderAllowanceIsInsufficient).to.be.true();
-
- const didReturnTrue = await token.transferFrom.call(owner, spender, amountToTransfer, {from: spender});
- expect(didReturnTrue).to.be.false();
- });
-
- it('should return true on a 0 value transfer', async () => {
- const amountToTransfer = 0;
- const didReturnTrue = await token.transferFrom.call(owner, spender, amountToTransfer, {from: spender});
- expect(didReturnTrue).to.be.true();
- });
-
- it('should not modify spender allowance if spender allowance is 2^256 - 1', async () => {
- const initOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
- const amountToTransfer = initOwnerBalance;
- const initSpenderAllowance = zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
- await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance);
- await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer);
-
- const newSpenderAllowance = await zeroEx.token.getAllowanceAsync(tokenAddress, owner, spender);
- expect(initSpenderAllowance).to.be.bignumber.equal(newSpenderAllowance);
- });
-
- it('should transfer the correct balances if spender has sufficient allowance', async () => {
- const initOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
- const amountToTransfer = initOwnerBalance;
- const initSpenderAllowance = initOwnerBalance;
- await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance);
- await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer);
-
- const newOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
- const newSpenderBalance = await zeroEx.token.getBalanceAsync(tokenAddress, spender);
-
- expect(newOwnerBalance).to.be.bignumber.equal(0);
- expect(newSpenderBalance).to.be.bignumber.equal(initOwnerBalance);
- });
-
- it('should modify allowance if spender has sufficient allowance less than 2^256 - 1', async () => {
- const initOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
- const amountToTransfer = initOwnerBalance;
- const initSpenderAllowance = initOwnerBalance;
- await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance);
- await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer);
- const newSpenderAllowance = await zeroEx.token.getAllowanceAsync(tokenAddress, owner, spender);
- expect(newSpenderAllowance).to.be.bignumber.equal(0);
+ describe('transferFrom', () => {
+ it('should return false if owner has insufficient balance', async () => {
+ const ownerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
+ const amountToTransfer = ownerBalance.plus(1);
+ await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, amountToTransfer);
+ const didReturnTrue = await token.transferFrom.call(owner, spender, amountToTransfer, {from: spender});
+ expect(didReturnTrue).to.be.false();
+ });
+
+ it('should return false if spender has insufficient allowance', async () => {
+ const ownerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
+ const amountToTransfer = ownerBalance;
+
+ const spenderAllowance = await zeroEx.token.getAllowanceAsync(tokenAddress, owner, spender);
+ const spenderAllowanceIsInsufficient = spenderAllowance.cmp(amountToTransfer) < 0;
+ expect(spenderAllowanceIsInsufficient).to.be.true();
+
+ const didReturnTrue = await token.transferFrom.call(owner, spender, amountToTransfer, {from: spender});
+ expect(didReturnTrue).to.be.false();
+ });
+
+ it('should return true on a 0 value transfer', async () => {
+ const amountToTransfer = 0;
+ const didReturnTrue = await token.transferFrom.call(owner, spender, amountToTransfer, {from: spender});
+ expect(didReturnTrue).to.be.true();
+ });
+
+ it('should not modify spender allowance if spender allowance is 2^256 - 1', async () => {
+ const initOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
+ const amountToTransfer = initOwnerBalance;
+ const initSpenderAllowance = zeroEx.token.UNLIMITED_ALLOWANCE_IN_BASE_UNITS;
+ await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance);
+ await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer);
+
+ const newSpenderAllowance = await zeroEx.token.getAllowanceAsync(tokenAddress, owner, spender);
+ expect(initSpenderAllowance).to.be.bignumber.equal(newSpenderAllowance);
+ });
+
+ it('should transfer the correct balances if spender has sufficient allowance', async () => {
+ const initOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
+ const amountToTransfer = initOwnerBalance;
+ const initSpenderAllowance = initOwnerBalance;
+ await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance);
+ await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer);
+
+ const newOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
+ const newSpenderBalance = await zeroEx.token.getBalanceAsync(tokenAddress, spender);
+
+ expect(newOwnerBalance).to.be.bignumber.equal(0);
+ expect(newSpenderBalance).to.be.bignumber.equal(initOwnerBalance);
+ });
+
+ it('should modify allowance if spender has sufficient allowance less than 2^256 - 1', async () => {
+ const initOwnerBalance = await zeroEx.token.getBalanceAsync(tokenAddress, owner);
+ const amountToTransfer = initOwnerBalance;
+ const initSpenderAllowance = initOwnerBalance;
+ await zeroEx.token.setAllowanceAsync(tokenAddress, owner, spender, initSpenderAllowance);
+ await zeroEx.token.transferFromAsync(tokenAddress, owner, spender, spender, amountToTransfer);
+
+ const newSpenderAllowance = await zeroEx.token.getAllowanceAsync(tokenAddress, owner, spender);
+ expect(newSpenderAllowance).to.be.bignumber.equal(0);
+ });
});
- });
});