首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当我运行松露测试调用时出错,我跟踪了官方松露商店文档的文档。

当我运行松露测试调用时出错,我跟踪了官方松露商店文档的文档。
EN

Ethereum用户
提问于 2019-03-10 07:18:00
回答 1查看 173关注 0票数 -2
代码语言:javascript
复制
chittiError: CompileError: Error parsing /Users/rahul/pet-shop-tutorial/test/TestAdoption.sol: ParsedContract.sol:10:1: ParserError: Expected pragma, import directive or contract/interface/library definition.
function testUserCanAdoptPet() public {
^------^
Compilation failed. See above.
    at async.whilst.error (/usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:369:1)
    at /usr/local/lib/node_modules/truffle/build/webpack:/~/async/dist/async.js:969:1
    at next (/usr/local/lib/node_modules/truffle/build/webpack:/~/async/dist/async.js:5222:1)
    at Promise.all.then.results (/usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-compile/profiler.js:351:1)
Truffle v5.0.7 (core: 5.0.7)
Node v10.15.3
EN

回答 1

Ethereum用户

发布于 2019-03-10 18:24:09

我看到了混乱。本教程要求您将该方法添加到本教程中先前创建的契约中。因此,在这个步骤中,您的所有文件都应该如下所示:

代码语言:javascript
复制
pragma solidity ^0.5.0;

import "truffle/Assert.sol";
import "truffle/DeployedAddresses.sol";
import "../contracts/Adoption.sol";

contract TestAdoption {
 // The address of the adoption contract to be tested
 Adoption adoption = Adoption(DeployedAddresses.Adoption());

 // The id of the pet that will be used for testing
 uint expectedPetId = 8;

 //The expected owner of adopted pet is this contract
 address expectedAdopter = address(this);

 // Testing the adopt() function
 function testUserCanAdoptPet() public {
   uint returnedId = adoption.adopt(expectedPetId);

   Assert.equal(returnedId, expectedPetId, "Adoption of the expected pet should match what is returned.");
 }
}
票数 1
EN
页面原文内容由Ethereum提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://ethereum.stackexchange.com/questions/68156

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档