You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I meet a problem, when i test testLockAndMint function, it shows me error, it can't mint nft for the user, i don't know why, the switchChainAndRouteMessage show me the message maybe sent to the destchain. This is my function at below:
//SPDX-License-Identifier:MITpragmasolidity0.8.24;import{Test}from"forge-std/Test.sol";import{MoodNft}from"src/MoodNft.sol";import{MNftPoolLockAndRelease}from"src/MNftPoolLockAndRelease.sol";import{DeployMNftPool}from"script/deploy/DeployMNftPool.s.sol";import{WMoodNft}from"src/WMoodNft.sol";import{WMNftPoolMintAndBurn}from"src/WMNftPoolMintAndBurn.sol";import{DeployWrappedMNftPool}from"script/deploy/DeployWrappedMNftPool.s.sol";import{CCIPLocalSimulatorFork,Register}from"@chainlink/local/src/ccip/CCIPLocalSimulatorFork.sol";import{IRouterClient}from"@chainlink/local/lib/ccip/contracts/src/v0.8/ccip/interfaces/IRouterClient.sol";import{IERC20}from"@openzeppelin/contracts/token/ERC20/IERC20.sol";/** * @title AllPoolForkTest * @notice 1. use ETH_SEPOLIA as source fork, deploy moodNft, mNftPool * 2. use ARB_SEPOLIA as destination fork, deploy wMoodNft, wMNftPool */contractAllPoolForkTestisTest{MoodNftpublicmoodNft;WMoodNftpublicwMoodNft;MNftPoolLockAndReleasepublicmNftPool;WMNftPoolMintAndBurnpublicwMNftPool;DeployMNftPoolpublicdeployMNftPool;DeployWrappedMNftPoolpublicdeployWrappedMNftPool;CCIPLocalSimulatorForkpublicccipLocalSimulatorFork;IRouterClientpublicsourceRouter;IRouterClientpublicdestinationRouter;IERC20publicsourceLinkToken;IERC20publicdestinationLinkToken;uint256publicsourceFork;uint256publicdestinationFork;uint64publicsourceChainSelector;uint64publicdestinationChainSelector;addresspublicUSER;functionsetUp()public{USER=makeAddr("USER");stringmemoryETH_SEPOLIA_RPC_URL=vm.envString("ETH_SEPOLIA_RPC_URL");stringmemoryARB_SEPOLIA_RPC_URL=vm.envString("ARB_SEPOLIA_RPC_URL");sourceFork=vm.createFork(ETH_SEPOLIA_RPC_URL);// destinationFork = vm.createSelectFork(ARB_SEPOLIA_RPC_URL);destinationFork=vm.createFork(ARB_SEPOLIA_RPC_URL);ccipLocalSimulatorFork=newCCIPLocalSimulatorFork();vm.makePersistent(address(ccipLocalSimulatorFork));vm.selectFork(destinationFork);// deploy wMoodNft, wMNftPool on destination chain.Register.NetworkDetailsmemorydestinationNetWorkDetails=ccipLocalSimulatorFork.getNetworkDetails(block.chainid);destinationChainSelector=destinationNetWorkDetails.chainSelector;destinationRouter=IRouterClient(destinationNetWorkDetails.routerAddress);destinationLinkToken=IERC20(destinationNetWorkDetails.linkAddress);deployWrappedMNftPool=newDeployWrappedMNftPool();(wMNftPool,wMoodNft)=deployWrappedMNftPool.run();ccipLocalSimulatorFork.requestLinkFromFaucet(USER,20ether);vm.deal(USER,20ether);// deploy moodNft, mNftPool on source chain.vm.selectFork(sourceFork);Register.NetworkDetailsmemorysourceNetWorkDetails=ccipLocalSimulatorFork.getNetworkDetails(block.chainid);sourceChainSelector=sourceNetWorkDetails.chainSelector;sourceRouter=IRouterClient(sourceNetWorkDetails.routerAddress);sourceLinkToken=IERC20(sourceNetWorkDetails.linkAddress);deployMNftPool=newDeployMNftPool();(mNftPool,moodNft)=deployMNftPool.run();ccipLocalSimulatorFork.requestLinkFromFaucet(USER,20ether);vm.deal(USER,20ether);}modifieronSourceChainAllowDestAndSourceChain(){vm.selectFork(sourceFork);vm.startPrank(mNftPool.owner());mNftPool.allowlistDestinationChain(destinationChainSelector,true);mNftPool.allowlistSourceChain(destinationChainSelector,true);_;}modifieronDestChainAllowDestAndSourceChain(){vm.selectFork(destinationFork);vm.startPrank(wMNftPool.owner());wMNftPool.allowlistDestinationChain(sourceChainSelector,true);wMNftPool.allowlistSourceChain(sourceChainSelector,true);wMNftPool.allowlistSender(USER,true);_;}modifiermoodNftPrepareForUser(){vm.selectFork(sourceFork);vm.startPrank(USER);moodNft.mintNft();moodNft.approve(address(mNftPool),0);sourceLinkToken.transfer(address(mNftPool),5ether);payable(address(mNftPool)).transfer(5ether);_;}modifierwMoodNftPrepareForUser(){vm.selectFork(destinationFork);vm.startPrank(USER);wMoodNft.mintNft();wMoodNft.approve(address(wMNftPool),0);destinationLinkToken.transfer(address(wMNftPool),5ether);payable(address(wMNftPool)).transfer(5ether);_;}// 1. on source chain test lock ann send message// 2. on destination chain test mint and receive massage// @notice can receive message but can not execute it.functiontestLockAndMint()publiconSourceChainAllowDestAndSourceChainonDestChainAllowDestAndSourceChainmoodNftPrepareForUser{vm.selectFork(sourceFork);vm.startPrank(USER);mNftPool.lockAndSendNft(0,USER,destinationChainSelector,USER,address(sourceLinkToken));assert(moodNft.balanceOf(USER)==0);assert(moodNft.ownerOf(0)==address(mNftPool));ccipLocalSimulatorFork.switchChainAndRouteMessage(destinationFork);// vm.startPrank(USER);// sourceLinkToken.transfer(address(wMNftPool), 5 ether);// payable(address(wMNftPool)).transfer(5 ether);vm.selectFork(destinationFork);assert(vm.activeFork()==destinationFork);assert(wMoodNft.balanceOf(USER)==1);// assert(wMoodNft.ownerOf(0) == USER);}// Why the source chain selector is 0?// function testBurnAndRelease()// public// onDestChainAllowDestAndSourceChain// onSourceChainAllowDestAndSourceChain// wMoodNftPrepareForUser// {// vm.selectFork(destinationFork);// vm.startPrank(USER);// wMNftPool.burnAndSendNft(0, USER, sourceChainSelector, USER, destinationLinkToken);// assert(wMoodNft.balanceOf(USER) == 0);// vm.expectRevert();// wMoodNft.ownerOf(0);// vm.stopPrank();// }}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello, I meet a problem, when i test
testLockAndMint
function, it shows me error, it can't mint nft for the user, i don't know why, theswitchChainAndRouteMessage
show me the message maybe sent to the destchain. This is my function at below:This is the stack traces:
Beta Was this translation helpful? Give feedback.
All reactions