1

I'm reading truffles's docs and am trying to build a custom project with a contract and a few test cases (written in a js file). I need to do this because testrpc is (considerably) faster than geth. My setup is as follows:

I have a directory for the project with the following layout:

drwxr-xr-x 5 user user 4096 Aug  4 10:55 app
drwxr-xr-x 4 user user 4096 Aug  4 11:35 build
drwxr-xr-x 2 user user 4096 Aug  4 11:06 contracts
drwxr-xr-x 2 user user 4096 Aug  4 10:55 migrations
drwxr-xr-x 2 user user 4096 Aug  4 11:24 test
-rw-r--r-- 1 user user  248 Aug  4 10:55 truffle.js

The files were created using truffle init. I've cleared the contracts in the contracts directory and the js files in the test directory.

I have a contract:

C.sol

contract C {

    string words = "Bla bla bla";

    uint256 lastVal;

    function math(uint256 a, uint256 b) returns (uint256) {
        lastVal = a + b;
        return lastVal;
    }

    function getWords() constant returns (string) {
        return words;
    }
} 

in the contracts directory and a test file:

c.js

contract('C', function(accounts) {
  it("Getting the words string from the contract", function() {
    var c = C.deployed();

    return c.getWords.call(accounts[0]).then(function(words) {
      assert.equal(words, "Bla bla bla", "[E] The contract should have said \"Bla bla bla\"");
    });
  });

  it(" 2 + 2 = 4 ", function(){
    var c = C.deployed();

    return c.math(2, 2).then(function(additionResult){
        assert.equal(additionResult, 4, "[E] 2 + 2 = 4 even in eth. contracts.");
    });
  });
});

in the tests directory. I have manually cleared the build directory and ran

truffle build

int the base directory. Nothing (no artifacts) gets built in the build directory. Why?

Does anybody have a minimal setup that does not involve developing a web app? only the contract .sol files and js test files.

2

The output is not in the build directory but in the ./environments/ directories.

Truffle knows 4 environments by default

  • development
  • staging
  • production
  • test

Each environment is configurable to use a different blockchain. You can change your environment by truffle deploy -e <environment>

Read more on the configuration in the truffle docs.

  • Now I ran into another issue related to testing methods. I've opened a ticket here: github.com/ConsenSys/truffle/issues/225 . I have no environments directories in my project directory. – Sebi Aug 5 '16 at 14:13
  • In version v2.0.4 that I'm using truffle init doesn't create the environment directories anymore. – Sebi Aug 5 '16 at 14:34
  • Do you have a minimal setup of truffle? I'm stuck at testing state changing methods: ethereum.stackexchange.com/questions/7822/… – Sebi Aug 8 '16 at 8:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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