Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SevenSwen committed Sep 28, 2023
1 parent 37d9175 commit e215888
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
16 changes: 9 additions & 7 deletions test/LimitOrderProtocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,9 @@ describe('LimitOrderProtocol', function () {
minReturn: 1n,
takerPermit: order.takerAsset + trim0x(permit),
});
await swap.fillOrderArgs(order, r, vs, 1, takerTraits.traits, takerTraits.args);
await expect(swap.fillOrderArgs(order, r, vs, 1, takerTraits.traits, takerTraits.args))
.to.be.revertedWith('ERC20Permit: invalid signature');
const tx = await swap.populateTransaction.fillOrderArgs(order, r, vs, 1, takerTraits.traits, takerTraits.args);
await addr.sendTransaction(tx);
await expect(addr.sendTransaction(tx)).to.be.revertedWithCustomError(swap, 'InvalidatedOrder');
});

it('skips wrong signature is allowance is enough', async function () {
Expand Down Expand Up @@ -514,8 +514,9 @@ describe('LimitOrderProtocol', function () {
takerPermit: order.takerAsset + trim0x(permit),
});
await weth.approve(swap.address, 0);
await expect(swap.fillOrderArgs(order, r, vs, 1, takerTraits.traits, takerTraits.args))
.to.be.revertedWith('ERC20Permit: invalid signature');

const tx = await swap.populateTransaction.fillOrderArgs(order, r, vs, 1, takerTraits.traits, takerTraits.args);
await expect(addr.sendTransaction(tx)).to.be.revertedWithCustomError(swap, 'TransferFromTakerToMakerFailed');
});

it('skips expired permit if allowance is enough', async function () {
Expand Down Expand Up @@ -545,8 +546,9 @@ describe('LimitOrderProtocol', function () {
takerPermit: order.takerAsset + trim0x(permit),
});
await weth.approve(swap.address, 0);
await expect(swap.fillOrderArgs(order, r, vs, 1, takerTraits.traits, takerTraits.args))
.to.be.revertedWith('ERC20Permit: expired deadline');

const tx = await swap.populateTransaction.fillOrderArgs(order, r, vs, 1, takerTraits.traits, takerTraits.args);
await expect(addr.sendTransaction(tx)).to.be.revertedWithCustomError(swap, 'TransferFromTakerToMakerFailed');
});
});

Expand Down
15 changes: 8 additions & 7 deletions test/RfqOrders.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,10 @@ describe('RFQ Orders in LimitOrderProtocol', function () {
minReturn: 1,
takerPermit: order.takerAsset + trim0x(permit),
});
const requestFunc = () => swap.fillOrderArgs(order, r, vs, 1, takerTraits.traits, takerTraits.args);
await requestFunc();
await expect(requestFunc()).to.be.revertedWith('ERC20Permit: invalid signature');

const tx = await swap.populateTransaction.fillOrderArgs(order, r, vs, 1, takerTraits.traits, takerTraits.args);
await addr.sendTransaction(tx);
await expect(addr.sendTransaction(tx)).to.be.revertedWithCustomError(swap, 'BitInvalidatedOrder');
});

it('rejects other signature', async function () {
Expand All @@ -181,8 +182,8 @@ describe('RFQ Orders in LimitOrderProtocol', function () {
const { r, _vs: vs } = ethers.utils.splitSignature(signature);
const takerTraits = buildTakerTraits({ takerPermit: order.takerAsset + trim0x(permit), minReturn: 1 });
await weth.approve(swap.address, 0);
await expect(swap.fillOrderArgs(order, r, vs, 1, takerTraits.traits, takerTraits.args))
.to.be.revertedWith('ERC20Permit: invalid signature');
const tx = await swap.populateTransaction.fillOrderArgs(order, r, vs, 1, takerTraits.traits, takerTraits.args);
await expect(addr.sendTransaction(tx)).to.be.revertedWithCustomError(swap, 'TransferFromTakerToMakerFailed');
});

it('rejects expired permit', async function () {
Expand All @@ -205,8 +206,8 @@ describe('RFQ Orders in LimitOrderProtocol', function () {
takerPermit: order.takerAsset + trim0x(permit),
});
await weth.approve(swap.address, 0);
await expect(swap.fillOrderArgs(order, r, vs, 1, takerTraits.traits, takerTraits.args))
.to.be.revertedWith('ERC20Permit: expired deadline');
const tx = await swap.populateTransaction.fillOrderArgs(order, r, vs, 1, takerTraits.traits, takerTraits.args);
await expect(addr.sendTransaction(tx)).to.be.revertedWithCustomError(swap, 'TransferFromTakerToMakerFailed');
});
});
});
Expand Down

0 comments on commit e215888

Please sign in to comment.