<h2>v0.11.0 and after:</h2>

<p>Check and make sure that your daemon version is v0.11.0 or greater. If it is, the generate method should work.</p>

<h2>Pre v0.11.0:</h2>

<p>The <code>setgenerate true</code> method should be used.</p>

<p>In a standard network (such as <code>testnet</code> or <code>main</code>), <code>setgenerate true</code> will turn mining on indefinitely. In regtest, it just mines one block. You can also do </p>

<pre><code>setgenerate(TRUE, 10)
</code></pre>

<p>To mine 10 regtest blocks. The second parameter is called the generation limit.</p>

CC BY-SA 3.0
2015-08-25T20:47:37.123Z
according to the [generate method reference](https://bitcoin.org/en/developer-reference#generate) the method should be used especially in `regtest` mode to mine blocks instantly without the computing cost, and that feature is a must for a platform like travis-ci. If you are asking for `generate()` body see [this](https://github.com/jangorecki/rbitcoind/blob/0e7ec4e2686849a5a169ae8b6989e4f1d26415b6/R/methods.R#L8). It just works on two CI environments: ubuntu and vm ubuntu.
jangorecki
CC BY-SA 3.0
2015-08-25T20:57:44.413Z
@jangorecki That must have been added in v0.11.0, I'm currently running v0.10.2. The release notes don't say that a `generate` method was added, though. What version of `bitcoind` are you running?
morsecoder
CC BY-SA 3.0
2015-08-25T21:03:37.963Z
OK, I see I have `0.10.2` on travis, this is the reason of no method found. I'm using same ppa so it should get the latest version of bitcoind, isn't it? you can put info about version to your answer so I will accept it. Thanks
jangorecki
CC BY-SA 3.0
2015-08-25T21:09:10.567Z
@jangorecki I guess the ppa is out of date. It's only one version out of date, at least. I have updated my answer to include version info.
morsecoder
CC BY-SA 3.0
2015-08-25T22:54:58.117Z
https://launchpad.net/~bitcoin/+archive/ubuntu/bitcoin did they stop builds for ubuntu 12.04?
jangorecki
CC BY-SA 3.0
2015-08-26T19:38:59.810Z
No, builds failed for 12.04, and they were never fixed.
Matt Corallo
CC BY-SA 3.0
2015-09-03T12:03:06.150Z
@MattCorallo is it so difficult to make them work? this would allow any github project which uses travis-ci to run unit tests against own blockchain, quite a huge extension.
jangorecki
CC BY-SA 3.0
2015-08-25T20:32:36.760Z
2015-08-25T21:07:50.813Z
2015-08-25T21:07:50.813Z
morsecoder
<p>Subtitle: <strong>travis-ci fails to run <code>generate</code> JSON-RPC method on regtest</strong></p>

<p>I'm trying to setup CI process on <a href="https://travis-ci.org" rel="nofollow">https://travis-ci.org</a> platform to install bitcoind and start new blockchain using <code>regtest</code> mode.<br>
I want to do this to run unit tests of my applications which uses wallet data. Methods against bitcoind are working fine except the <code>generate</code> method which is needed to mine some bitcoins in regtest private chain.  </p>

<p>It looks like some <code>bitcoind/travis-ci</code> related issue.  </p>

<ol>
<li><code>generate</code> method is working fine in my local CI process (non-travis).</li>
<li>Travis-CI is working fine if I comment the <code>generate</code> method call in CI tests.  </li>
</ol>

<p><code>generate</code> method call when using travis-ci fails with the following error:</p>

<p></p>

<pre><code>{"code":-32601,"message":"Method not found"}
</code></pre>

<p><code>bitcoin.conf</code>:  </p>

<pre><code>server=1
regtest=1
gen=1
rpcuser=someuser
rpcpassword=somepass
</code></pre>

<p><code>.travis.yml</code>:</p>

<pre><code>language: r
sudo: required

before_script:
  - sudo apt-add-repository ppa:bitcoin/bitcoin -y
  - sudo apt-get update -qq
  - sudo apt-get install bitcoind -y

r_github_packages:
 - jangorecki/rbitcoind

after_script:
 - cat $(find . -maxdepth 1 -name "*.Rcheck" -type d)/tests/tests.Rout
</code></pre>

<p><strong>Is there any trick in setup I should use to make travis-ci capable to run CI on <code>regtest</code> chain, including <code>generate</code> method?</strong>  </p>

<p>Leaving the build links just for reference:<br>
- <code>generate</code> method commented - CI passed: <a href="https://travis-ci.org/jangorecki/rpc.generate/builds/77207297" rel="nofollow">https://travis-ci.org/jangorecki/rpc.generate/builds/77207297</a><br>
- use <code>generate</code> - CI failed: <a href="https://travis-ci.org/jangorecki/rpc.generate/builds/77208666" rel="nofollow">https://travis-ci.org/jangorecki/rpc.generate/builds/77208666</a></p>

<bitcoind><json-rpc><block><regtest>
Continuous integration setup using bitcoind regtest on travis-ci
jangorecki
# Continuous integration setup using bitcoind regtest on travis-ci

(Asked by: username_0 on 2015-08-25)

Subtitle: **travis-ci fails to run `generate` JSON-RPC method on regtest**

I'm trying to setup CI process on <https://travis-ci.org> platform to install bitcoind and start new blockchain using `regtest` mode.  
I want to do this to run unit tests of my applications which uses wallet data. Methods against bitcoind are working fine except the `generate` method which is needed to mine some bitcoins in regtest private chain.

It looks like some `bitcoind/travis-ci` related issue.

1. `generate` method is working fine in my local CI process (non-travis).
2. Travis-CI is working fine if I comment the `generate` method call in CI tests.

`generate` method call when using travis-ci fails with the following error:

```
{"code":-32601,"message":"Method not found"}

```

`bitcoin.conf`:

```
server=1
regtest=1
gen=1
rpcuser=someuser
rpcpassword=somepass

```

`.travis.yml`:

```
language: r
sudo: required

before_script:
  - sudo apt-add-repository ppa:bitcoin/bitcoin -y
  - sudo apt-get update -qq
  - sudo apt-get install bitcoind -y

r_github_packages:
 - username_0/rbitcoind

after_script:
 - cat $(find . -maxdepth 1 -name "*.Rcheck" -type d)/tests/tests.Rout

```

**Is there any trick in setup I should use to make travis-ci capable to run CI on `regtest` chain, including `generate` method?**

Leaving the build links just for reference:  
- `generate` method commented - CI passed: <https://travis-ci.org/username_0/rpc.generate/builds/77207297>  
- use `generate` - CI failed: <https://travis-ci.org/username_0/rpc.generate/builds/77208666>

**Tags:** bitcoind, json-rpc, block, regtest


---

## 1 answers

### Answer by username_1 on 2015-08-25. Score: 3 | Accepted answer

## v0.11.0 and after:

Check and make sure that your daemon version is v0.11.0 or greater. If it is, the generate method should work.

## Pre v0.11.0:

The `setgenerate true` method should be used.

In a standard network (such as `testnet` or `main`), `setgenerate true` will turn mining on indefinitely. In regtest, it just mines one block. You can also do

```
setgenerate(TRUE, 10)

```

To mine 10 regtest blocks. The second parameter is called the generation limit.

> **Comments:**
> **username_0**: according to the [generate method reference](https://bitcoin.org/en/developer-reference#generate) the method should be used especially in `regtest` mode to mine blocks instantly without the computing cost, and that feature is a must for a platform like travis-ci. If you are asking for `generate()` body see [this](https://github.com/username_0/rbitcoind/blob/0e7ec4e2686849a5a169ae8b6989e4f1d26415b6/R/methods.R#L8). It just works on two CI environments: ubuntu and vm ubuntu.  
> **username_1**: @username_0 That must have been added in v0.11.0, I'm currently running v0.10.2. The release notes don't say that a `generate` method was added, though. What version of `bitcoind` are you running?  
> **username_0**: OK, I see I have `0.10.2` on travis, this is the reason of no method found. I'm using same ppa so it should get the latest version of bitcoind, isn't it? you can put info about version to your answer so I will accept it. Thanks  
> **username_1**: @username_0 I guess the ppa is out of date. It's only one version out of date, at least. I have updated my answer to include version info.  
> **username_0**: https://launchpad.net/~bitcoin/+archive/ubuntu/bitcoin did they stop builds for ubuntu 12.04?  
> **username_2**: No, builds failed for 12.04, and they were never fixed.  
> **username_0**: @username_2 is it so difficult to make them work? this would allow any github project which uses travis-ci to run unit tests against own blockchain, quite a huge extension.  

---

