Coder Social home page Coder Social logo

warchant / testcontainers-iroha Goto Github PK

View Code? Open in Web Editor NEW
5.0 4.0 1.0 189 KB

MOVED TO

Home Page: https://github.com/hyperledger/iroha-java

License: Apache License 2.0

Java 65.59% Groovy 19.82% Dockerfile 0.63% Shell 13.95%
iroha testcontainers java

testcontainers-iroha's Introduction

Build Status Codacy Badge codecov GitPitch

testcontainers-iroha

Testcontainers image for single Iroha peer and iroha network.

Features

  • run one or multiple independent iroha peers (not connected to a network) with IrohaContainer class.
  • run one or multiple independent iroha networks with IrohaNetwork class. All peers within a network are connected to a single network.
  • define custom genesis block or peer config for peer/network at run-time.
  • select iroha or postgres version at run-time.

Install

https://jitpack.io/#warchant/testcontainers-iroha

Usage

Single Peer

class SinglePeerTest {

  IrohaContainer iroha = new IrohaContainer();

  @BeforeAll
  public void beforeAll(){
    iroha.start(); // starts iroha and postgres
  }

  @AfterAll
  public void afterAll(){
    iroha.stop(); // stops iroha and postgres
  }

  @Test
  public TestWithIroha (){
    URI toriiAddr = iroha.getToriiAddress();  // iroha API host:port (torii)
    IrohaAPI api  = iroha.getApi();  // or use async Iroha API wrapper directly
    // ...
  }
}

IrohaContainer starts Postgres and Iroha docker containers with given PeerConfig. There is a default config for test purposes.

Configuration

To change default configuration:

IrohaContainer iroha = new IrohaContainer()
    .withPeerConfig( /* pass config here */ );

iroha.start();
...
iroha.stop();

Network Of Peers

class IrohaNetworkTest {

  IrohaNetwork iroha = new IrohaNetwork(5 /* peers */);

  // networks are completely independent
  IrohaNetwork network2 = new IrohaNetwork(5 /* peers */)
            .withNetworkName("someUniqueName");

  @BeforeAll
  public void beforeAll(){
    iroha.start(); // starts all containers
  }

  @AfterAll
  public void afterAll(){
    iroha.stop(); // stops all containers
  }

  @Test
  public TestWithIroha (){
    List<URI> toriiAddr = iroha.getToriiAddress();  // list of iroha API host:port (torii)
    List<IrohaAPI> apis = iroha.getApis();  // or list of async Iroha API wrappers, 1 per peer
    // ...
  }
}

Configuration

To change default configuration:

IrohaNetwork network = new IrohaNetwork(5 /* peers */);

// setup shared iroha config
network.withIrohaConfig(IrohaConfig.builder()
  .setMst_enable(true)
  .build())

// to change genesis block (peers are added automatically)
network.addTransaction(tx);

network.start();
...
network.stop();

Known Issues

If you get an Exception:

com.github.dockerjava.api.exception.DockerException: Mounts denied

You are probably on MAC and you need to add /var/folder to docker paths:

Please refer to testcontainers/testcontainers-java#730

testcontainers-iroha's People

Contributors

dependabot-support avatar warchant avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

sudomann

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.