fillOrder tests with new wrapper
This commit is contained in:
parent
d882133e44
commit
7af2c751dc
@ -60,11 +60,11 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
|
|||||||
let erc20Wrapper: ERC20Wrapper;
|
let erc20Wrapper: ERC20Wrapper;
|
||||||
let erc20Balances: ERC20BalancesByOwner;
|
let erc20Balances: ERC20BalancesByOwner;
|
||||||
let balanceThresholdWrapper: BalanceThresholdWrapper;
|
let balanceThresholdWrapper: BalanceThresholdWrapper;
|
||||||
|
let nonCompliantBalanceThresholdWrapper: BalanceThresholdWrapper;
|
||||||
|
|
||||||
let takerTransactionFactory: TransactionFactory;
|
let takerTransactionFactory: TransactionFactory;
|
||||||
let compliantSignedOrder: SignedOrder;
|
let compliantSignedOrder: SignedOrder;
|
||||||
let compliantSignedFillOrderTx: SignedTransaction;
|
let compliantSignedFillOrderTx: SignedTransaction;
|
||||||
let noncompliantSignedFillOrderTx: SignedTransaction;
|
|
||||||
|
|
||||||
let logDecoder: LogDecoder;
|
let logDecoder: LogDecoder;
|
||||||
|
|
||||||
@ -237,6 +237,8 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
|
|||||||
throw new Error(`w`);*/
|
throw new Error(`w`);*/
|
||||||
logDecoder = new LogDecoder(web3Wrapper);
|
logDecoder = new LogDecoder(web3Wrapper);
|
||||||
balanceThresholdWrapper = new BalanceThresholdWrapper(compliantForwarderInstance, exchangeInstance, new TransactionFactory(takerPrivateKey, exchangeInstance.address), provider);
|
balanceThresholdWrapper = new BalanceThresholdWrapper(compliantForwarderInstance, exchangeInstance, new TransactionFactory(takerPrivateKey, exchangeInstance.address), provider);
|
||||||
|
const nonCompliantPrivateKey = constants.TESTRPC_PRIVATE_KEYS[accounts.indexOf(nonCompliantAddress)];
|
||||||
|
nonCompliantBalanceThresholdWrapper = new BalanceThresholdWrapper(compliantForwarderInstance, exchangeInstance, new TransactionFactory(nonCompliantPrivateKey, exchangeInstance.address), provider);
|
||||||
});
|
});
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await blockchainLifecycle.startAsync();
|
await blockchainLifecycle.startAsync();
|
||||||
@ -334,7 +336,7 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
|
|||||||
});
|
});
|
||||||
it('should transfer the correct amounts and validate both maker/taker when both maker and taker meet the balance threshold', async () => {
|
it('should transfer the correct amounts and validate both maker/taker when both maker and taker meet the balance threshold', async () => {
|
||||||
// Execute a valid fill
|
// Execute a valid fill
|
||||||
const txReceipt = await balanceThresholdWrapper.fillOrderAsync(compliantSignedOrder, compliantSignedFillOrderTx.signerAddress, {takerAssetFillAmount});
|
const txReceipt = await balanceThresholdWrapper.fillOrderAsync(compliantSignedOrder, compliantTakerAddress, {takerAssetFillAmount});
|
||||||
// Assert validated addresses
|
// Assert validated addresses
|
||||||
const expectedValidatedAddresseses = [compliantSignedOrder.makerAddress, compliantSignedFillOrderTx.signerAddress];
|
const expectedValidatedAddresseses = [compliantSignedOrder.makerAddress, compliantSignedFillOrderTx.signerAddress];
|
||||||
assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses);
|
assertValidatedAddressesLog(txReceipt, expectedValidatedAddresseses);
|
||||||
@ -377,35 +379,22 @@ describe.only(ContractName.BalanceThresholdFilter, () => {
|
|||||||
senderAddress: compliantForwarderInstance.address,
|
senderAddress: compliantForwarderInstance.address,
|
||||||
makerAddress: nonCompliantAddress
|
makerAddress: nonCompliantAddress
|
||||||
});
|
});
|
||||||
const signedOrderWithoutExchangeAddress = orderUtils.getOrderWithoutExchangeAddress(
|
// Execute transaction
|
||||||
signedOrderWithBadMakerAddress,
|
|
||||||
);
|
|
||||||
const signedOrderWithoutExchangeAddressData = exchangeInstance.fillOrder.getABIEncodedTransactionData(
|
|
||||||
signedOrderWithoutExchangeAddress,
|
|
||||||
takerAssetFillAmount,
|
|
||||||
compliantSignedOrder.signature,
|
|
||||||
);
|
|
||||||
const signedFillOrderTx = takerTransactionFactory.newSignedTransaction(
|
|
||||||
signedOrderWithoutExchangeAddressData,
|
|
||||||
);
|
|
||||||
// Call compliant forwarder
|
|
||||||
return expectTransactionFailedAsync(
|
return expectTransactionFailedAsync(
|
||||||
compliantForwarderInstance.executeTransaction.sendTransactionAsync(
|
balanceThresholdWrapper.fillOrderAsync(
|
||||||
signedFillOrderTx.salt,
|
signedOrderWithBadMakerAddress,
|
||||||
signedFillOrderTx.signerAddress,
|
compliantTakerAddress,
|
||||||
signedFillOrderTx.data,
|
{takerAssetFillAmount}
|
||||||
signedFillOrderTx.signature,
|
|
||||||
),
|
),
|
||||||
RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold
|
RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
it('should revert if taker does not meet the balance threshold', async () => {
|
it('should revert if taker does not meet the balance threshold', async () => {
|
||||||
return expectTransactionFailedAsync(
|
return expectTransactionFailedAsync(
|
||||||
compliantForwarderInstance.executeTransaction.sendTransactionAsync(
|
nonCompliantBalanceThresholdWrapper.fillOrderAsync(
|
||||||
compliantSignedFillOrderTx.salt,
|
compliantSignedOrder,
|
||||||
nonCompliantAddress,
|
nonCompliantAddress,
|
||||||
compliantSignedFillOrderTx.data,
|
{takerAssetFillAmount}
|
||||||
compliantSignedFillOrderTx.signature,
|
|
||||||
),
|
),
|
||||||
RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold
|
RevertReason.AtLeastOneAddressDoesNotMeetBalanceThreshold
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user