diff --git a/contracts/test/CW20toERC20PointerTest.js b/contracts/test/CW20toERC20PointerTest.js index 6ea2bed7e8..69d9d0f2d9 100644 --- a/contracts/test/CW20toERC20PointerTest.js +++ b/contracts/test/CW20toERC20PointerTest.js @@ -81,6 +81,18 @@ describe("CW20 to ERC20 Pointer", function () { expect(balanceAfter).to.equal((parseInt(balanceBefore) + 100).toString()) }); + it("transfer to unassociated address should fail", async function() { + const unassociatedSeiAddr = "sei1z7qugn2xy4ww0c9nsccftxw592n4xhxccmcf4q"; + const respBefore = await queryWasm(cw20Pointer, "balance", {address: accounts[1].seiAddress}) + const balanceBefore = respBefore.data.balance; + + await executeWasm(cw20Pointer, { transfer: { recipient: unassociatedSeiAddr, amount: "100" } }); + const respAfter = await queryWasm(cw20Pointer, "balance", {address: accounts[1].seiAddress}) + const balanceAfter = respAfter.data.balance; + + expect(balanceAfter).to.equal((parseInt(balanceBefore)).toString()) + }); + //TODO: other execute methods it("should increase and decrease allowance for a spender", async function() { diff --git a/contracts/test/ERC20toCW20PointerTest.js b/contracts/test/ERC20toCW20PointerTest.js index b750ce9985..dc339c08fd 100644 --- a/contracts/test/ERC20toCW20PointerTest.js +++ b/contracts/test/ERC20toCW20PointerTest.js @@ -97,9 +97,20 @@ describe("ERC20 to CW20 Pointer", function () { }); it("should fail transfer() if sender has insufficient balance", async function () { - let recipient = accounts[1]; + const recipient = accounts[1]; await expect(pointer.transfer(recipient.evmAddress, 20000000)).to.be.revertedWith("CosmWasm execute failed"); }); + + it("transfer to unassociated address should fail", async function() { + const unassociatedRecipient = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"; + await expect(pointer.transfer(unassociatedRecipient, 1)).to.be.revertedWithoutReason; + }); + + it("transfer to contract address should succeed", async function() { + const contract = await pointer.getAddress(); + const tx = await pointer.transfer(contract, 1); + await tx.wait(); + }); }); describe("approve()", function () {