How to contribute?
Building the SDK
Prerequisites
Docker
Gradle
The SDK heavily makes use of the lombok IDE plugin to hide glue code, especially getters, setters, builders and helper methods and helps to keep the classes clean and focus on the logic. The plugin is needed in your IDE of choice to automatically create the necessary methods in the background
latest version of the SDK (dev branch):
git clone git@github.com:kryptokrauts/aepp-sdk-java.git
git checkout dev
Development environment
The SDK is shipped with multiple preconfigured docker containers to support integration testing and debugging. In order to start them just call docker-compose:
docker-compose up -d
After pulling the images you should see the following instances up and running:
aeternal - local middleware that provides aggregated data and websockets
compiler - local aeternity node to provide the sophia compiler functions
node - local aeternity node to provide the protocol functions
proxy - a nginx httpd to expose the aeternity nodes as well as the goggles app to the running host
The services then can be accessed through the following URLs.
Function
URL
aeternal REST API
http://aeternal.localhost/api
OR
http://localhost:8080/api
node REST API
http://localhost/api
compiler REST API
http://compiler.localhost/api
OR
http://localhost:3080
docker-compose exec node sh
bash
cd log/
tail -100f aeternity.log
Generate API clients
In order to develop and test the SDK one need to generate the necessary Java classes for defined in the swagger endpoint definition once (and every time, the swagger definition is updated).
# if set to true the sources will be generated on each build
export AETERNITY_GENERATE_SOURCES=true # unix
SET AETERNITY_GENERATE_SOURCES=true # windows
# if the above env-variable is missing or set to false the sources
# need to be generated manually be executing this command
gradle generateApiClient
Testing the SDK
The SDK ships with two kinds of tests
unit tests, which run independently of a node and prove basic functions and services
integration tests, which need a running aeternity node and validate posted transactions of all currently supported types
In order to run the integration tests you need to define the URLs to the local aeternity and compiler node. This is done using the following environment variables (example is provided for local environment):
## using localhost
AETERNAL_BASE_URL = http://aeternal.localhost
AETERNITY_BASE_URL = http://localhost
COMPILER_BASE_URL = http://compiler.localhost
## using aelocal (by editing /etc/hosts)
AETERNAL_BASE_URL = http://aeternal.aelocal
AETERNITY_BASE_URL = http://aelocal
COMPILER_BASE_URL = http://compiler.aelocal
## using IP
AETERNAL_BASE_URL = http://localhost:8080
AETERNITY_BASE_URL = http://localhost
COMPILER_BASE_URL = http://localhost:3080
The tests can be run within your IDE of choice by using the following gradle tasks
gradle test
gradle integrationTest
Contributing to the SDK
All contributions to the SDK must be linked to an issue within the aepp-sdk-java project - either pick one or create a new one if you miss a feature or want to fix / enhance current services.
The next step is to create a feature branch which must be named according to the ticket
feature/<ticket-number>-<further-description>
Integrationtests should extend the BaseTest class which especially provides some convinent functions for running tests using the underlying vertx framework. Test methods can thus make use of the
executeTest(TestContext context, Consumer<?> method)
method, assertions should be made using the vertx TestContext
@Test
public void testMyLogic(TestContext context) {
this.executeTest(
context,
t -> {
<Custom Test Logic>
context.assertTrue(result.getBalance().compareTo(ZERO) == 1);
});
}
After implementing the feature / enhancement / fix and providing an appropriate amount of tests / integration tests format your code using the google formatter pattern (if you don't already use it) by running the following gradle command. Unformated / wrong formatted as well as untested code will be rejected.
gradle googleJavaFormat
Then push your branch and create a pull request. After successful review, the PR will be merged into the dev branch and later into the master branch, from where it will be released.
Last updated
Was this helpful?