@0x:contracts-exchange Added tests for matchOrders protocol fees

This commit is contained in:
Alex Towle
2019-08-28 00:29:16 -07:00
parent dd0d848530
commit cc7b8359b4
2 changed files with 147 additions and 9 deletions

View File

@@ -3,7 +3,7 @@ import { BigNumber } from '@0x/utils';
import { artifacts, TestProtocolFeesContract, TestProtocolFeesReceiverContract } from '../src';
blockchainTests('Protocol Fee Payments', env => {
blockchainTests.only('Protocol Fee Payments', env => {
let testProtocolFees: TestProtocolFeesContract;
let testProtocolFeesReceiver: TestProtocolFeesReceiverContract;
@@ -75,4 +75,54 @@ blockchainTests('Protocol Fee Payments', env => {
);
});
});
blockchainTests.resets('matchOrders Protocol Fees', () => {
it('should not pay protocol fee when there is no registered protocol fee collector', async () => {
await testProtocolFeesReceiver.testMatchOrdersProtocolFees.awaitTransactionSuccessAsync(
testProtocolFees.address,
DEFAULT_PROTOCOL_FEE_MULTIPLIER,
false,
{
gasPrice: DEFAULT_GAS_PRICE,
value: DEFAULT_PROTOCOL_FEE,
},
);
});
it('should pay protocol fee in WETH when too little value is sent', async () => {
await testProtocolFeesReceiver.testMatchOrdersProtocolFees.awaitTransactionSuccessAsync(
testProtocolFees.address,
DEFAULT_PROTOCOL_FEE_MULTIPLIER,
true,
{
gasPrice: DEFAULT_GAS_PRICE,
value: DEFAULT_PROTOCOL_FEE.minus(new BigNumber(10)),
},
);
});
it('should pay protocol fee in ETH when the correct value is sent', async () => {
await testProtocolFeesReceiver.testMatchOrdersProtocolFees.awaitTransactionSuccessAsync(
testProtocolFees.address,
DEFAULT_PROTOCOL_FEE_MULTIPLIER,
true,
{
gasPrice: DEFAULT_GAS_PRICE,
value: DEFAULT_PROTOCOL_FEE,
},
);
});
it('should pay protocol fee in ETH when extra value is sent', async () => {
await testProtocolFeesReceiver.testMatchOrdersProtocolFees.awaitTransactionSuccessAsync(
testProtocolFees.address,
DEFAULT_PROTOCOL_FEE_MULTIPLIER,
true,
{
gasPrice: DEFAULT_GAS_PRICE,
value: DEFAULT_PROTOCOL_FEE.plus(new BigNumber(10)),
},
);
});
});
});