Skip to content

Commit

Permalink
Merge pull request #244 from /issues/243
Browse files Browse the repository at this point in the history
issues/243 - Refactor integration tests to use mocked node.
  • Loading branch information
cnorburn authored Feb 13, 2024
2 parents 8f628e3 + ec0d4bf commit 2b4e737
Show file tree
Hide file tree
Showing 30 changed files with 245,435 additions and 278 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/generate-jekyll-pages-for-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: generate-jekyll-pages-for-docs

on:
workflow_run:
workflows: [ update-gh-pages ]
workflows: [ test-and-build ]
branches: [ main ]
types: [ completed ]

Expand All @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4.1.1
with:
ref: gh-pages
fetch-depth: 0
Expand All @@ -24,4 +24,4 @@ jobs:
SOURCE_INDEX_FILE: README.md

- name: Commit changes
uses: EndBug/add-and-commit@v8.0.1
uses: EndBug/add-and-commit@v9.1.4
10 changes: 5 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4.1.1

- name: Set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'adopt'
Expand All @@ -27,15 +27,15 @@ jobs:
run: chmod +x gradlew

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
uses: gradle/wrapper-validation-action@v2.1.0

- name: Publish package
uses: gradle/gradle-build-action@v2
uses: gradle/gradle-build-action@v3
with:
arguments: publish closeAndReleaseStagingRepository
env:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}
GPG_SIGNING_KEY_PASSWORD: ${{ secrets.GPG_SIGNING_KEY_PASSWORD }}
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will build a Java project with Gradle
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle

name: Java CI with Gradle
name: Java SDK test and build

on:
push:
Expand All @@ -13,93 +13,71 @@ on:
jobs:
build:
runs-on: ubuntu-latest
services:
nctl:
image: stormeye2000/cspr-nctl:1.5
options: --name cspr-nctl
env:
PREDEFINED_ACCOUNTS: 'true'
MINIMUM_ROUND_EXPONENT: '12'
MAXIMUM_ROUND_EXPONENT: '14'
DEPLOY_DELAY: '30sec'
SPECULATIVE_EXEC_SERVER_ENABLED: 'true'
ports:
- 11101:11101
- 14101:14101
- 18101:18101
- 25101:25101
steps:
- name: Wait for NCTL
run: |
echo "Wait for NCTL"
sleep 30s

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4.1.1

- name: Set up JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'adopt'

- name: Grant execute permission for gradlew
run: chmod +x gradlew

# Copy the assets from the NCTL docker image and build
- name: Build and test with Gradle
run: |
cd sh && chmod +x docker-copy-assets.sh && ./docker-copy-assets.sh && cd ..
./gradlew clean build
- name: Export project version
- name: run the unit tests
run: ./gradlew clean build -x javadoc

- name: export project version
run: echo "PROJECT_VERSION=$(./gradlew properties -q | grep "version:" | awk '{print $2}')" >> $GITHUB_ENV

- name: Generate Javadoc
- name: generate javadoc
run: ./gradlew javadoc

- name: Deploy tests results to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4.2.2
- name: deploy tests results to github pages
uses: jamesives/github-pages-deploy-action@v4.2.2
with:
branch: gh-pages
clean: true
folder: build/reports/tests
target-folder: docs/latest/junit

- name: Deploy jacoco report to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4.2.2
- name: deploy jacoco report to github pages
uses: jamesives/github-pages-deploy-action@v4.5.0
with:
branch: gh-pages
clean: true
folder: build/reports/jacoco
target-folder: docs/latest/jacoco

- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4.2.2
- name: deploy to github pages
uses: jamesives/github-pages-deploy-action@v4.5.0
with:
branch: gh-pages
clean: true
folder: build/docs/javadoc
target-folder: docs/latest/javadoc

- name: Deploy tests results to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4.2.2
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
branch: gh-pages
clean: true
folder: build/reports/tests
target-folder: docs/${{ env.PROJECT_VERSION }}/junit

- name: Deploy jacoco report to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4.2.2
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
branch: gh-pages
clean: true
folder: build/reports/jacoco
target-folder: docs/${{ env.PROJECT_VERSION }}/jacoco

- name: Deploy to GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4.2.2
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
branch: gh-pages
clean: true
Expand Down
113 changes: 0 additions & 113 deletions .github/workflows/update-gh-pages.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
HELP.md
.gradle
assets/
build/
src/test/resources/deploy-accounts/nctl
!gradle/wrapper/gradle-wrapper.jar
Expand Down
11 changes: 11 additions & 0 deletions script/docker-copy-assets
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
BASEDIR=$(builtin cd .. || exit 1; pwd)
# clear the assets folder
rm -rf "${BASEDIR}/assets"
mkdir "${BASEDIR}/assets"
# copy net-1 users
docker cp cspr-nctl:/home/casper/casper-node/utils/nctl/assets/net-1/users "${BASEDIR}/assets/net-1"
# copy net-1 chainspec
docker cp cspr-nctl:/home/casper/casper-node/utils/nctl/assets/net-1/chainspec "${BASEDIR}/assets/net-1"
# copy faucet keys
docker cp cspr-nctl:/home/casper/casper-node/utils/nctl/assets/net-1/faucet "${BASEDIR}/assets/net-1"
3 changes: 3 additions & 0 deletions script/docker-run
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
# run the cspr-nctl container in docker
docker run --rm -it --name cspr-nctl -d -p 25101:25101 -p 11101:11101 -p 14101:14101 -p 18101:18101 stormeye2000/cspr-nctl:linux-1.5.5
6 changes: 0 additions & 6 deletions sh/docker-copy-assets.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import com.syntifi.crypto.key.Ed25519PrivateKey;
import dev.oak3.sbs4j.exception.ValueSerializationException;
import org.bouncycastle.util.encoders.Hex;
import org.junit.Ignore;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -33,6 +35,7 @@
* @author Andre Bertolace
* @since 0.2.0
*/
@Disabled
public class CasperTransferHelperTests extends AbstractJsonRpcTests {
private static final Logger LOGGER = LoggerFactory.getLogger(CasperTransferHelperTests.class);

Expand Down
10 changes: 9 additions & 1 deletion src/test/java/com/casper/sdk/service/AbstractJsonRpcTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.junit.jupiter.api.BeforeAll;

import java.net.MalformedURLException;
import java.net.URI;

/**
* Abstract class for testing json rpc methods
Expand All @@ -23,16 +24,22 @@ public enum CasperNetwork {
MAIN_NET("65.109.54.159", 7777),
TEST_NET("85.114.132.133", 7777),
NCTL("127.0.0.1", 11101),
NCTL_SPECULATIVE("127.0.0.1", 25101);
NCTL_SPECULATIVE("127.0.0.1", 25101),
MOCK("localhost", 7777);

private final String ip;
private final int port;

public URI getUri() {
return URI.create("http://" + ip + ":" + port);
}
}

protected static CasperService casperServiceMainnet;
protected static CasperService casperServiceTestnet;
protected static CasperService casperServiceNctl;
protected static CasperService speculativeCasperServiceNctl;
protected static CasperService casperServiceMock;

@BeforeAll
public static void setUp() throws MalformedURLException {
Expand All @@ -44,5 +51,6 @@ public static void setUp() throws MalformedURLException {
CasperNetwork.NCTL.getPort());
speculativeCasperServiceNctl = CasperService.usingPeer(CasperNetwork.NCTL_SPECULATIVE.getIp(),
CasperNetwork.NCTL_SPECULATIVE.getPort());
casperServiceMock = CasperService.usingPeer(CasperNetwork.MOCK.ip, CasperNetwork.MOCK.port);
}
}
Loading

0 comments on commit 2b4e737

Please sign in to comment.