Skip to content

Commit

Permalink
add test to matchOrders onlyAuthorized onlyNotExpired
Browse files Browse the repository at this point in the history
  • Loading branch information
gfournieriExec committed May 29, 2024
1 parent c5e18f9 commit 783f99d
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/beacon/Voucher.test.ts
Original file line number Diff line number Diff line change
@@ -326,6 +326,30 @@ describe('Voucher', function () {
expect(await voucher.getSponsoredAmount(dealId)).to.be.equal(0);
});

it('Should match orders with an authorized account', async () => {
await addEligibleAssets([app, dataset, workerpool]);
await voucherAsOwner.authorizeAccount(anyone.address).then((tx) => tx.wait());
await expect(
voucherAsAnyone.matchOrders(appOrder, datasetOrder, workerpoolOrder, requestOrder),
)
.to.emit(voucher, 'OrdersMatchedWithVoucher')
.withArgs(dealId);
});

it('Should not match orders when sender is not allowed', async () => {
await expect(
voucherAsAnyone.matchOrders(appOrder, datasetOrder, workerpoolOrder, requestOrder),
).to.be.revertedWith('Voucher: sender is not authorized');
});

it('Should not match orders when voucher is expired', async () => {
const expirationDate = await voucher.getExpiration();
await time.setNextBlockTimestamp(expirationDate);
await expect(
voucherAsOwner.matchOrders(appOrder, datasetOrder, workerpoolOrder, requestOrder),
).to.be.revertedWith('Voucher: voucher is expired');
});

it('Should not match orders when non-sponsored amount is not transferable', async () => {
await expect(voucher.matchOrders(appOrder, datasetOrder, workerpoolOrder, requestOrder))
.to.be.revertedWithCustomError(iexecPocoInstance, 'ERC20InsufficientAllowance')

0 comments on commit 783f99d

Please sign in to comment.