1

I'd like to build unit tests for a Quorum project including the Quorum specific part that is the privateFor attribute in the transactions. Is there a tool like testrpc specific to Quorum ?

1 Answer 1

1

You can get a Quorum chain up and running using the 7 Nodes Example. Then, you can actually use Truffle to compose and run tests in the same way you would for Ethereum with testrpc. truffle.js should be modified

module.exports = {
  networks: {
    development: {
      host: "localhost",
      port: 22001, // This is your second node, 22002 for second, etc.
      network_id: "*", 
      gasPrice: 0,
      gas: 4500000
    }
  }
}

Here is a tutorial with more details: http://truffleframework.com/tutorials/building-dapps-for-quorum-private-enterprise-blockchains.

4
  • thanks I'm aware of how to create a real quorum chain, but that would make for a rather impractical and slow unit tests setup (how do you reset the blockchain state between tests for example ?). I was thinking of something as practical and lightweight as testrpc
    – Adil
    Jan 26, 2018 at 9:55
  • With Truffle, you can use truffle migrate --reset so that each migration is fresh, and for tests, new contracts are launched each time you run and if you use a beforeEach() hook in your tests then you are looking at different contract instances each test - this is how working with testrpc works as well, or else you'd need to restart testrpc each time you wanted to test.
    – Karen S
    Jan 26, 2018 at 15:09
  • testrpc takes blockchain state snapshots, restores those outside mocha "contract" calls and allows to restore those manually as well. you can also advance the block timestamps ...
    – Adil
    Jan 26, 2018 at 15:17
  • Except for the ability to advance block timestamps, because you're right - I don't think that's achievable, but it'd be similar to testing with Ropsten or Rinkeby. You're still able to interact with the contract in the truffle console the same as an Ethereum network, so you're receiving the same type of Truffle artifacts that you'd need for testing results
    – Karen S
    Jan 26, 2018 at 15:25

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.