truffle test 出错 Expected identifier but got 'ILLEGAL'

执行测试时报错:

λ npx truffle test
Using network 'development'.

Compiling your contracts...
===========================
> Compiling .\contracts\Migrations.sol
> Compiling .\contracts\savePets.sol
> Compiling .\test\testPetSaveUser.sol
> Compiling truffle\Assert.sol
> Compiling truffle\AssertAddress.sol
> Compiling truffle\AssertAddressArray.sol
> Compiling truffle\AssertBalance.sol
> Compiling truffle\AssertBool.sol
> Compiling truffle\AssertBytes32.sol
> Compiling truffle\AssertBytes32Array.sol
> Compiling truffle\AssertGeneral.sol
> Compiling truffle\AssertInt.sol
> Compiling truffle\AssertIntArray.sol
> Compiling truffle\AssertString.sol
> Compiling truffle\AssertUint.sol
> Compiling truffle\AssertUintArray.sol
> Compiling truffle\DeployedAddresses.sol

CompileError: truffle/DeployedAddresses.sol:5:12: ParserError: Expected identifier but got 'ILLEGAL'
  function 08ebae3222c3a4860ae9251bef8f2022() public pure returns (address payable) { revert(); }

测试的代码

pragma solidity >=0.4.0 <=0.9.0;

// 1. 需要 导入 相应的文件
import "truffle/Assert.sol";   // 引入的断言    Truffle 框架提供
import "truffle/DeployedAddresses.sol";  // 用来获取被测试合约的地址    Truffle 框架提供
import "../contracts/savePets.sol";      // 被测试合约

contract testPetSaveUser { // 用于 测试 领养操作
  Adoption adoption = Adoption(DeployedAddresses.Adoption());
    // Adoption adoption = Adoption(DeployedAddresses.Adoption());   // 合约的实例化

    // 领养测试
    function testUserSavePet() public {
        uint returnedId = adoption.adopt(8);

        uint expected = 8;  // 期待用户ID

        // 判断是否是期待的用户
        // equal 判断是否相等
        Assert.equal(returnedId, expected, "应记录收养宠物 ID 8");
    }

    // 领养所有者测试

    // 所有领养者测试

}
请先 登录 后评论

1 个回答

Tiny熊
  擅长:智能合约,以太坊
请先 登录 后评论
  • 1 关注
  • 0 收藏,2539 浏览
  • 提出于 2022-06-08 13:16