From 8cdf8fcece5c19b41ead4d9ebb44fa1927aa5a3b Mon Sep 17 00:00:00 2001 From: Simon Paitrault Date: Fri, 24 Nov 2023 14:37:37 +0100 Subject: [PATCH] test: update test with zero address Signed-off-by: Simon Paitrault --- test/topos-core/ToposMessaging.test.ts | 41 +++++++++++++++++++++----- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/test/topos-core/ToposMessaging.test.ts b/test/topos-core/ToposMessaging.test.ts index 46ee675..2f58064 100644 --- a/test/topos-core/ToposMessaging.test.ts +++ b/test/topos-core/ToposMessaging.test.ts @@ -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, @@ -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') })