diff options
author | Fabio Berger <me@fabioberger.com> | 2018-06-14 17:17:13 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-06-14 17:17:13 +0800 |
commit | c232a32991725f2f05d61c40f1fb899d138544d2 (patch) | |
tree | bc59186ead3534fe08afc69d8bd05b47c1fde9a3 /packages/contracts/test | |
parent | 57f37939d5d422d2bac90e7576030ff41b8de7b4 (diff) | |
download | dexon-sol-tools-c232a32991725f2f05d61c40f1fb899d138544d2.tar dexon-sol-tools-c232a32991725f2f05d61c40f1fb899d138544d2.tar.gz dexon-sol-tools-c232a32991725f2f05d61c40f1fb899d138544d2.tar.bz2 dexon-sol-tools-c232a32991725f2f05d61c40f1fb899d138544d2.tar.lz dexon-sol-tools-c232a32991725f2f05d61c40f1fb899d138544d2.tar.xz dexon-sol-tools-c232a32991725f2f05d61c40f1fb899d138544d2.tar.zst dexon-sol-tools-c232a32991725f2f05d61c40f1fb899d138544d2.zip |
Use a defaultFillScenario in fillOrder tests
Diffstat (limited to 'packages/contracts/test')
-rw-r--r-- | packages/contracts/test/exchange/fill_order.ts | 75 |
1 files changed, 39 insertions, 36 deletions
diff --git a/packages/contracts/test/exchange/fill_order.ts b/packages/contracts/test/exchange/fill_order.ts index 9c289b950..3f49f6119 100644 --- a/packages/contracts/test/exchange/fill_order.ts +++ b/packages/contracts/test/exchange/fill_order.ts @@ -18,16 +18,19 @@ import { chaiSetup.configure(); const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper); -const defaultOrderScenario = { - takerScenario: TakerScenario.Unspecified, - feeRecipientScenario: FeeRecipientAddressScenario.EthUserAddress, - makerAssetAmountScenario: OrderAmountScenario.Large, - takerAssetAmountScenario: OrderAmountScenario.Large, - makerFeeScenario: OrderAmountScenario.Large, - takerFeeScenario: OrderAmountScenario.Large, - expirationTimeSecondsScenario: ExpirationTimeSecondsScenario.InFuture, - makerAssetDataScenario: AssetDataScenario.ERC20NonZRXEighteenDecimals, - takerAssetDataScenario: AssetDataScenario.ERC20NonZRXEighteenDecimals, +const defaultFillScenario = { + orderScenario: { + takerScenario: TakerScenario.Unspecified, + feeRecipientScenario: FeeRecipientAddressScenario.EthUserAddress, + makerAssetAmountScenario: OrderAmountScenario.Large, + takerAssetAmountScenario: OrderAmountScenario.Large, + makerFeeScenario: OrderAmountScenario.Large, + takerFeeScenario: OrderAmountScenario.Large, + expirationTimeSecondsScenario: ExpirationTimeSecondsScenario.InFuture, + makerAssetDataScenario: AssetDataScenario.ERC20NonZRXEighteenDecimals, + takerAssetDataScenario: AssetDataScenario.ERC20NonZRXEighteenDecimals, + }, + takerAssetFillAmountScenario: TakerAssetFillAmountScenario.LessThanRemainingFillableTakerAssetAmount, }; describe.only('FillOrder Tests', () => { @@ -49,86 +52,83 @@ describe.only('FillOrder Tests', () => { describe('fillOrder', () => { it('should transfer the correct amounts when makerAssetAmount === takerAssetAmount', async () => { const fillScenario = { - orderScenario: defaultOrderScenario, - takerAssetFillAmountScenario: TakerAssetFillAmountScenario.LessThanRemainingFillableTakerAssetAmount, + ...defaultFillScenario, }; await coreCombinatorialUtils.testFillOrderScenarioAsync(provider, fillScenario); }); it('should transfer the correct amounts when makerAssetAmount > takerAssetAmount', async () => { const fillScenario = { + ...defaultFillScenario, orderScenario: { - ...defaultOrderScenario, + ...defaultFillScenario.orderScenario, takerAssetAmountScenario: OrderAmountScenario.Small, }, - takerAssetFillAmountScenario: TakerAssetFillAmountScenario.LessThanRemainingFillableTakerAssetAmount, }; await coreCombinatorialUtils.testFillOrderScenarioAsync(provider, fillScenario); }); it('should transfer the correct amounts when makerAssetAmount < takerAssetAmount', async () => { const fillScenario = { + ...defaultFillScenario, orderScenario: { - ...defaultOrderScenario, + ...defaultFillScenario.orderScenario, makerAssetAmountScenario: OrderAmountScenario.Small, }, - takerAssetFillAmountScenario: TakerAssetFillAmountScenario.LessThanRemainingFillableTakerAssetAmount, }; await coreCombinatorialUtils.testFillOrderScenarioAsync(provider, fillScenario); }); it('should transfer the correct amounts when taker is specified and order is claimed by taker', async () => { const fillScenario = { + ...defaultFillScenario, orderScenario: { - ...defaultOrderScenario, + ...defaultFillScenario.orderScenario, takerScenario: TakerScenario.CorrectlySpecified, }, - takerAssetFillAmountScenario: TakerAssetFillAmountScenario.LessThanRemainingFillableTakerAssetAmount, }; await coreCombinatorialUtils.testFillOrderScenarioAsync(provider, fillScenario); }); it('should fill remaining value if takerAssetFillAmount > remaining takerAssetAmount', async () => { const fillScenario = { - orderScenario: defaultOrderScenario, + ...defaultFillScenario, takerAssetFillAmountScenario: TakerAssetFillAmountScenario.GreaterThanRemainingFillableTakerAssetAmount, }; await coreCombinatorialUtils.testFillOrderScenarioAsync(provider, fillScenario); }); it('should throw when taker is specified and order is claimed by other', async () => { const fillScenario = { + ...defaultFillScenario, orderScenario: { - ...defaultOrderScenario, + ...defaultFillScenario.orderScenario, takerScenario: TakerScenario.IncorrectlySpecified, }, - takerAssetFillAmountScenario: TakerAssetFillAmountScenario.LessThanRemainingFillableTakerAssetAmount, }; await coreCombinatorialUtils.testFillOrderScenarioAsync(provider, fillScenario); }); it('should throw if makerAssetAmount is 0', async () => { const fillScenario = { + ...defaultFillScenario, orderScenario: { - ...defaultOrderScenario, + ...defaultFillScenario.orderScenario, makerAssetAmountScenario: OrderAmountScenario.Zero, }, - takerAssetFillAmountScenario: TakerAssetFillAmountScenario.LessThanRemainingFillableTakerAssetAmount, }; await coreCombinatorialUtils.testFillOrderScenarioAsync(provider, fillScenario); }); it('should throw if takerAssetAmount is 0', async () => { const fillScenario = { + ...defaultFillScenario, orderScenario: { - ...defaultOrderScenario, + ...defaultFillScenario.orderScenario, takerAssetAmountScenario: OrderAmountScenario.Zero, }, - takerAssetFillAmountScenario: TakerAssetFillAmountScenario.LessThanRemainingFillableTakerAssetAmount, }; await coreCombinatorialUtils.testFillOrderScenarioAsync(provider, fillScenario); }); it('should throw if takerAssetFillAmount is 0', async () => { const fillScenario = { - orderScenario: { - ...defaultOrderScenario, - }, + ...defaultFillScenario, takerAssetFillAmountScenario: TakerAssetFillAmountScenario.Zero, }; await coreCombinatorialUtils.testFillOrderScenarioAsync(provider, fillScenario); @@ -136,11 +136,11 @@ describe.only('FillOrder Tests', () => { it('should throw if an order is expired', async () => { const fillScenario = { + ...defaultFillScenario, orderScenario: { - ...defaultOrderScenario, + ...defaultFillScenario.orderScenario, expirationTimeSecondsScenario: ExpirationTimeSecondsScenario.InPast, }, - takerAssetFillAmountScenario: TakerAssetFillAmountScenario.LessThanRemainingFillableTakerAssetAmount, }; await coreCombinatorialUtils.testFillOrderScenarioAsync(provider, fillScenario); }); @@ -149,36 +149,39 @@ describe.only('FillOrder Tests', () => { describe('Testing Exchange of ERC721 Tokens', () => { it('should successfully exchange a single token between the maker and taker (via fillOrder)', async () => { const fillScenario = { + ...defaultFillScenario, orderScenario: { - ...defaultOrderScenario, + ...defaultFillScenario.orderScenario, makerAssetDataScenario: AssetDataScenario.ERC721, takerAssetDataScenario: AssetDataScenario.ERC721, }, - takerAssetFillAmountScenario: TakerAssetFillAmountScenario.LessThanRemainingFillableTakerAssetAmount, + takerAssetFillAmountScenario: TakerAssetFillAmountScenario.ExactlyRemainingFillableTakerAssetAmount, }; await coreCombinatorialUtils.testFillOrderScenarioAsync(provider, fillScenario); }); it('should successfully fill order when makerAsset is ERC721 and takerAsset is ERC20', async () => { const fillScenario = { + ...defaultFillScenario, orderScenario: { - ...defaultOrderScenario, + ...defaultFillScenario.orderScenario, makerAssetDataScenario: AssetDataScenario.ERC721, takerAssetDataScenario: AssetDataScenario.ERC20NonZRXEighteenDecimals, }, - takerAssetFillAmountScenario: TakerAssetFillAmountScenario.LessThanRemainingFillableTakerAssetAmount, + takerAssetFillAmountScenario: TakerAssetFillAmountScenario.ExactlyRemainingFillableTakerAssetAmount, }; await coreCombinatorialUtils.testFillOrderScenarioAsync(provider, fillScenario); }); it('should successfully fill order when makerAsset is ERC20 and takerAsset is ERC721', async () => { const fillScenario = { + ...defaultFillScenario, orderScenario: { - ...defaultOrderScenario, + ...defaultFillScenario.orderScenario, makerAssetDataScenario: AssetDataScenario.ERC20NonZRXEighteenDecimals, takerAssetDataScenario: AssetDataScenario.ERC721, }, - takerAssetFillAmountScenario: TakerAssetFillAmountScenario.LessThanRemainingFillableTakerAssetAmount, + takerAssetFillAmountScenario: TakerAssetFillAmountScenario.ExactlyRemainingFillableTakerAssetAmount, }; await coreCombinatorialUtils.testFillOrderScenarioAsync(provider, fillScenario); }); |