Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zajck committed Jul 5, 2023
1 parent abf854f commit bd1757d
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 25 deletions.
4 changes: 2 additions & 2 deletions test/protocol/BuyerHandlerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,9 @@ describe("BuyerHandler", function () {
.connect(other1)
.commitToOffer(await other1.getAddress(), offerId, { value: offer.price });

const beaconProxyAddress = await calculateBosonProxyAddress(accountHandler.address);
const beaconProxyAddress = await calculateBosonProxyAddress(await accountHandler.getAddress());
const bosonVoucherCloneAddress = calculateCloneAddress(
accountHandler.address,
await accountHandler.getAddress(),
beaconProxyAddress,
admin.address,
""
Expand Down
4 changes: 2 additions & 2 deletions test/protocol/ConfigHandlerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ describe("IBosonConfigHandler", function () {
describe("Deploy tests", async function () {
context("📋 Initializer", async function () {
it("should initialize the config handler and emit set events", async function () {
const proxyAddress = await calculateBosonProxyAddress(protocolDiamond.address);
const proxyAddress = await calculateBosonProxyAddress(await protocolDiamond.getAddress());

const protocolConfig = [
// Protocol addresses
Expand Down Expand Up @@ -1290,7 +1290,7 @@ describe("IBosonConfigHandler", function () {
"Invalid voucher beacon address"
);

const proxyAddress = await calculateBosonProxyAddress(protocolDiamond.address);
const proxyAddress = await calculateBosonProxyAddress(await protocolDiamond.getAddress());
expect(await configHandler.connect(rando).getBeaconProxyAddress()).to.equal(
proxyAddress,
"Invalid voucher proxy address"
Expand Down
2 changes: 1 addition & 1 deletion test/protocol/ExchangeHandlerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ describe("IBosonExchangeHandler", function () {
[foreign20, foreign721, foreign1155] = await deployMockTokens(["Foreign20", "Foreign721", "Foreign1155"]);

// Get the beacon proxy address
beaconProxyAddress = await calculateBosonProxyAddress(configHandler.address);
beaconProxyAddress = await calculateBosonProxyAddress(await configHandler.getAddress());

// Get snapshot id
snapshotId = await getSnapshot();
Expand Down
2 changes: 1 addition & 1 deletion test/protocol/FundsHandlerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ describe("IBosonFundsHandler", function () {
[mockToken] = await deployMockTokens(["Foreign20"]);

// Get the beacon proxy address
beaconProxyAddress = await calculateBosonProxyAddress(configHandler.address);
beaconProxyAddress = await calculateBosonProxyAddress(await configHandler.getAddress());

// Get snapshot id
snapshotId = await getSnapshot();
Expand Down
2 changes: 1 addition & 1 deletion test/protocol/OfferHandlerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe("IBosonOfferHandler", function () {
[deployer] = await getSigners();

// Get the beacon proxy address
beaconProxyAddress = await calculateBosonProxyAddress(configHandler.address);
beaconProxyAddress = await calculateBosonProxyAddress(await configHandler.getAddress());

// Get snapshot id
snapshotId = await getSnapshot();
Expand Down
2 changes: 1 addition & 1 deletion test/protocol/OrchestrationHandlerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ describe("IBosonOrchestrationHandler", function () {
[deployer] = await getSigners();

// Get the beacon proxy address
beaconProxyAddress = await calculateBosonProxyAddress(configHandler.address);
beaconProxyAddress = await calculateBosonProxyAddress(await configHandler.getAddress());

// Get snapshot id
snapshotId = await getSnapshot();
Expand Down
16 changes: 6 additions & 10 deletions test/protocol/SellerHandlerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe("SellerHandler", function () {
await mockAuthERC721Contract.connect(authTokenOwner).mint(8400, 1);

// Get the beacon proxy address
beaconProxyAddress = await calculateBosonProxyAddress(configHandler.address);
beaconProxyAddress = await calculateBosonProxyAddress(await configHandler.getAddress());

// Get snapshot id
snapshotId = await getSnapshot();
Expand Down Expand Up @@ -492,7 +492,6 @@ describe("SellerHandler", function () {
const newAuthTokenOwner = rando;
seller.id = accountId.next().value;
seller.assistant = newAuthTokenOwner.address;
seller.clerk = newAuthTokenOwner.address;

//Create struct again with new addresses
sellerStruct = seller.toStruct();
Expand Down Expand Up @@ -1902,14 +1901,13 @@ describe("SellerHandler", function () {
seller2.treasury = other2.address;
seller2.assistant = other1.address;
seller2.admin = other1.address;
seller2.clerk = other1.address;

// Create seller 2
await accountHandler.connect(other1).createSeller(seller2, emptyAuthToken, voucherInitValues);

// Update seller 2 treasury
seller2.treasury = await treasury.getAddress();
await accountHandler.connect(admin).updateSeller(seller2, emptyAuthToken);
await accountHandler.connect(other1).updateSeller(seller2, emptyAuthToken);

// Check seller 2 treasury
[, sellerStruct, authTokenStruct] = await accountHandler.connect(rando).getSeller(seller2.id);
Expand Down Expand Up @@ -2841,7 +2839,7 @@ describe("SellerHandler", function () {

externalId = "newSellerBrand";
expectedCollectionAddress = calculateCloneAddress(
accountHandler.address,
await accountHandler.getAddress(),
beaconProxyAddress,
admin.address, // original admin address
externalId
Expand All @@ -2855,19 +2853,17 @@ describe("SellerHandler", function () {
.withArgs(seller.id, 1, expectedCollectionAddress, externalId, other1.address);

// Voucher clone contract
bosonVoucher = await ethers.getContractAt("IBosonVoucher", expectedCollectionAddress);
bosonVoucher = await getContractAt("IBosonVoucher", expectedCollectionAddress);

await expect(tx).to.emit(bosonVoucher, "ContractURIChanged").withArgs(contractURI);
await expect(tx).to.emit(bosonVoucher, "RoyaltyPercentageChanged").withArgs(royaltyPercentage);
await expect(tx)
.to.emit(bosonVoucher, "VoucherInitialized")
.withArgs(seller.id, royaltyPercentage, contractURI);

bosonVoucher = await ethers.getContractAt("OwnableUpgradeable", expectedCollectionAddress);
bosonVoucher = await getContractAt("OwnableUpgradeable", expectedCollectionAddress);

await expect(tx)
.to.emit(bosonVoucher, "OwnershipTransferred")
.withArgs(ethers.constants.AddressZero, other1.address);
await expect(tx).to.emit(bosonVoucher, "OwnershipTransferred").withArgs(ZeroAddress, other1.address);
});

context("💔 Revert Reasons", async function () {
Expand Down
11 changes: 4 additions & 7 deletions test/protocol/clients/BosonVoucherTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,9 @@ describe("IBosonVoucher", function () {
rando2,
assistant,
admin,
clerk,
treasury,
assistantDR,
adminDR,
clerkDR,
treasuryDR,
seller,
foreign20;
Expand Down Expand Up @@ -92,7 +90,6 @@ describe("IBosonVoucher", function () {
// make all account the same
assistant = admin;
assistantDR = adminDR;
clerk = clerkDR = { address: ZeroAddress };
[deployer] = await getSigners();

// Grant protocol role to eoa so it's easier to test
Expand All @@ -110,7 +107,7 @@ describe("IBosonVoucher", function () {
[foreign20] = await deployMockTokens(["Foreign20", "BosonToken"]);

// Get the beacon proxy address
beaconProxyAddress = await calculateBosonProxyAddress(configHandler.address);
beaconProxyAddress = await calculateBosonProxyAddress(await configHandler.getAddress());

// Get snapshot id
snapshotId = await getSnapshot();
Expand Down Expand Up @@ -171,7 +168,7 @@ describe("IBosonVoucher", function () {

before(async function () {
const bosonVoucherCloneAddress = calculateCloneAddress(
await accountHandler.address,
await accountHandler.getAddress(),
beaconProxyAddress,
admin.address,
""
Expand All @@ -181,7 +178,7 @@ describe("IBosonVoucher", function () {
seller = mockSeller(
await assistant.getAddress(),
await admin.getAddress(),
clerk.address,
ZeroAddress,
await treasury.getAddress()
);

Expand All @@ -194,7 +191,7 @@ describe("IBosonVoucher", function () {
disputeResolver = mockDisputeResolver(
await assistantDR.getAddress(),
await adminDR.getAddress(),
clerkDR.address,
ZeroAddress,
await treasuryDR.getAddress(),
true
);
Expand Down

0 comments on commit bd1757d

Please sign in to comment.