aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-08-22 09:14:22 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-08-22 09:14:22 +0800
commit3760eb5bafcc0980b3a42dd5f10e745390702b16 (patch)
tree964c5c3cb0eeacf70bece4e485b5fddceea2adb4 /packages/contracts/test
parent7fa5b474ebac649b6a23c8b9108e07c117dcc00b (diff)
downloaddexon-sol-tools-3760eb5bafcc0980b3a42dd5f10e745390702b16.tar
dexon-sol-tools-3760eb5bafcc0980b3a42dd5f10e745390702b16.tar.gz
dexon-sol-tools-3760eb5bafcc0980b3a42dd5f10e745390702b16.tar.bz2
dexon-sol-tools-3760eb5bafcc0980b3a42dd5f10e745390702b16.tar.lz
dexon-sol-tools-3760eb5bafcc0980b3a42dd5f10e745390702b16.tar.xz
dexon-sol-tools-3760eb5bafcc0980b3a42dd5f10e745390702b16.tar.zst
dexon-sol-tools-3760eb5bafcc0980b3a42dd5f10e745390702b16.zip
Add getBalancesAndAllowances
Diffstat (limited to 'packages/contracts/test')
-rw-r--r--packages/contracts/test/extensions/order_validator.ts50
1 files changed, 50 insertions, 0 deletions
diff --git a/packages/contracts/test/extensions/order_validator.ts b/packages/contracts/test/extensions/order_validator.ts
index a3b704f27..3a57cfc37 100644
--- a/packages/contracts/test/extensions/order_validator.ts
+++ b/packages/contracts/test/extensions/order_validator.ts
@@ -217,6 +217,56 @@ describe('OrderValidator', () => {
});
});
});
+ describe('getBalancesAndAllowances', () => {
+ it('should return the correct balances and allowances when all values are 0', async () => {
+ const [
+ [erc20Balance, erc721Balance],
+ [erc20Allowance, erc721Allowance],
+ ] = await orderValidator.getBalancesAndAllowances.callAsync(makerAddress, [
+ erc20AssetData,
+ erc721AssetData,
+ ]);
+ expect(erc20Balance).to.be.bignumber.equal(constants.ZERO_AMOUNT);
+ expect(erc721Balance).to.be.bignumber.equal(constants.ZERO_AMOUNT);
+ expect(erc20Allowance).to.be.bignumber.equal(constants.ZERO_AMOUNT);
+ expect(erc721Allowance).to.be.bignumber.equal(constants.ZERO_AMOUNT);
+ });
+ it('should return the correct balances and allowances when balances and allowances are non-zero', async () => {
+ const balance = new BigNumber(123);
+ const allowance = new BigNumber(456);
+ await web3Wrapper.awaitTransactionSuccessAsync(
+ await erc20Token.setBalance.sendTransactionAsync(makerAddress, balance),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
+ await web3Wrapper.awaitTransactionSuccessAsync(
+ await erc20Token.approve.sendTransactionAsync(erc20Proxy.address, allowance, {
+ from: makerAddress,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
+ await web3Wrapper.awaitTransactionSuccessAsync(
+ await erc721Token.mint.sendTransactionAsync(makerAddress, tokenId),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
+ await web3Wrapper.awaitTransactionSuccessAsync(
+ await erc721Token.approve.sendTransactionAsync(erc721Proxy.address, tokenId, {
+ from: makerAddress,
+ }),
+ constants.AWAIT_TRANSACTION_MINED_MS,
+ );
+ const [
+ [erc20Balance, erc721Balance],
+ [erc20Allowance, erc721Allowance],
+ ] = await orderValidator.getBalancesAndAllowances.callAsync(makerAddress, [
+ erc20AssetData,
+ erc721AssetData,
+ ]);
+ expect(erc20Balance).to.be.bignumber.equal(balance);
+ expect(erc721Balance).to.be.bignumber.equal(ERC721_BALANCE);
+ expect(erc20Allowance).to.be.bignumber.equal(allowance);
+ expect(erc721Allowance).to.be.bignumber.equal(ERC721_ALLOWANCE);
+ });
+ });
describe('getTraderInfo', () => {
beforeEach(async () => {
signedOrder = await orderFactory.newSignedOrderAsync();