Skip to content

Commit

Permalink
Doc change (#6)
Browse files Browse the repository at this point in the history
* chore: Next snapshot version

* chore: Doc updated for 0.0.2 release
  • Loading branch information
satran004 authored Apr 13, 2024
1 parent b33e624 commit b743923
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 13 deletions.
87 changes: 75 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ in your test code through a Test Helper class and use Cardano specific assertion

- Docker - [please see General Docker requirements](https://www.testcontainers.org/supported_docker_environment/)

## How to use

Check this sample project https://github.com/bloxbean/yaci-cardano-test-sample

For more tests check the [test](https://github.com/bloxbean/yaci-cardano-test/tree/main/src/test/java/com/bloxbean/cardano/yaci/test) pacakage in this project.

## Dependencies

### Maven dependencies
Expand All @@ -25,7 +19,7 @@ For more tests check the [test](https://github.com/bloxbean/yaci-cardano-test/tr
<dependency>
<groupId>com.bloxbean.cardano</groupId>
<artifactId>yaci-cardano-test</artifactId>
<version>0.0.1</version>
<version>0.0.2</version>
<scope>test</scope>
</dependency>
```
Expand All @@ -35,12 +29,17 @@ You also need to add following cardano-client-lib dependencies and also junit 5.
<dependency>
<groupId>com.bloxbean.cardano</groupId>
<artifactId>cardano-client-lib</artifactId>
<version>0.4.3</version>
<version>0.5.1</version>
</dependency>
<dependency>
<groupId>com.bloxbean.cardano</groupId>
<artifactId>cardano-client-backend</artifactId>
<version>0.4.3</version>
<version>0.5.1</version>
</dependency>
<dependency>
<groupId>com.bloxbean.cardano</groupId>
<artifactId>cardano-client-backend-ogmios</artifactId>
<version>0.5.1</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand All @@ -54,15 +53,79 @@ You also need to add following cardano-client-lib dependencies and also junit 5.
### Gradle Dependencies

```
testImplementation "com.bloxbean.cardano:yaci-cardano-test:0.0.1"
testImplementation "com.bloxbean.cardano:yaci-cardano-test:0.0.2"
```

Other dependencies

```
implementation "com.bloxbean.cardano:cardano-client-lib:0.4.3"
implementation "com.bloxbean.cardano:cardano-client-backend:0.4.3"
implementation "com.bloxbean.cardano:cardano-client-lib:0.5.1"
implementation "com.bloxbean.cardano:cardano-client-backend:0.5.1"
implementation "com.bloxbean.cardano:cardano-client-backend-ogmios:0.5.1"
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.2'
```

## Quick Start

### Start a Cardano Node with Yaci Store API (Blockfrost Compatible API) support

The following code snippet demonstrates how to launch a Cardano node in a Docker container and fund an account with 20,000 ADA.
By default, the Yaci Store API is enabled, which can be used to query and submit transactions to the running node.
The Yaci Store API is compatible with the Blockfrost API.

```java
YaciCardanoContainer yaciCardanoContainer = new YaciCardanoContainer()
.withInitialFunding(new Funding(account.baseAddress(), 20000))
.withLogConsumer(outputFrame -> System.out.println(outputFrame.getUtf8String()));

yaciCardanoContainer.start();
```

### Start a Cardano Node with Ogmios Api Support

```java
YaciCardanoContainer yaciCardanoContainer = new YaciCardanoContainer()
.withApiMode(ApiMode.OGMIOS)
.withInitialFunding(new Funding(account.baseAddress(), 20000))
.withLogConsumer(outputFrame -> System.out.println(outputFrame.getUtf8String()));

yaciCardanoContainer.start();
```

### Build and Submit a Transaction

Get Cardano Client Lib Suppliers required to build and submit transactions

```java
var utxoSupplier = yaciCardanoContainer.getUtxoSupplier();
var protocolParamsSupplier = yaciCardanoContainer.getProtocolParamsSupplier();
var transactionProcessor = yaciCardanoContainer.getTransactionProcessor();
```

Using the above suppliers, you can build and submit transactions using one of the transaction builders in the Cardano Client Library.

### Assertion Library

Yaci Cardano Test provides a set of Cardano specific assertions to verify the results of your tests.
For example, you can verify the ada or asset balance of an address, verify utxo size, etc.

```java
Assertions.assertMe(cardanoContainer).hasLovelaceBalance(receiverAddress, adaToLovelace(2.1));
Assertions.assertMe(cardanoContainer).hasAssetBalance(receiverAddress, policy.getPolicyId(), "abc", BigInteger.valueOf(300));
Assertions.assertMe(cardanoContainer).utxos(receiverAddress).hasSize(1);
Assertions.assertMe(cardanoContainer).utxos(receiverAddress).hasLovelaceBalance(adaToLovelace(2.1));
```

## Examples

Check this sample project https://github.com/bloxbean/yaci-cardano-test-sample

For more tests check the [test](https://github.com/bloxbean/yaci-cardano-test/tree/main/src/test/java/com/bloxbean/cardano/yaci/test) pacakage in this project.

# Any questions, ideas or issues?

- Create a Github [Discussion](https://github.com/bloxbean/yaci-cardano-test/discussions)
- Create a Github [Issue](https://github.com/bloxbean/yaci-cardano-test/issues)
- [Discord Server](https://discord.gg/JtQ54MSw6p)
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
group = com.bloxbean.cardano
artifactId = yaci-cardano-test
version = 0.0.2
version = 0.0.3-SNAPSHOT

0 comments on commit b743923

Please sign in to comment.