Truffle Compile failing, ParserError: Expected token LParen got Identifier function

0 votes

truffle compile fails with the following error:

Error parsing /Users/rdelrosario/ron-eth-pet-shop/test/TestAdoption.sol: ParsedContract.sol:19:14: ParserError: Expected token LParen got 'Identifier'function testGetAdopterAddressByPetId() public {

Code is below:

pragma solidity ^0.4.17;

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

contract TestAdoption {
  Adoption adoption = Adoption(DeployedAddresses.Adoption());

  // Testing the adopt() function
  function testUserCanAdoptPet() public {
    uint returnedId = adoption.adopt(8);

    uint expected = 8;

    Assert.equal(returnedId, expected, "Adoption of pet ID 8 should be recorded.");

    // Testing retrieval of a single pet's owner
    function testGetAdopterAddressByPetId() public {
      // Expected owner is this contract
      address expected = this;

      address adopter = adoption.adopters(8);

      Assert.equal(adopter, expected, "Owner of pet ID 8 should be recorded.");

    // Testing retrieval of all pet owners
    function testGetAdopterAddressByPetIdInArray() public {
      // Expected owner is this contract
      address expected = this;

      // Store adopters in memory rather than contract's storage
      address[16] memory adopters = adoption.getAdopters();

      Assert.equal(adopters[8], expected, "Owner of pet ID 8 should be recorded.");
      }
    }
  }
}

Oct 9, 2018 in Blockchain by slayer
• 29,040 points
126 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Your parentheses are mismatched.

pragma solidity ^0.4.17;

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

contract TestAdoption {
  Adoption adoption = Adoption(DeployedAddresses.Adoption());

  // Testing the adopt() function
  function testUserCanAdoptPet() public {
    uint returnedId = adoption.adopt(8);

    uint expected = 8;

    Assert.equal(returnedId, expected, "Adoption of pet ID 8 should be recorded.");
  }

  // Testing retrieval of a single pet's owner
  function testGetAdopterAddressByPetId() public {
    // Expected owner is this contract
    address expected = this;

    address adopter = adoption.adopters(8);

    Assert.equal(adopter, expected, "Owner of pet ID 8 should be recorded.");
  }

  // Testing retrieval of all pet owners
  function testGetAdopterAddressByPetIdInArray() public {
    // Expected owner is this contract
    address expected = this;

    // Store adopters in memory rather than contract's storage
    address[16] memory adopters = adoption.getAdopters();

    Assert.equal(adopters[8], expected, "Owner of pet ID 8 should be recorded.");
  }

}
answered Oct 9, 2018 by Omkar
• 65,810 points

Related Questions In Blockchain

0 votes
1 answer
0 votes
1 answer

Truffle Error: Migrations contract constructor expected

You are not using constructor() public { ...READ MORE

answered Aug 10, 2018 in Blockchain by digger
• 27,620 points
167 views
0 votes
1 answer

Can't call contract function in truffle console

Inspect the object adoption within the console. You will ...READ MORE

answered Sep 28, 2018 in Blockchain by slayer
• 29,040 points
343 views
0 votes
1 answer

Truffle migrate fails due to missing function, but it exists in node_modules

deployer.deploy(password1, password2, deadline, {value: 100, from: accounts[0]}); ...READ MORE

answered Oct 3, 2018 in Blockchain by digger
• 27,620 points
89 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
60 views
0 votes
1 answer

Solidity geth: Error encountered during contract execution [Bad instruction]

recipes is a dynamic storage array. You need ...READ MORE

answered Oct 15, 2018 in Blockchain by Omkar
• 65,810 points
28 views
0 votes
2 answers
0 votes
1 answer

How can I deploy a HelloWorld contract on my testrpc network?

The problem lies in the command: truffle migrate Your truffle migrate command ...READ MORE

answered Apr 27, 2018 in Blockchain by Perry
• 16,450 points

edited Aug 10, 2018 by Omkar 350 views
0 votes
1 answer

Solidity ParserError: Expected identifier but got '='

Hey, the solidity grammar doesn't allow assignments ...READ MORE

answered Oct 9, 2018 in Blockchain by Omkar
• 65,810 points
190 views
0 votes
1 answer

Truffle compile shows DeclarationError: Undeclared identifier.

Hey. You might have missed declaring the "myaddress"  ...READ MORE

answered Dec 4, 2018 in Blockchain by Omkar
• 65,810 points
38 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.