Skip to content

Commit

Permalink
Merge pull request #165 from bosonprotocol/unit-tests-revision
Browse files Browse the repository at this point in the history
Unit tests - 2_test_fullpath_with_permit
  • Loading branch information
zajck committed Oct 13, 2021
2 parents 5319bbb + 7869e6d commit 5d17584
Show file tree
Hide file tree
Showing 9 changed files with 4,768 additions and 2,604 deletions.
16 changes: 8 additions & 8 deletions contracts/BosonRouter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,13 @@ contract BosonRouter is
address tokenPriceAddress = IVoucherKernel(voucherKernel)
.getVoucherPriceToken(_tokenIdSupply);

IVoucherKernel(voucherKernel).fillOrder(
_tokenIdSupply,
_issuer,
msg.sender,
TKNETH
);

permitTransferFromAndAddEscrow(
tokenPriceAddress,
price,
Expand All @@ -708,14 +715,7 @@ contract BosonRouter is
_r,
_s
);

IVoucherKernel(voucherKernel).fillOrder(
_tokenIdSupply,
_issuer,
msg.sender,
TKNETH
);


//record funds in escrow ...
ICashier(cashierAddress).addEscrowAmount{value: msg.value}(msg.sender);
}
Expand Down
13 changes: 11 additions & 2 deletions test/11_gate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,13 @@ describe('Gate contract', async () => {
users.seller,
timestamp,
timestamp + constants.SECONDS_IN_DAY,
constants.product_price,
constants.seller_deposit,
constants.buyer_deposit,
constants.QTY_10,
gate,
conditionalOrderNftTokenID
conditionalOrderNftTokenID,
true
);

const txReceipt = await txOrder.wait();
Expand Down Expand Up @@ -475,7 +478,13 @@ describe('Gate contract', async () => {
expect(await contractGate.check(users.buyer.address, tokenId)).to.be
.true;

await utils.commitToBuy(users.buyer, users.seller, tokenId);
await utils.commitToBuy(
users.buyer,
users.seller,
tokenId,
constants.product_price,
constants.buyer_deposit
);

expect(await contractGate.check(users.buyer.address, tokenId)).to.be
.false;
Expand Down
26 changes: 23 additions & 3 deletions test/12_conditional_commit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1827,10 +1827,13 @@ describe('Create Voucher sets and commit to vouchers with token conditional comm
users.seller,
constants.PROMISE_VALID_FROM,
constants.PROMISE_VALID_TO,
constants.product_price,
constants.PROMISE_DEPOSITSE1,
constants.buyer_deposit,
constants.QTY_10,
contractGate,
0
0,
true
);

const txReceipt = await txOrder.wait();
Expand Down Expand Up @@ -1929,7 +1932,13 @@ describe('Create Voucher sets and commit to vouchers with token conditional comm
});

it('[NEGATIVE] Should not be able to request voucher twice', async () => {
await utils.commitToBuy(users.buyer, users.seller, tokenSupplyKey);
await utils.commitToBuy(
users.buyer,
users.seller,
tokenSupplyKey,
constants.product_price,
constants.buyer_deposit
);

const {txValue, DEPOSIT, PRICE} = await generateInputs(
users.buyer,
Expand Down Expand Up @@ -2000,7 +2009,9 @@ describe('Create Voucher sets and commit to vouchers with token conditional comm
users.seller,
timestamp,
timestamp + constants.SECONDS_IN_DAY,
constants.product_price,
constants.seller_deposit,
constants.buyer_deposit,
constants.QTY_10,
users.other1, /// gate address that maps to EOA
0
Expand Down Expand Up @@ -2045,7 +2056,9 @@ describe('Create Voucher sets and commit to vouchers with token conditional comm
users.seller,
timestamp,
timestamp + constants.SECONDS_IN_DAY,
constants.product_price,
constants.seller_deposit,
constants.buyer_deposit,
constants.QTY_10,
contractGate,
0
Expand Down Expand Up @@ -2154,10 +2167,13 @@ describe('Create Voucher sets and commit to vouchers with token conditional comm
users.seller,
constants.PROMISE_VALID_FROM,
constants.PROMISE_VALID_TO,
constants.product_price,
constants.PROMISE_DEPOSITSE1,
constants.buyer_deposit,
constants.QTY_10,
contractGate,
0
0,
true
);

const txReceipt = await txOrder.wait();
Expand Down Expand Up @@ -2314,7 +2330,9 @@ describe('Create Voucher sets and commit to vouchers with token conditional comm
users.seller,
timestamp,
timestamp + constants.SECONDS_IN_DAY,
constants.product_price,
constants.seller_deposit,
constants.buyer_deposit,
constants.QTY_10,
users.other1, /// gate address that maps to EOA
0
Expand Down Expand Up @@ -2349,7 +2367,9 @@ describe('Create Voucher sets and commit to vouchers with token conditional comm
users.seller,
timestamp,
timestamp + constants.SECONDS_IN_DAY,
constants.product_price,
constants.seller_deposit,
constants.buyer_deposit,
constants.QTY_10,
contractGate,
0
Expand Down
Loading

0 comments on commit 5d17584

Please sign in to comment.