【发布时间】:2018-04-26 12:35:10
【问题描述】:
我正在使用 truffle 开发虚拟测试合约,用于以下代码,
pragma solidity ^0.4.17;
import "truffle/Assert.sol";
import "truffle/DeployedAddresses.sol";
import "../contracts/SkillDevelopment.sol";
contract TestSkillDevelopment {
SkillDevelopment skillDevelopmentContract = SkillDevelopment(DeployedAddresses.SkillDevelopment());
function testSetStudentEnrollInfo() public {
skillDevelopmentContract.setStudentEnrollInfo("{\"Info\":[{\"id\":\"06bb05b8b3152b0323f4a9c07ae84f0c513b24946a8f8ec685af7cd763f7ffad\",\"studentId\":6532916,\"parenterId\":6187778,\"schemeId\":3853115,\"batchId\":3458926,\"instructorId\":1175723,\"trainingId\":2599715,\"studentSkillState\":1,\"state\":1}]}");
string expected = string("{\"Info\":[{\"id\":\"06bb05b8b3152b0323f4a9c07ae84f0c513b24946a8f8ec685af7cd763f7ffad\",\"studentId\":6532916,\"parenterId\":6187778,\"schemeId\":3853115,\"batchId\":3458926,\"instructorId\":1175723,\"trainingId\":2599715,\"studentSkillState\":1,\"state\":1}]}");
Assert.equal(skillDevelopmentContract.getStudentEnrollInfo(), expected, "The message should be set");
}
}
但出现错误
" TypeError: 不允许从 "literal_string 到 "string storage pointer" 的显式类型转换。"
在运行“松露测试”命令时。
请指教,这里怎么不正确。
【问题讨论】: