aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-05-10 05:41:44 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-05-31 08:11:30 +0800
commit4b71c65aea44bba34429e288c5411a090dd78071 (patch)
tree29fc4d79b6a74e7bfa0c23c5e5cada14de9f022f /packages/contracts/test
parent34ab53173daad302e0d13cbf5369116b373d72d3 (diff)
downloaddexon-sol-tools-4b71c65aea44bba34429e288c5411a090dd78071.tar
dexon-sol-tools-4b71c65aea44bba34429e288c5411a090dd78071.tar.gz
dexon-sol-tools-4b71c65aea44bba34429e288c5411a090dd78071.tar.bz2
dexon-sol-tools-4b71c65aea44bba34429e288c5411a090dd78071.tar.lz
dexon-sol-tools-4b71c65aea44bba34429e288c5411a090dd78071.tar.xz
dexon-sol-tools-4b71c65aea44bba34429e288c5411a090dd78071.tar.zst
dexon-sol-tools-4b71c65aea44bba34429e288c5411a090dd78071.zip
Update Whitelist contract with comments, also require maker to be whitelisted
Diffstat (limited to 'packages/contracts/test')
-rw-r--r--packages/contracts/test/exchange/transactions.ts33
1 files changed, 29 insertions, 4 deletions
diff --git a/packages/contracts/test/exchange/transactions.ts b/packages/contracts/test/exchange/transactions.ts
index 7242b0063..fe6df2f75 100644
--- a/packages/contracts/test/exchange/transactions.ts
+++ b/packages/contracts/test/exchange/transactions.ts
@@ -212,8 +212,12 @@ describe('Exchange transactions', () => {
let whitelistOrderFactory: OrderFactory;
before(async () => {
- const whitelistInstance = await deployer.deployAsync(ContractName.Whitelist, [exchange.address]);
- whitelist = new WhitelistContract(whitelistInstance.abi, whitelistInstance.address, provider);
+ whitelist = await WhitelistContract.deployFrom0xArtifactAsync(
+ artifacts.Whitelist,
+ provider,
+ txDefaults,
+ exchange.address,
+ );
const defaultOrderParams = {
...constants.STATIC_ORDER_PARAMS,
senderAddress: whitelist.address,
@@ -231,7 +235,28 @@ describe('Exchange transactions', () => {
erc20Balances = await erc20Wrapper.getBalancesAsync();
});
+ it('should revert if maker has not been whitelisted', async () => {
+ const isApproved = true;
+ await whitelist.updateWhitelistStatus.sendTransactionAsync(takerAddress, isApproved, { from: owner });
+
+ const orderStruct = orderUtils.getOrderStruct(signedOrder);
+ const takerAssetFillAmount = signedOrder.takerAssetAmount;
+ const salt = ZeroEx.generatePseudoRandomSalt();
+ return expect(
+ whitelist.fillOrderIfWhitelisted.sendTransactionAsync(
+ orderStruct,
+ takerAssetFillAmount,
+ salt,
+ signedOrder.signature,
+ { from: takerAddress },
+ ),
+ ).to.be.rejectedWith(constants.REVERT);
+ });
+
it('should revert if taker has not been whitelisted', async () => {
+ const isApproved = true;
+ await whitelist.updateWhitelistStatus.sendTransactionAsync(makerAddress, isApproved, { from: owner });
+
const orderStruct = orderUtils.getOrderStruct(signedOrder);
const takerAssetFillAmount = signedOrder.takerAssetAmount;
const salt = ZeroEx.generatePseudoRandomSalt();
@@ -246,8 +271,9 @@ describe('Exchange transactions', () => {
).to.be.rejectedWith(constants.REVERT);
});
- it('should fill the order if taker has been whitelisted', async () => {
+ it('should fill the order if maker and taker have been whitelisted', async () => {
const isApproved = true;
+ await whitelist.updateWhitelistStatus.sendTransactionAsync(makerAddress, isApproved, { from: owner });
await whitelist.updateWhitelistStatus.sendTransactionAsync(takerAddress, isApproved, { from: owner });
const orderStruct = orderUtils.getOrderStruct(signedOrder);
@@ -260,7 +286,6 @@ describe('Exchange transactions', () => {
signedOrder.signature,
{ from: takerAddress },
);
-
const newBalances = await erc20Wrapper.getBalancesAsync();
const makerAssetFillAmount = signedOrder.makerAssetAmount;