Skip to content

Commit

Permalink
Tests on pointers for sending to unassociated addrs (sei-protocol#1639)
Browse files Browse the repository at this point in the history
* unassociated addrs tests

* fix

* fix
  • Loading branch information
jewei1997 authored May 8, 2024
1 parent aaec77e commit 9d9d7a6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
12 changes: 12 additions & 0 deletions contracts/test/CW20toERC20PointerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
13 changes: 12 additions & 1 deletion contracts/test/ERC20toCW20PointerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down

0 comments on commit 9d9d7a6

Please sign in to comment.