关灯

TypeError: Member "adopt" not found or not visible after argument-depe

  [复制链接]
区块链技术 发表于 2019-1-2 20:00:16 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题
 

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x

TypeError: Member "adopt" not found or not visible after argument-dependent lookup in type(contract Adoption).
uint returnPetId=Adoption.adopt(expectedPetId);

Hello, I am trying to learn dapp. I started to write pet-shop tutorial with the help of truffle tutorial but i am getting error in test file. please help.

Following is contract

pragma solidity ^0.5.0;

contract Adoption {
    address[16] public adopters;
    // Adopting a pet
    function adopt(uint petId) public returns (uint) {
        require(petId >= 0 && petId <= 15);="" adopters[petid]="msg.sender;" return="" petid;="" }="" retrieving="" the="" adopters="" function="" getadopters()="" public="" view="" returns="" (address[16]="" memory)="" {="" adopters;="" <="" code="">

here is my test file

pragma solidity ^0.5.0

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

contract TestAdoption {
    Adoption adoption = Adoption(DeployedAddresses.Adoption());
    uint expectedPetId = 8;
    address expectedAdopter = address(this);

    function testUserCanAdoptPet() public {
        uint returnPetId = Adoption.adopt(expectedPetId);
        assert.equal(returnPetId, expectedPetId, "Error:Expectd PetId and Return PetId are not equal");
    }

    function testGetAdopterAddressByPetId() public {
        address adopter = adoption.adopters(expectedPetId);
        assert.equal(adopter, expectedAdopter, "Owner of the expected pet should be this contract");
    }

    function testGetAdopterAddressByPetIdInArray() public {
        // Store adopters in memory rather than contract's storage
        address[16] memory adopters = adoption.getAdopters();
        assert.equal(adopters[expectedPetId], expectedAdopter, "Owner of the expected pet should be this contract");
    }
}



上一篇:区块链4.0跨链机制有哪些特点? [
下一篇:Using &quot;owner = msg.sender&quot; in a non-constructor function or in a decla
回复

使用道具 举报

 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

排行榜

关注我们:微信订阅号

官方微信

APP下载

全国服务邮箱:

admin@xuesq.cn

公司地址:重庆南岸区学府大道

运营中心:重庆微生派网络工作室

邮编:610066 Email:1401171837#qq.com

Copyright   ©2017-2018  中比特Powered by©xuesq.cn!技术支持:中比特    ( 蜀ICP备16009247号-1 )