Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: mainsail compatibility and dependency upgrade #165

Merged
merged 8 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,25 @@ on: workflow_dispatch
jobs:
integration:
runs-on: ubuntu-latest
strategy:
matrix:
java: [8, 11, 15, 16, 17, 18, 19, 20, 21, 22]

steps:
- uses: actions/checkout@v2
- name: Checkout code
uses: actions/checkout@v2

- name: Use Java Version 8
uses: actions/setup-java@v1
with:
java-version: 8
- name: Use Java Version ${{ matrix.java }}
uses: actions/setup-java@v2
with:
distribution: "zulu"
java-version: ${{ matrix.java }}
cache: "gradle"

- name: Install
run: gradle dependencies
- name: Install
run: gradle dependencies

- name: Test
run: gradle integrationTest
env:
INTEGRATION_TESTS_MNEMONIC: ${{ secrets.MNEMONIC }}
- name: Test
run: gradle integrationTest
env:
INTEGRATION_TESTS_MNEMONIC: ${{ secrets.MNEMONIC }}
78 changes: 39 additions & 39 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,65 +6,65 @@ on:
- "master"
- "develop"
pull_request:
types: [ ready_for_review, synchronize, opened ]
types: [ready_for_review, synchronize, opened]

jobs:
format:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}

- name: Merge Conflict finder
uses: olivernybroe/[email protected]
- name: Merge Conflict finder
uses: olivernybroe/[email protected]

- name: Use Java Version 8
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: 8
cache: 'gradle'
- name: Use Java Version 8
uses: actions/setup-java@v2
with:
distribution: "adopt"
java-version: 8
cache: "gradle"

- name: Format code
run: gradle format
- name: Format code
run: gradle format

- name: Commit fixed code
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "style: resolve style guide violations"
branch: ${{ github.head_ref }}
- name: Commit fixed code
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "style: resolve style guide violations"
branch: ${{ github.head_ref }}

unit:
runs-on: ubuntu-latest
strategy:
matrix:
# test against the latest update of each major Java version, as well as specific updates of LTS versions:
java: [ 8, 11, 15, 16, 17 ]
java: [8, 11, 15, 16, 17, 18, 19, 20, 21, 22]

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Checkout code
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}

- name: Merge Conflict finder
uses: olivernybroe/[email protected]
- name: Merge Conflict finder
uses: olivernybroe/[email protected]

- name: Use Java Version ${{ matrix.java }}
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: ${{ matrix.java }}
cache: 'gradle'
- name: Use Java Version ${{ matrix.java }}
uses: actions/setup-java@v2
with:
distribution: "zulu"
java-version: ${{ matrix.java }}
cache: "gradle"

- name: Install
run: gradle dependencies
- name: Install
run: gradle dependencies

- name: Test
run: gradle test && gradle jacocoTestReport
- name: Test
run: gradle test && gradle jacocoTestReport

- name: Codecov
run: bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }}
- name: Codecov
run: bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.arkecosystem.client.api;

import org.arkecosystem.client.BaseClientTest;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.util.Map;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.Matchers.hasKey;

@SuppressWarnings("unchecked")
public class ApiNodesIntegrationTest extends BaseClientTest {

@Test
void all() throws IOException {
Map<String, Object> actual = connection.api().apiNodes.all();
assertThat(actual, hasKey("data"));
assertThat(actual, hasKey("meta"));
}

@Test
void allWithParams() throws IOException {
Map<String, Object> actual =
connection.api().apiNodes.param("page", 1).param("limit", 100).all();
assertThat(actual, hasKey("data"));
assertThat(actual, hasKey("meta"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.arkecosystem.client.api;

import org.arkecosystem.client.BaseClientTest;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.util.Map;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasKey;

@SuppressWarnings("unchecked")
public class CommitsIntegrationTest extends BaseClientTest {

@Test
void show() throws IOException {
Map<String, Object> actual = connection.api().commits.show(123456);
assertThat(actual, hasKey("data"));
}
}
55 changes: 0 additions & 55 deletions src/integration/java/org/arkecosystem/client/api/LocksTest.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,36 @@
import java.util.Map;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasEntry;
import static org.hamcrest.Matchers.hasKey;

public class RoundsTest extends BaseClientTest {
public class RoundsIntegrationTest extends BaseClientTest {

@Test
void delegates() throws IOException {
Map<String, Object> actual = connection.api().rounds.delegates(12345);
assertThat(actual, hasKey("data"));
}

@Test
void all() throws IOException {
Map<String, Object> actual = connection.api().rounds.all();
assertThat(actual, hasKey("data"));
assertThat(actual, hasKey("meta"));
}

@Test
void allWithParams() throws IOException {
Map<String, Object> actual =
connection.api().rounds.param("page", 1).param("limit", 100).all();
assertThat(actual, hasKey("data"));
assertThat(actual, hasKey("meta"));
}

@Test
void show() throws IOException {
Map<String, Object> actual = connection.api().rounds.show(12345);
assertThat(actual, hasKey("data"));
assertThat((Map<String, ?>) actual.get("data"), hasEntry("id", 12345.0));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,6 @@ void votesWithParams() throws IOException {
assertThat((Map<String, ?>) actual.get("meta"), hasEntry("count", 3.0));
}

@Test
void locks() throws IOException {
Map<String, Object> actual = connection.api().wallets.locks("D6i8P5N44rFto6M6RALyUXLLs7Q1A1WREW");
logger.info("actual: {}", actual);

assertThat(actual, hasKey("meta"));
assertThat(actual, hasKey("data"));
assertThat((Map<String, ?>) actual.get("meta"), hasEntry("count", 0.0));
}

@Test
void top() throws IOException {
Map<String, Object> actual = connection.api().wallets.top();
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/org/arkecosystem/client/api/Api.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,31 @@
import org.arkecosystem.client.http.Client;

public class Api {

public final Blockchain blockchain;
public final Blocks blocks;
public final Delegates delegates;
public final Entities entities;
public final Locks locks;
public final Node node;
public final Peers peers;
public final Rounds rounds;
public final Transactions transactions;
public final Votes votes;
public final Wallets wallets;
public final ApiNodes apiNodes;
public final Commits commits;

public Api(Client client) {
this.blockchain = new Blockchain(client);
this.blocks = new Blocks(client);
this.delegates = new Delegates(client);
this.entities = new Entities(client);
this.locks = new Locks(client);
this.node = new Node(client);
this.peers = new Peers(client);
this.rounds = new Rounds(client);
this.transactions = new Transactions(client);
this.votes = new Votes(client);
this.wallets = new Wallets(client);
this.apiNodes = new ApiNodes(client);
this.commits = new Commits(client);
}
}
26 changes: 26 additions & 0 deletions src/main/java/org/arkecosystem/client/api/ApiNodes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.arkecosystem.client.api;

import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;
import org.arkecosystem.client.http.Client;

public class ApiNodes implements SupportsParams<ApiNodes> {
private final Client client;

private final Map<String, Object> params = new LinkedHashMap<>();

public ApiNodes(Client client) {
this.client = client;
}

@Override
public ApiNodes param(String name, Object value) {
params.put(name, value);
return this;
}

public Map<String, Object> all() throws IOException {
return this.client.get("api-nodes", params);
}
}
17 changes: 17 additions & 0 deletions src/main/java/org/arkecosystem/client/api/Commits.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.arkecosystem.client.api;

import java.io.IOException;
import java.util.Map;
import org.arkecosystem.client.http.Client;

public class Commits {
private final Client client;

public Commits(Client client) {
this.client = client;
}

public Map<String, Object> show(int height) throws IOException {
return this.client.get("commits/" + height);
}
}
Loading
Loading