1
truffle(develop)> version
Truffle v5.0.5 (core: 5.0.5)
Solidity v0.5.0 (solc-js)
Node v10.15.1
const ApprovalContracts = artifacts.require('../../contracts/ApprovalContracts.sol'); 

contract ('ApprovalContracts', function (accounts) {
    it('initiates contract', async function() { 
        const contract = await ApprovalContracts.depolyed();
        const approver = await contract.approver.call(); 
        assert.equal(approver, 0xc7780C9521C2C2abED69f0D65BEbF9794C55ae94, "approvers don't match");
    });

    it('takes a deposit', async function() {
        const contract = await ApprovalContracts.depolyed();
        await contract.deposit(accounts[0], {value: 1e+18, from: accounts [1]});
        assert.equal(web3.eth.getBalance(contract.address), 1e+18, "amount did not match")
    })
})

ERRORS

 TypeError: ApprovalContracts.depolyed is not a function
  at Context.<anonymous> (test\approvalcontract.js:10:43)
  at web3.eth.getBlockNumber.then.result (C:\Users\_000\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-core\lib\testing\testrunner.js:134:1)
  at process._tickCallback (internal/process/next_tick.js:68:7)

 TypeError: ApprovalContracts.depolyed is not a function
  at Context.<anonymous> (test\approvalcontract.js:17:43)
  at web3.eth.getBlockNumber.then.result (C:\Users\_000\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-core\lib\testing\testrunner.js:134:1)
  at process._tickCallback (internal/process/next_tick.js:68:7)

Im very sure that its the .depolyed and its expecting a function.

2 Answers 2

2

You're missing }); at the end.

const ApprovalContracts = artifacts.require('../../contracts/ApprovalContracts.sol'); 

contract('ApprovalContracts', function (accounts) { 

  it('initiates contract', async function() {  
    const contract = await ApprovalContracts.deployed();
    const approver = await contract.approver.call();     
    assert.equal(approver, 0xc7780C9521C2C2abED69f0D65BEbF9794C55ae94, "approvers don't match");    
  }); // <----I can see the error, not sure how to correct it.
});  // <--- To close the contract({}) block

Hope it helps.

1
  • I corrected a little typo :-) Mar 14, 2019 at 18:39
1

You have a typo in:

const contract = await ApprovalContracts.depolyed();

Like the error says, depolyed() is not a function. deployed() is.

const contract = await ApprovalContracts.deployed();
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.