Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
test: update test with zero address
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Paitrault <[email protected]>
  • Loading branch information
Freyskeyd committed Nov 27, 2023
1 parent 61bd207 commit 6419302
Showing 1 changed file with 36 additions and 8 deletions.
44 changes: 36 additions & 8 deletions test/topos-core/ToposMessaging.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,12 +497,13 @@ describe('ToposMessaging', () => {
const { admin, receiver, ERC20, toposCore, erc20Messaging } =
await loadFixture(deployERC20MessagingFixture)
await toposCore.setNetworkSubnetId(cc.SOURCE_SUBNET_ID_2)
const smallDailyMintLimit = 1;
const token = testUtils.encodeTokenParam(
tc.TOKEN_NAME,
tc.TOKEN_SYMBOL_X,
tc.MINT_CAP_100_000_000,
ethers.constants.AddressZero,
1,
smallDailyMintLimit,
tc.INITIAL_SUPPLY_10_000_000
)
const tx = await erc20Messaging.deployToken(token)
Expand Down Expand Up @@ -544,17 +545,44 @@ describe('ToposMessaging', () => {
})

it('reverts if trying to mint for zero address', async () => {
const { defaultToken, toposCore, erc20Messaging } = await loadFixture(
deployERC20MessagingFixture
)
const { admin, ERC20, toposCore, erc20Messaging } =
await loadFixture(deployERC20MessagingFixture)
await toposCore.setNetworkSubnetId(cc.SOURCE_SUBNET_ID_2)
await erc20Messaging.deployToken(defaultToken)
const token = testUtils.encodeTokenParam(
tc.TOKEN_NAME,
tc.TOKEN_SYMBOL_X,
tc.MINT_CAP_100_000_000,
ethers.constants.AddressZero,
tc.DAILY_MINT_LIMIT_100,
tc.INITIAL_SUPPLY_10_000_000
)
const tx = await erc20Messaging.deployToken(token)
const txReceipt = await tx.wait()
const logs = txReceipt.events?.find((e) => e.event === 'TokenDeployed')
const tokenAddress = logs?.args?.tokenAddress
const erc20 = ERC20.attach(tokenAddress)
await erc20.approve(erc20Messaging.address, tc.SEND_AMOUNT_50)

const sendToken = await sendTokenTx(
erc20Messaging,
ethers.provider,
ethers.constants.AddressZero,
admin,
cc.SOURCE_SUBNET_ID_2,
tokenAddress
)

const { proofBlob, receiptsRoot } = await getReceiptMptProof(
sendToken,
ethers.provider
)

const certificate = testUtils.encodeCertParam(
cc.PREV_CERT_ID_0,
cc.SOURCE_SUBNET_ID_1,
cc.STATE_ROOT_MAX,
cc.TX_ROOT_MAX,
txc.ZERO_ADDRESS_TRANSACTION.receiptRoot,
receiptsRoot,
[cc.SOURCE_SUBNET_ID_2],
cc.VERIFIER,
cc.CERT_ID_1,
Expand All @@ -565,8 +593,8 @@ describe('ToposMessaging', () => {
await expect(
erc20Messaging.execute(
[tc.TOKEN_SENT_INDEX_2],
txc.ZERO_ADDRESS_TRANSACTION.proofBlob,
txc.ZERO_ADDRESS_TRANSACTION.receiptRoot
proofBlob,
receiptsRoot
)
).to.be.revertedWith('ERC20: mint to the zero address')
})
Expand Down

0 comments on commit 6419302

Please sign in to comment.