diff --git a/test/TestSwaplace.test.ts b/test/TestSwaplace.test.ts index 92c1c5b..8390473 100644 --- a/test/TestSwaplace.test.ts +++ b/test/TestSwaplace.test.ts @@ -15,6 +15,7 @@ describe("Swaplace", async function () { let deployer: SignerWithAddress; let owner: SignerWithAddress; let acceptee: SignerWithAddress; + let receiver: SignerWithAddress; // Solidity address(0) const zeroAddress = ethers.constants.AddressZero; @@ -45,7 +46,7 @@ describe("Swaplace", async function () { } before(async () => { - [deployer, owner, acceptee] = await ethers.getSigners(); + [deployer, owner, acceptee, receiver] = await ethers.getSigners(); Swaplace = await deploy("Swaplace", deployer); MockERC20 = await deploy("MockERC20", deployer); MockERC721 = await deploy("MockERC721", deployer); @@ -273,10 +274,10 @@ describe("Swaplace", async function () { it("Should be able to {acceptSwap} as 1-1 Swap", async function () { await Swaplace.connect(owner).createSwap(swap); await expect( - await Swaplace.connect(acceptee).acceptSwap(await Swaplace.totalSwaps()) + await Swaplace.connect(acceptee).acceptSwap(await Swaplace.totalSwaps(), receiver.address) ) .to.emit(Swaplace, "SwapAccepted") - .withArgs(await Swaplace.totalSwaps(), acceptee.address); + .withArgs(await Swaplace.totalSwaps(), receiver.address); }); it("Should be able to {acceptSwap} as N-N Swap", async function () { @@ -303,10 +304,10 @@ describe("Swaplace", async function () { .withArgs(await Swaplace.totalSwaps(), owner.address, swap.expiry); await expect( - await Swaplace.connect(acceptee).acceptSwap(await Swaplace.totalSwaps()) + await Swaplace.connect(acceptee).acceptSwap(await Swaplace.totalSwaps(), receiver.address) ) .to.emit(Swaplace, "SwapAccepted") - .withArgs(await Swaplace.totalSwaps(), acceptee.address); + .withArgs(await Swaplace.totalSwaps(), receiver.address); }); it("Should be able to {acceptSwap} as P2P Swap", async function () { @@ -324,10 +325,10 @@ describe("Swaplace", async function () { .withArgs(await Swaplace.totalSwaps(), owner.address, swap.expiry); await expect( - await Swaplace.connect(acceptee).acceptSwap(await Swaplace.totalSwaps()) + await Swaplace.connect(acceptee).acceptSwap(await Swaplace.totalSwaps(), receiver.address) ) .to.emit(Swaplace, "SwapAccepted") - .withArgs(await Swaplace.totalSwaps(), acceptee.address); + .withArgs(await Swaplace.totalSwaps(), receiver.address); }); }); @@ -336,13 +337,13 @@ describe("Swaplace", async function () { await Swaplace.connect(owner).createSwap(swap); await expect( - await Swaplace.connect(acceptee).acceptSwap(await Swaplace.totalSwaps()) + await Swaplace.connect(acceptee).acceptSwap(await Swaplace.totalSwaps(), receiver.address) ) .to.emit(Swaplace, "SwapAccepted") - .withArgs(await Swaplace.totalSwaps(), acceptee.address); + .withArgs(await Swaplace.totalSwaps(), receiver.address); await expect( - Swaplace.connect(acceptee).acceptSwap(await Swaplace.totalSwaps()) + Swaplace.connect(acceptee).acceptSwap(await Swaplace.totalSwaps(), receiver.address) ) .to.be.revertedWithCustomError(Swaplace, `InvalidExpiry`) .withArgs(0); @@ -354,7 +355,7 @@ describe("Swaplace", async function () { await network.provider.send("evm_increaseTime", [swap.expiry * 2]); await expect( - Swaplace.connect(owner).acceptSwap(await Swaplace.totalSwaps()) + Swaplace.connect(owner).acceptSwap(await Swaplace.totalSwaps(), receiver.address) ) .to.be.revertedWithCustomError(Swaplace, `InvalidExpiry`) .withArgs(swap.expiry); @@ -366,7 +367,7 @@ describe("Swaplace", async function () { await Swaplace.connect(owner).createSwap(swap); await expect( - Swaplace.connect(acceptee).acceptSwap(await Swaplace.totalSwaps()) + Swaplace.connect(acceptee).acceptSwap(await Swaplace.totalSwaps(), receiver.address) ).to.be.revertedWith(`ERC721: caller is not token owner or approved`); }); @@ -385,7 +386,7 @@ describe("Swaplace", async function () { .withArgs(await Swaplace.totalSwaps(), owner.address, swap.expiry); await expect( - Swaplace.connect(acceptee).acceptSwap(await Swaplace.totalSwaps()) + Swaplace.connect(acceptee).acceptSwap(await Swaplace.totalSwaps(), receiver.address) ) .to.be.revertedWithCustomError(Swaplace, "InvalidAddress") .withArgs(acceptee.address); @@ -410,7 +411,7 @@ describe("Swaplace", async function () { it("Should not be able to {acceptSwap} a canceled a Swap", async function () { const lastSwap = await Swaplace.totalSwaps(); - await expect(Swaplace.connect(owner).acceptSwap(lastSwap)) + await expect(Swaplace.connect(owner).acceptSwap(lastSwap, receiver.address)) .to.be.revertedWithCustomError(Swaplace, `InvalidExpiry`) .withArgs(0); });