TransWikia.com

Testing using Truffle unbox: Assert.equal error

Ethereum Asked on August 26, 2021

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.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP