0

I ran the pet shop project. It uses "truffle unbox". The petshop project at: Petshop project using Assert.equal without any error

is able to execute Assert.equal command but when I am using Assert.equal, I am getting error. I am first deploying the pet-shop project in my project folder using "truffle unbox petshop". It creates the files but then I modified the files as follows. My files are (got from Michalzalecki):

//Funding.sol

pragma solidity 0.5.16;
contract Funding {
   address public owner;
   constructor() public {
      owner = msg.sender;
   }
}

//2_deploy_contracts.js
var Funding= artifacts.require("Funding");
module.exports = function(deployer){
   deployer.deploy(Funding);
};

//TestFunding.sol

pragma solidity ^0.5.0;
import "truffle/Assert.sol";
import "truffle/DeployedAddresses.sol";
import "../contracts/Funding.sol";

contract  TestFunding{

  function testSettingAnOwnerDuringCreation() public {
    Funding funding = new Funding();
    Assert.equal(funding.owner, address(this), "An owner is different than a deployer");
  }
}

I am getting following error when I am compiling my code using "truffle test":

$ truffle test You can improve web3's peformance when running Node.js versions older than 10.5.0 by installing the (deprecated) scrypt package in your project Using network 'development'.

Compiling your contracts... ===========================

Compiling ./test/TestFunding.sol

/test/TestFunding.sol:10:5: TypeError: Member "equal" not found or not visible after argument-dependent lookup in type(library Assert). Assert.equal(funding.owner, address(this), "An owner is different than a deployer"); ^----------^

Compilation failed. See above. Truffle v5.1.33 (core: 5.1.33) Node v8.10.0

Somebody please guide me how can I modify the pet-shop project to create a new project for testing so that it can use Assert.equal(...)command.

I am getting the same error after changing the Assert to 'assert':

$ truffle test

You can improve web3's peformance when running Node.js versions older than 10.5.0 by installing the (deprecated) scrypt package in your project Using network 'development'.

Compiling your contracts... ===========================

Compiling ./test/TestFunding.sol

/test/TestFunding.sol:10:5: TypeError: Member "equal" not found or not visible after argument-dependent lookup in function (bool) pure. assert.equal(funding.owner, address(this), "An owner is different than a deployer"); ^----------^

Compilation failed. See above. Truffle v5.1.33 (core: 5.1.33) Node v8.10.0

Zulfi.

  • 1
    what does the function.owner() function return? Can you show us the whole contract? – haxerl Jul 17 at 1:00
  • 1
    and you need to use adress(this) not this only to get back the contract’s address – haxerl Jul 17 at 1:02
  • I have corrected 'owner', its a state variable. I have provided the link for original code which mistakenly shows parenthesis with 'owner'. Code is complete. – zak100 Jul 19 at 3:00
  • Still the problem persists and I am getting error with "Assert.equal(...)". – zak100 Jul 19 at 21:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.