Skip to content

Commit

Permalink
Fixed the tests #172
Browse files Browse the repository at this point in the history
  • Loading branch information
blackbeard002 committed Jan 16, 2024
1 parent f96cf99 commit aa61f3e
Showing 1 changed file with 9 additions and 76 deletions.
85 changes: 9 additions & 76 deletions test/TestSwaplace.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,7 @@ describe("Swaplace", async function () {

await expect(await Swaplace.connect(owner).createSwap(swap))
.to.emit(Swaplace, "SwapCreated")
.withArgs(
await Swaplace.totalSwaps(),
owner.address,
zeroAddress,
currentTimestamp,
);
.withArgs(await Swaplace.totalSwaps());
});

it("Should be able to create a 1-N swap with ERC20", async function () {
Expand Down Expand Up @@ -110,12 +105,7 @@ describe("Swaplace", async function () {

await expect(await Swaplace.connect(owner).createSwap(swap))
.to.emit(Swaplace, "SwapCreated")
.withArgs(
await Swaplace.totalSwaps(),
owner.address,
zeroAddress,
currentTimestamp,
);
.withArgs(await Swaplace.totalSwaps());
});

it("Should be able to create a N-N swap with ERC20", async function () {
Expand Down Expand Up @@ -147,12 +137,7 @@ describe("Swaplace", async function () {

await expect(await Swaplace.connect(owner).createSwap(swap))
.to.emit(Swaplace, "SwapCreated")
.withArgs(
await Swaplace.totalSwaps(),
owner.address,
zeroAddress,
currentTimestamp,
);
.withArgs(await Swaplace.totalSwaps());
});

it("Should be able to create a 1-1 swap with ERC721", async function () {
Expand All @@ -176,12 +161,7 @@ describe("Swaplace", async function () {

await expect(await Swaplace.connect(owner).createSwap(swap))
.to.emit(Swaplace, "SwapCreated")
.withArgs(
await Swaplace.totalSwaps(),
owner.address,
zeroAddress,
currentTimestamp,
);
.withArgs(await Swaplace.totalSwaps());
});

it("Should be able to create a 1-N swap with ERC721", async function () {
Expand Down Expand Up @@ -209,12 +189,7 @@ describe("Swaplace", async function () {

await expect(await Swaplace.connect(owner).createSwap(swap))
.to.emit(Swaplace, "SwapCreated")
.withArgs(
await Swaplace.totalSwaps(),
owner.address,
zeroAddress,
currentTimestamp,
);
.withArgs(await Swaplace.totalSwaps());
});

it("Should be able to create a N-N swap with ERC721", async function () {
Expand Down Expand Up @@ -246,12 +221,7 @@ describe("Swaplace", async function () {

await expect(await Swaplace.connect(owner).createSwap(swap))
.to.emit(Swaplace, "SwapCreated")
.withArgs(
await Swaplace.totalSwaps(),
owner.address,
zeroAddress,
currentTimestamp,
);
.withArgs(await Swaplace.totalSwaps());
});
});

Expand All @@ -262,28 +232,6 @@ describe("Swaplace", async function () {
.to.be.revertedWithCustomError(Swaplace, `InvalidAddress`)
.withArgs(acceptee.address);
});

it("Should revert when {expiry} is smaller than {block.timestamp}", async function () {
const swap = await mockSwap();

let [allowed, expiry] = await Swaplace.parseData(swap.config);
expiry /= 2;
swap.config = await Swaplace.packData(allowed, expiry);

await expect(Swaplace.connect(owner).createSwap(swap))
.to.be.revertedWithCustomError(Swaplace, `InvalidExpiry`)
.withArgs(expiry);
});

it("Should revert when {biding} and {asking} lengths are equal 0", async function () {
const swap = await mockSwap();
swap.biding = [];
swap.asking = [];

await expect(
Swaplace.connect(owner).createSwap(swap),
).to.be.revertedWithCustomError(Swaplace, `InvalidAssetsLength`);
});
});
});

Expand Down Expand Up @@ -354,12 +302,7 @@ describe("Swaplace", async function () {

await expect(await Swaplace.connect(owner).createSwap(swap))
.to.emit(Swaplace, "SwapCreated")
.withArgs(
await Swaplace.totalSwaps(),
owner.address,
allowed,
expiry,
);
.withArgs(await Swaplace.totalSwaps());

await expect(
await Swaplace.connect(acceptee).acceptSwap(
Expand All @@ -386,12 +329,7 @@ describe("Swaplace", async function () {

await expect(await Swaplace.connect(owner).createSwap(swap))
.to.emit(Swaplace, "SwapCreated")
.withArgs(
await Swaplace.totalSwaps(),
owner.address,
allowed,
expiry,
);
.withArgs(await Swaplace.totalSwaps());

await expect(
await Swaplace.connect(acceptee).acceptSwap(
Expand Down Expand Up @@ -472,12 +410,7 @@ describe("Swaplace", async function () {

await expect(await Swaplace.connect(owner).createSwap(swap))
.to.emit(Swaplace, "SwapCreated")
.withArgs(
await Swaplace.totalSwaps(),
owner.address,
allowed,
expiry,
);
.withArgs(await Swaplace.totalSwaps());

await expect(
Swaplace.connect(acceptee).acceptSwap(
Expand Down

0 comments on commit aa61f3e

Please sign in to comment.