Skip to content

Instantly share code, notes, and snippets.

@karimofthecrop
Created May 3, 2019 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karimofthecrop/4069e509e184a000a84f0ad7b3423cc6 to your computer and use it in GitHub Desktop.
Save karimofthecrop/4069e509e184a000a84f0ad7b3423cc6 to your computer and use it in GitHub Desktop.

Table of Contents

  1. Intro
  2. Setup Vagrantfile:
  3. Setup ssh config
  4. Host updates and apt setup
  5. Install necessary stuff
  6. Get source code, start building
  7. Run tests

Intro

The following will allow you to setup a Vagrant box that is ready to go for writing tests and/or code in the bitcoin codebase. We assume you have VirtualBox, or some other pre-configured provider for Vagrant.

Setup Vagrantfile:

put the below in some working directory such as $HOME/vagrants/bitcoin

Vagrant.configure("2") do |config|

  # change this to your preferred debian flavor
  config.vm.box = "ubuntu/trusty64"

  # map your source code/project directory here so that it is visible
  # in the guest. I like "src", you might use "projects" or "dev".
  config.vm.synced_folder "$HOME/src", "/home/vagrant/src"

  # if you want to run QT wallet
  config.ssh.forward_x11 = true

  # This is nice if you are using vagrant for other things to avoid port conflicts.
  config.vm.network :forwarded_port, guest: 22, host: 10309, id: 'ssh'
end

Setup ssh config

Put the following in to (your possibly new) ~/.ssh/config. Note that you need to edit the path in IdentityFile

Host bitcoin-dev
	 HostName 127.0.0.1
	 User vagrant
	 Port 10309
	 IdentityFile $HOME/$PATH_TO_VAGRANT/.vagrant/machines/default/virtualbox/private_key
	 ForwardX11 yes
	 UserKnownHostsFile /dev/null
	 LogLevel QUIET
	 StrictHostKeyChecking no

Test that you can get into your new Vagrant box

cd $HOME/vagrants/bitcoin
vagrant up
ssh bitcoin-dev

All remaning commands are executed on vagrant guest

Host updates and apt setup

# On guest
sudo add-apt-repository ppa:bitcoin/bitcoin
sudo apt-get update
sudo apt-get upgrade

Install necessary stuff

sudo apt-get install \
  autoconf \
  bash-completion \
  build-essential \
  emacs \
  git \
  libboost-all-dev \
  libcanberra-gtk-module \
  libdb4.8++-dev \
  libdb4.8-dev \
  libevent-dev \
  libprotobuf-dev \
  libssl-dev \
  libtool \
  pkg-config \
  protobuf-compiler \
  qt5-default \
  qttools5-dev-tools \
  libqrencode-dev

Get source code, start building

cd ~/src # or your preferred working directory mapped in Vagrantfile
git clone https://github.com/bitcoin/bitcoin.git
cd bitcoin
git checkout v0.18.0
./autogen.sh
./configure --with-gui --with-qrencode --with-zmq --disable-bip70
make

Run tests

make check
src/test/test_bitcoin
test/functional/test_runner.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment