diff --git a/test/TestSwaplace.test.ts b/test/TestSwaplace.test.ts index dc4cb94..2c8e965 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); @@ -275,10 +276,11 @@ describe("Swaplace", async function () { await expect( 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 () { @@ -307,10 +309,11 @@ describe("Swaplace", async function () { await expect( 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 () { @@ -330,10 +333,11 @@ describe("Swaplace", async function () { await expect( 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); }); }); @@ -344,13 +348,17 @@ describe("Swaplace", async function () { await expect( 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); @@ -362,7 +370,10 @@ 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); @@ -374,7 +385,10 @@ 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`); }); @@ -393,7 +407,10 @@ 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); @@ -418,7 +435,9 @@ 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); });