diff --git a/test/integration/seaport/utils.js b/test/integration/seaport/utils.js index 04d49f02c..7dccae7e8 100644 --- a/test/integration/seaport/utils.js +++ b/test/integration/seaport/utils.js @@ -2,7 +2,7 @@ const { BigNumber, constants, utils } = require("ethers"); const getOfferOrConsiderationItem = function ( itemType = 0, - token = constants.AddressZero, + token = ZeroAddress, identifierOrCriteria = 0, startAmount = 1, endAmount = 1, diff --git a/test/protocol/ExchangeHandlerTest.js b/test/protocol/ExchangeHandlerTest.js index 488d59df8..939d56d2a 100644 --- a/test/protocol/ExchangeHandlerTest.js +++ b/test/protocol/ExchangeHandlerTest.js @@ -642,8 +642,9 @@ describe("IBosonExchangeHandler", function () { }); it("Should not decrement seller funds if offer price and sellerDeposit is 0", async function () { + let availableFundsAddresses = [ZeroAddress]; // Seller funds before - const sellersFundsBefore = FundsList.fromStruct(await fundsHandler.getAvailableFunds(seller.id)); + const sellersFundsBefore = FundsList.fromStruct(await fundsHandler.getAvailableFunds(seller.id, availableFundsAddresses)); // Set protocolFee to zero so we don't get the error AGENT_FEE_AMOUNT_TOO_HIGH let protocolFeePercentage = "0"; @@ -672,7 +673,7 @@ describe("IBosonExchangeHandler", function () { await exchangeHandler.connect(buyer).commitToOffer(await buyer.getAddress(), offerId); // Seller funds after - const sellerFundsAfter = FundsList.fromStruct(await fundsHandler.getAvailableFunds(seller.id)); + const sellerFundsAfter = FundsList.fromStruct(await fundsHandler.getAvailableFunds(seller.id, availableFundsAddresses)); expect(sellerFundsAfter.toString()).to.equal( sellersFundsBefore.toString(), "Seller funds should not be decremented" diff --git a/test/protocol/MetaTransactionsHandlerTest.js b/test/protocol/MetaTransactionsHandlerTest.js index 0289ef260..e24d5145c 100644 --- a/test/protocol/MetaTransactionsHandlerTest.js +++ b/test/protocol/MetaTransactionsHandlerTest.js @@ -3484,9 +3484,12 @@ describe("IBosonMetaTransactionsHandler", function () { }); context("Should emit MetaTransactionExecuted event and update state", async () => { + let availableFundsAddresses; beforeEach(async function () { + availableFundsAddresses = [await mockToken.getAddress(), ZeroAddress]; + // Read on chain state - buyerAvailableFunds = FundsList.fromStruct(await fundsHandler.getAvailableFunds(buyerId)); + buyerAvailableFunds = FundsList.fromStruct(await fundsHandler.getAvailableFunds(buyerId, availableFundsAddresses)); buyerBalanceBefore = await mockToken.balanceOf(await buyer.getAddress()); // Chain state should match the expected available funds before the withdrawal @@ -3533,12 +3536,13 @@ describe("IBosonMetaTransactionsHandler", function () { .withArgs(await buyer.getAddress(), await deployer.getAddress(), message.functionName, nonce); // Read on chain state - buyerAvailableFunds = FundsList.fromStruct(await fundsHandler.getAvailableFunds(buyerId)); + buyerAvailableFunds = FundsList.fromStruct(await fundsHandler.getAvailableFunds(buyerId, availableFundsAddresses)); buyerBalanceAfter = await mockToken.balanceOf(await buyer.getAddress()); // Chain state should match the expected available funds after the withdrawal // Since all tokens are withdrawn, token should be removed from the list expectedBuyerAvailableFunds = new FundsList([ + new Funds(await mockToken.getAddress(), "Foreign20", "0"), new Funds(ZeroAddress, "Native currency", (BigInt(buyerPayoff) / 2n).toString()), ]); expect(buyerAvailableFunds).to.eql( @@ -3597,12 +3601,16 @@ describe("IBosonMetaTransactionsHandler", function () { .withArgs(await buyer.getAddress(), await deployer.getAddress(), message.functionName, nonce); // Read on chain state - buyerAvailableFunds = FundsList.fromStruct(await fundsHandler.getAvailableFunds(buyerId)); + buyerAvailableFunds = FundsList.fromStruct(await fundsHandler.getAvailableFunds(buyerId, availableFundsAddresses)); buyerBalanceAfter = await mockToken.balanceOf(await buyer.getAddress()); // Chain state should match the expected available funds after the withdrawal - // Since all tokens are withdrawn, funds list should be empty. - expectedBuyerAvailableFunds = new FundsList([]); + // Since all tokens are withdrawn, values should be zero + const emptyFundsList = new FundsList([ + new Funds(await mockToken.getAddress(), "Foreign20", "0"), + new Funds(ZeroAddress, "Native currency", "0"), + ]); + expectedBuyerAvailableFunds = emptyFundsList; expect(buyerAvailableFunds).to.eql( expectedBuyerAvailableFunds, "Buyer available funds mismatch after withdrawal"