0

I am trying to run a test with truffle.

But I am getting an error:

Error: Invalid number of arguments to Solidity function

My contract looks like this:

pragma solidity ^0.4.0;

contract Leontest1 {
    uint flight_number;
    uint day_number;
    string low_no = "This is a low flight number";

    function Leontest1() {
     //contructor
    }

    function low_numbers (uint flight_number) returns (string) {
        if (flight_number > 6) {low_no = "This is not a low flight number";} else {low_no = low_no;}
        return low_no;


    }
}

And my test.js looks like this:

var Leontest1 = artifacts.require("./Leontest1.sol");

contract('Leontest1:low_numbers', function(accounts) {
  it("should assert true", async function() {
    const contract = await Leontest1.deployed();
    await contract.low_numbers(5);
    const result = await contract.low_numbers.call();
    assert.equal(result,"This is a low flight number");

  });
});

Can someone help me please?

I am using Truffle v4.1.7

Thanks in advance,

1
  • What's this doing in your code? {low_no = low_no;} May 16, 2018 at 19:22

1 Answer 1

1

Well, function low_numbers takes an argument, which you are not passing it.

Solidity code:

function low_numbers (uint flight_number) returns (string) {

Javascript code:

const result = await contract.low_numbers.call();

BTW, you are calling it twice (what exactly is the point in that???):

await contract.low_numbers(5);
const result = await contract.low_numbers.call();
1
  • I have taken out the line const result = await contract.low_numbers.call();
    – Victor
    Jun 3, 2018 at 2:05

Your Answer

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

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