orbs-network / orbs-network-go

Orbs node virtual chain core reference implementation in Go
MIT License
47 stars 12 forks source link

Orbs Network Core Node

Orbs is a public blockchain infrastructure built for the needs of decentralized apps with millions of users. For more information, please check https://orbs.com and read the white papers.

This repo contains the node core reference implementation in golang.

The project is thoroughly tested with unit tests, component tests per microservice, acceptance tests, E2E tests and E2E stress tests running the system under load.

Building Docker images only

If you only want to build the Docker images containing the node binaries, you don't need to have golang on your own machine (the node will be compiled inside the image).

Building from source

Prerequisites

Build

Run

Testing from command line

Test runner

We use the official go test runner go test. It has minimal UI and result caching.

Please install go-junit-reporter prior to running tests for the first time:

go get -u github.com/orbs-network/go-junit-report

Test

Test types

E2E tests (slow)

End-to-end tests check the entire system in a real life scenario mimicking real production with multiple nodes. It runs on docker with several nodes connected in a cluster. Due to their nature, E2E tests are slow to run.

Integration tests (slow)

Integration tests check the system adapters and make sure they meet the interface contract they implement. For example connection to a database or network sockets.

Acceptance tests (fast)

Acceptance tests check the internal hexagon of the system (it's logic with all microservices) with faster adapters that allow the suite to run extremely fast.

Component tests (fast)

Component tests check that a single service meets its specification while mocking the other services around it. They allow development of a service in isolation.

Unit tests (fast)

Unit tests are very specific tests that check a single unit or two. They test the unit in isolation and stub/mock everything around it.

Testing on Docker

For Troubleshooting, see the Docker Guide

All tests run automatically when the Docker images are built. The script ./test.sh is part of the Docker build.

Component tests on Docker

To detect flaky tests of specific components, run component tests multiple times on Docker:

After you've finished editing, run ./docker/build/build.sh && ./docker/test/test.sh

You should probably not commit any of these edits you've made for testing, as they are transient in nature.

Developer experience

Git hooks

Please run git config --local core.hooksPath .githooks after cloning the repository.

Debugging issues on Docker

Occasionally, local tests with go test will pass but the same tests on Docker will fail. This usually happens when tests are flaky and sensitive to timing (we do our best to avoid this).

IDE

Profiling

To enable profiling: put "profiling": true in your config.json.

It will enable net/http/pprof package, and you will be able to query pprof via http just as described in the docs.

Debugging with logs

By default, log output is filtered to only errors and metrics. To enable full log, put "logger-full-log": true in your node configuration. It will permanently remove the filter.

If you want to enable or disable this filter in production, there is a way to do that via HTTP API:

curl -XPOST http://$NODE_IP/vchains/$VCHAIN/debug/logs/fiter-on

Or

curl -XPOST http://$NODE_IP/vchains/$VCHAIN/debug/logs/fiter-off

Development principles

Refer to the Contributor's Guide (work in progress)

License

MIT