Truffle test command failing with no description of error

Viewed 92

I have a Campaign.sol smart contract with the following constructor -

constructor (
        string memory _name,
        string memory _imageURL,
        string memory _description,
        string memory _descriptionURL,
        uint256 _goalAmount,
        uint256 _expiresInDays,
        uint256 _refundPeriodInDays,
        address payable _beneficiary,
        address _custodian
    ) {
        name = _name;
        imageURL = _imageURL;
        description = _description;
        descriptionURL = _descriptionURL;
        beneficiary = _beneficiary;
        goalAmount = _goalAmount;
        expiresInDays = _expiresInDays;
        refundPeriodInDays = _refundPeriodInDays;
        campaignStartTime = block.timestamp;
        _transferOwnership(_custodian);
    }

I have a test file campaign.js as follows:

const Campaign = artifacts.require("Campaign");
var sinon = require("sinon");



contract('Campaign', (accounts) => {
  const _name = "Beneficiary Name";
  const _imageURL = "https://picsum.photos/200/300"; 
  const _description = "Beneficiary description";
  const _descriptionURL = "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf" 
  const _beneficiary = accounts[1];
  const _custodian = accounts[0];
  const ERROR_MSG = "VM Exception while processing transaction: revert ";
  let clock;
  beforeEach(function () {
      clock = sinon.useFakeTimers();
  });

  afterEach(function () {
      clock.restore();
  });

  it('should donate only when campaign is not expired', async () => {
    const campaignInstance = await Campaign.new(
      _name, 
      _imageURL, 
      _description, 
      _descriptionURL, 
      150,
      2,
      1,
      _beneficiary, 
      _custodian);
    
    try {
      clock.tick(17290);
      await campaignInstance.donate(accounts[3], 20);
    } catch (err) {
      assert(err, "Expected an error but did not get one");
      expect(err.message).to.include("Campaign has expired");
    }
  });

});


When I try to do test inside the truffle consol, it compiles but errors out after that. Also, the error message is not shown. I am unable to debug it.

Console output:

truffle(ganache)> test
Using network 'ganache'.


Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.
Error: 
    at /opt/homebrew/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:379:1
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at Migration._deploy (/opt/homebrew/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:68:1)
    at Migration._load (/opt/homebrew/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:54:1)
    at Migration.run (/opt/homebrew/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:202:1)
    at Object.runMigrations (/opt/homebrew/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:152:1)
    at Object.runFrom (/opt/homebrew/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:117:1)
    at Object.runAll (/opt/homebrew/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:121:1)
    at Object.run (/opt/homebrew/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:86:1)
    at Object.run (/opt/homebrew/lib/node_modules/truffle/build/webpack:/packages/core/lib/testing/Test.js:114:1)
    at Object.module.exports [as run] (/opt/homebrew/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/test/run.js:139:1)
    at Command.run (/opt/homebrew/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:189:1)
truffle(ganache)> 
0 Answers
Related