5 ERC20父类 Context里面的_msgSender()与msg.sender,我在非GSN合约里使用msg.sender测试全部通过,全部替换成_msgSender()有部分测试报错

ERC20父类 Context里面的_msgSender()与msg.sender,我在非GSN合约里使用msg.sender测试全部通过,全部替换成_msgSender()有部分测试报错

报错内容相似: AssertionError: Expected transaction to be reverted with Crowdfund: failed now, please wait restart!, but other exception was thrown: Error: Transaction reverted without a reason and without a valid sourcemap provided by the compiler. Some line numbers may be off. We strongly recommend upgrading solc and always using revert reasons.

我定位到了错误代码 //涉及到的存储变量 mapping(address => uint256) public userIndex; //以下代码测试通过 require(userIndex[msg.sender] == 0,'Crowdfund: cannot invest when user already existed'); //msg.sender替换为_msgSender()后,以下代码测试报错 require(userIndex[_msgSender()] == 0,'Crowdfund: cannot invest when user already existed');

请先 登录 后评论

4 个回答

Tiny熊
  擅长:智能合约,以太坊
请先 登录 后评论
Ethereal - Solidity智能合约开发工程师
请先 登录 后评论
Tiny熊
  擅长:智能合约,以太坊
请先 登录 后评论
gnoying
请先 登录 后评论
  • 3 关注
  • 0 收藏,3605 浏览
  • Ethereal 提出于 2021-06-16 11:41