Skip to content

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 24, 2023
1 parent 176a36d commit 8cdf8fc
Showing 1 changed file with 34 additions and 7 deletions.
41 changes: 34 additions & 7 deletions test/topos-core/ToposMessaging.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,17 +594,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 @@ -615,8 +642,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 8cdf8fc

Please sign in to comment.