AssertionError Address changing in hardhat tests

Viewed 224

I'm running into this AssertionError. I'm using a public key generated from the hardhat network. It's saved as a const const recipient = "0x8626f6940e2eb28930efb4cef49b2d1f2c9c1199";

As you can see in the error below the value of recipient is changing (capital letters vs lowercase letter). Any idea why and how this can happen?

should work with ERC2981 royalties:

  AssertionError: expected '0x8626f6940E2eb28930eFb4CeF49B2d1F2C9…' to equal '0x8626f6940e2eb28930efb4cef49b2d1f2c9…'
  + expected - actual

  -0x8626f6940E2eb28930eFb4CeF49B2d1F2C9C1199
  +0x8626f6940e2eb28930efb4cef49b2d1f2c9c1199

This is the actual test:

it("should work with ERC2981 royalties", async function () {
    const Token = await ethers.getContractFactory("Token");
    const token = await Token.deploy();
    await token.deployed();

    await token.setRoyalties(0, recipient, 1000);
    let getRoyalties = await token.getRaribleV2Royalties(0);
    assert.equal(getRoyalties[0].value, "1000");
    assert.equal(getRoyalties[0].account, recipient);
    let royalties = await token.royaltyInfo(0, 100000);

    assert.equal(royalties.royaltyAmount.toString(), "10000");
    assert.equal(royalties.receiver, recipient);
});
1 Answers

It's the address checksum. You can checksum an address using the ethers.utils.getAddress() function (docs).

Related