Skip to content

Commit 9157c20

Browse files
authored
feat: mainsail compatibility and dependency upgrade (#165)
1 parent c9cf27f commit 9157c20

18 files changed

Lines changed: 260 additions & 218 deletions

File tree

.github/workflows/integration-test.yml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,25 @@ on: workflow_dispatch
55
jobs:
66
integration:
77
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
java: [8, 11, 15, 16, 17, 18, 19, 20, 21, 22]
811

912
steps:
10-
- uses: actions/checkout@v2
13+
- name: Checkout code
14+
uses: actions/checkout@v2
1115

12-
- name: Use Java Version 8
13-
uses: actions/setup-java@v1
14-
with:
15-
java-version: 8
16+
- name: Use Java Version ${{ matrix.java }}
17+
uses: actions/setup-java@v2
18+
with:
19+
distribution: "zulu"
20+
java-version: ${{ matrix.java }}
21+
cache: "gradle"
1622

17-
- name: Install
18-
run: gradle dependencies
23+
- name: Install
24+
run: gradle dependencies
1925

20-
- name: Test
21-
run: gradle integrationTest
22-
env:
23-
INTEGRATION_TESTS_MNEMONIC: ${{ secrets.MNEMONIC }}
26+
- name: Test
27+
run: gradle integrationTest
28+
env:
29+
INTEGRATION_TESTS_MNEMONIC: ${{ secrets.MNEMONIC }}

.github/workflows/test.yml

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,65 +6,65 @@ on:
66
- "master"
77
- "develop"
88
pull_request:
9-
types: [ ready_for_review, synchronize, opened ]
9+
types: [ready_for_review, synchronize, opened]
1010

1111
jobs:
1212
format:
1313
runs-on: ubuntu-latest
1414

1515
steps:
16-
- name: Checkout code
17-
uses: actions/checkout@v2
18-
with:
19-
ref: ${{ github.head_ref }}
16+
- name: Checkout code
17+
uses: actions/checkout@v2
18+
with:
19+
ref: ${{ github.head_ref }}
2020

21-
- name: Merge Conflict finder
22-
uses: olivernybroe/action-conflict-finder@v1.1
21+
- name: Merge Conflict finder
22+
uses: olivernybroe/action-conflict-finder@v1.1
2323

24-
- name: Use Java Version 8
25-
uses: actions/setup-java@v2
26-
with:
27-
distribution: 'adopt'
28-
java-version: 8
29-
cache: 'gradle'
24+
- name: Use Java Version 8
25+
uses: actions/setup-java@v2
26+
with:
27+
distribution: "adopt"
28+
java-version: 8
29+
cache: "gradle"
3030

31-
- name: Format code
32-
run: gradle format
31+
- name: Format code
32+
run: gradle format
3333

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

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

4747
steps:
48-
- name: Checkout code
49-
uses: actions/checkout@v2
50-
with:
51-
ref: ${{ github.head_ref }}
48+
- name: Checkout code
49+
uses: actions/checkout@v2
50+
with:
51+
ref: ${{ github.head_ref }}
5252

53-
- name: Merge Conflict finder
54-
uses: olivernybroe/action-conflict-finder@v1.1
53+
- name: Merge Conflict finder
54+
uses: olivernybroe/action-conflict-finder@v1.1
5555

56-
- name: Use Java Version ${{ matrix.java }}
57-
uses: actions/setup-java@v2
58-
with:
59-
distribution: 'zulu'
60-
java-version: ${{ matrix.java }}
61-
cache: 'gradle'
56+
- name: Use Java Version ${{ matrix.java }}
57+
uses: actions/setup-java@v2
58+
with:
59+
distribution: "zulu"
60+
java-version: ${{ matrix.java }}
61+
cache: "gradle"
6262

63-
- name: Install
64-
run: gradle dependencies
63+
- name: Install
64+
run: gradle dependencies
6565

66-
- name: Test
67-
run: gradle test && gradle jacocoTestReport
66+
- name: Test
67+
run: gradle test && gradle jacocoTestReport
6868

69-
- name: Codecov
70-
run: bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }}
69+
- name: Codecov
70+
run: bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package org.arkecosystem.client.api;
2+
3+
import org.arkecosystem.client.BaseClientTest;
4+
import org.junit.jupiter.api.Test;
5+
6+
import java.io.IOException;
7+
import java.util.Map;
8+
9+
import static org.hamcrest.MatcherAssert.assertThat;
10+
import static org.hamcrest.Matchers.hasEntry;
11+
import static org.hamcrest.Matchers.hasKey;
12+
13+
@SuppressWarnings("unchecked")
14+
public class ApiNodesIntegrationTest extends BaseClientTest {
15+
16+
@Test
17+
void all() throws IOException {
18+
Map<String, Object> actual = connection.api().apiNodes.all();
19+
assertThat(actual, hasKey("data"));
20+
assertThat(actual, hasKey("meta"));
21+
}
22+
23+
@Test
24+
void allWithParams() throws IOException {
25+
Map<String, Object> actual =
26+
connection.api().apiNodes.param("page", 1).param("limit", 100).all();
27+
assertThat(actual, hasKey("data"));
28+
assertThat(actual, hasKey("meta"));
29+
}
30+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.arkecosystem.client.api;
2+
3+
import org.arkecosystem.client.BaseClientTest;
4+
import org.junit.jupiter.api.Test;
5+
6+
import java.io.IOException;
7+
import java.util.Map;
8+
9+
import static org.hamcrest.MatcherAssert.assertThat;
10+
import static org.hamcrest.Matchers.hasKey;
11+
12+
@SuppressWarnings("unchecked")
13+
public class CommitsIntegrationTest extends BaseClientTest {
14+
15+
@Test
16+
void show() throws IOException {
17+
Map<String, Object> actual = connection.api().commits.show(123456);
18+
assertThat(actual, hasKey("data"));
19+
}
20+
}

src/integration/java/org/arkecosystem/client/api/LocksTest.java

Lines changed: 0 additions & 55 deletions
This file was deleted.

src/integration/java/org/arkecosystem/client/api/RoundsTest.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,36 @@
77
import java.util.Map;
88

99
import static org.hamcrest.MatcherAssert.assertThat;
10+
import static org.hamcrest.Matchers.hasEntry;
1011
import static org.hamcrest.Matchers.hasKey;
1112

12-
public class RoundsTest extends BaseClientTest {
13+
public class RoundsIntegrationTest extends BaseClientTest {
1314

1415
@Test
1516
void delegates() throws IOException {
1617
Map<String, Object> actual = connection.api().rounds.delegates(12345);
1718
assertThat(actual, hasKey("data"));
1819
}
20+
21+
@Test
22+
void all() throws IOException {
23+
Map<String, Object> actual = connection.api().rounds.all();
24+
assertThat(actual, hasKey("data"));
25+
assertThat(actual, hasKey("meta"));
26+
}
27+
28+
@Test
29+
void allWithParams() throws IOException {
30+
Map<String, Object> actual =
31+
connection.api().rounds.param("page", 1).param("limit", 100).all();
32+
assertThat(actual, hasKey("data"));
33+
assertThat(actual, hasKey("meta"));
34+
}
35+
36+
@Test
37+
void show() throws IOException {
38+
Map<String, Object> actual = connection.api().rounds.show(12345);
39+
assertThat(actual, hasKey("data"));
40+
assertThat((Map<String, ?>) actual.get("data"), hasEntry("id", 12345.0));
41+
}
1942
}

src/integration/java/org/arkecosystem/client/api/WalletsTest.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,16 +130,6 @@ void votesWithParams() throws IOException {
130130
assertThat((Map<String, ?>) actual.get("meta"), hasEntry("count", 3.0));
131131
}
132132

133-
@Test
134-
void locks() throws IOException {
135-
Map<String, Object> actual = connection.api().wallets.locks("D6i8P5N44rFto6M6RALyUXLLs7Q1A1WREW");
136-
logger.info("actual: {}", actual);
137-
138-
assertThat(actual, hasKey("meta"));
139-
assertThat(actual, hasKey("data"));
140-
assertThat((Map<String, ?>) actual.get("meta"), hasEntry("count", 0.0));
141-
}
142-
143133
@Test
144134
void top() throws IOException {
145135
Map<String, Object> actual = connection.api().wallets.top();

src/main/java/org/arkecosystem/client/api/Api.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,31 @@
33
import org.arkecosystem.client.http.Client;
44

55
public class Api {
6-
76
public final Blockchain blockchain;
87
public final Blocks blocks;
98
public final Delegates delegates;
109
public final Entities entities;
11-
public final Locks locks;
1210
public final Node node;
1311
public final Peers peers;
1412
public final Rounds rounds;
1513
public final Transactions transactions;
1614
public final Votes votes;
1715
public final Wallets wallets;
16+
public final ApiNodes apiNodes;
17+
public final Commits commits;
1818

1919
public Api(Client client) {
2020
this.blockchain = new Blockchain(client);
2121
this.blocks = new Blocks(client);
2222
this.delegates = new Delegates(client);
2323
this.entities = new Entities(client);
24-
this.locks = new Locks(client);
2524
this.node = new Node(client);
2625
this.peers = new Peers(client);
2726
this.rounds = new Rounds(client);
2827
this.transactions = new Transactions(client);
2928
this.votes = new Votes(client);
3029
this.wallets = new Wallets(client);
30+
this.apiNodes = new ApiNodes(client);
31+
this.commits = new Commits(client);
3132
}
3233
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package org.arkecosystem.client.api;
2+
3+
import java.io.IOException;
4+
import java.util.LinkedHashMap;
5+
import java.util.Map;
6+
import org.arkecosystem.client.http.Client;
7+
8+
public class ApiNodes implements SupportsParams<ApiNodes> {
9+
private final Client client;
10+
11+
private final Map<String, Object> params = new LinkedHashMap<>();
12+
13+
public ApiNodes(Client client) {
14+
this.client = client;
15+
}
16+
17+
@Override
18+
public ApiNodes param(String name, Object value) {
19+
params.put(name, value);
20+
return this;
21+
}
22+
23+
public Map<String, Object> all() throws IOException {
24+
return this.client.get("api-nodes", params);
25+
}
26+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.arkecosystem.client.api;
2+
3+
import java.io.IOException;
4+
import java.util.Map;
5+
import org.arkecosystem.client.http.Client;
6+
7+
public class Commits {
8+
private final Client client;
9+
10+
public Commits(Client client) {
11+
this.client = client;
12+
}
13+
14+
public Map<String, Object> show(int height) throws IOException {
15+
return this.client.get("commits/" + height);
16+
}
17+
}

0 commit comments

Comments
 (0)