Skip to content

ganchix/testcontainers-java-module-ganache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TestContainers Ganache testing module Build Status codecov Maven Central GitHub stars

Testcontainers module for Ganache.

Table of Contents

Overview

A simple way to test Ethereum in your Java Code

See testcontainers.org for more information about Testcontainers.

Getting started

Add dependency

Maven
<dependency>
    <groupId>io.github.ganchix</groupId>
    <artifactId>testcontainers-java-module-ganache</artifactId>
    <version>0.0.4</version>
</dependency>
Gradle
compile group: 'io.github.ganchix', name: 'testcontainers-java-module-ganache', version: '0.0.4'

Code example

Running Ganache during a test:

public class SomeTest {


	@Rule
	public GanacheContainer GanacheContainer = new GanacheContainer();

    
	@Test
	public void simpleTestWithClientCreation() {
            Web3j web3j = ganacheContainer.getWeb3j();
            assertEquals( web3j.ethBlockNumber().send().getBlockNumber(), BigInteger.ZERO);
            assertNotNull(ganacheContainer);
	}
}

Considerations

To obtain the data of addresses and privates keys of console log we implemented a custom log consumer LogGanacheExtractorConsumer, if you overwrite it this information will not be extracted.

License

Testcontainers module for Ganache is licensed under the MIT License. See LICENSE for details.

Copyright (c) 2018 Rafael Ríos Moya

About

Testcontainers module for Ganache CLI

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •