Skip to content

Commit

Permalink
test: updates
Browse files Browse the repository at this point in the history
  • Loading branch information
PacificYield committed Nov 28, 2024
1 parent 5645294 commit 0cf310c
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions test/encryptedERC20/EncryptedERC20WithErrors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ describe("EncryptedERC20WithErrors", function () {
await reencryptBalance(this.signers, this.instances, "bob", this.encryptedERC20, this.encryptedERC20Address),
).to.equal(0); // check that transfer did not happen, as expected

// Check that the error code matches if balance is not sufficient
// Check that the error code matches if approval is not sufficient
expect(
await checkErrorCode(
this.signers,
Expand Down Expand Up @@ -240,7 +240,7 @@ describe("EncryptedERC20WithErrors", function () {
),
).to.equal(0);

// Check that the error code matches if allowance is not sufficient
// Check that the error code matches if there is no error
expect(
await checkErrorCode(
this.signers,
Expand Down Expand Up @@ -332,6 +332,26 @@ describe("EncryptedERC20WithErrors", function () {
}
});

it("spender cannot be null address", async function () {
const NULL_ADDRESS = "0x0000000000000000000000000000000000000000";
const mintAmount = 100_000;
const transferAmount = 50_000;
const tx = await this.encryptedERC20.connect(this.signers.alice).mint(mintAmount);
await tx.wait();

const input = this.instances.alice.createEncryptedInput(this.encryptedERC20Address, this.signers.alice.address);
input.add64(transferAmount);
const encryptedTransferAmount = await input.encrypt();

await expect(
this.encryptedERC20
.connect(this.signers.alice)
[
"approve(address,bytes32,bytes)"
](NULL_ADDRESS, encryptedTransferAmount.handles[0], encryptedTransferAmount.inputProof),
).to.be.revertedWithCustomError(this.encryptedERC20, "ERC20InvalidSpender");
});

it("receiver cannot be null address", async function () {
const NULL_ADDRESS = "0x0000000000000000000000000000000000000000";
const mintAmount = 100_000;
Expand Down

0 comments on commit 0cf310c

Please sign in to comment.