Skip to content
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
75 changes: 75 additions & 0 deletions .github/workflows/check-package-lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
name: Check Package Lock File

permissions:
contents: read

concurrency:
group: check-package-lock-${{ github.ref }}
cancel-in-progress: true

on:
push:
branches:
- main
pull_request:
branches:
- "**"

jobs:
verify-package-lock:
name: Verify package-lock.json
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Check if package.json dependencies were changed
id: check-changes
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE_SHA="${{ github.event.pull_request.base.sha }}"
else
BASE_SHA="${{ github.event.before }}"
fi

if ! git diff --name-only "$BASE_SHA" HEAD | grep -q '^package\.json$'; then
echo "package_json_changed=false" >> "$GITHUB_OUTPUT"
echo "package.json was NOT changed, skipping lock file validation"
exit 0
fi

echo "package_json_changed=true" >> "$GITHUB_OUTPUT"
echo "package.json was changed, will validate lock file"

- name: Check if package-lock.json exists
run: |
if [ ! -f "package-lock.json" ]; then
echo "ERROR: package-lock.json file is missing from the repository"
echo "This file is required to ensure consistent dependency versions across all environments"
echo "Please ensure package-lock.json is committed with your changes"
exit 1
fi
echo "SUCCESS: package-lock.json file is present"

- name: Verify package-lock.json is not empty
run: |
if [ ! -s "package-lock.json" ]; then
echo "ERROR: package-lock.json file exists but is empty"
echo "Please run 'npm install' to regenerate the lock file"
exit 1
fi
echo "SUCCESS: package-lock.json file is valid and not empty"

- name: Setup Node.js
if: steps.check-changes.outputs.package_json_changed == 'true'
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Validate package-lock.json is in sync
if: steps.check-changes.outputs.package_json_changed == 'true'
run: npm ci --dry-run --ignore-scripts
125 changes: 97 additions & 28 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:
branches:
- '**'

permissions:
contents: read

env:
REPOSITORY_PASSWORD: password
JWT_SECRET: aTx13FzDG+85j9b5s2G7IBEc5SJNJZZLPLe7RF8hu1xKgRKj46YFRx/z7fJi7iF2NnL7SHcxTzq7TySuPKWkdg/AYKEMD2p1I++qPYFHqg8KQeLArGjCYiqtf43i1Fgtya8z9qJXyegogMz/jYori2BJ8v6b4K3GkAw3XxiO7VaaEYktOp8qsRDcN3b+bITMZqztDvZdWp4EnViGjoES7fRFhKm/d/2C8URnQyGm6xgTR3xTfAjy7+milGmoPA0KU0nu+GsZIhOfeVc9Z2nfxOK/1JQykpjeBhNDYTOr31yW/xdvoW0Kq0PZ6JmM+yezLoyQXcYjavZ+X7cXjbREQg==
Expand All @@ -28,52 +31,118 @@ jobs:
- name: Run linter
run: npm run lint

# unit-tests:
# runs-on: ubuntu-latest
# services:
# graphdb:
# image: khaller/graphdb-free:latest
# ports:
# - 7200:7200
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
bdd-smoke:
if: github.event_name == 'push'
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: operationaldb
MYSQL_USER: node
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: password
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
redis:
image: redis:7
ports:
- 6379:6379
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up environment
uses: ./.github/actions/setup

- name: Start Blazegraph
run: /usr/bin/java -Djava.awt.headless=true -jar blazegraph.jar &

# - name: Set up environment
# uses: ./.github/actions/setup
- name: Wait for Blazegraph
run: |
for i in $(seq 1 30); do
if curl -sf http://localhost:9999/blazegraph/status > /dev/null; then
echo "Blazegraph is ready"
exit 0
fi
sleep 2
done
echo "Blazegraph did not start in time"
exit 1

# - name: Run unit tests
# run: npm run test:unit
- name: Run BDD smoke tests
run: |
npx cucumber-js \
--config cucumber.js \
--tags "@smoke" \
--format progress \
test/bdd/ \
--import test/bdd/steps/ \
--exit

- name: Upload log files
if: '!cancelled()'
uses: actions/upload-artifact@v4
with:
name: bdd-smoke-logs
path: ./test/bdd/log/

bdd-tests:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
services:
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: operationaldb
MYSQL_USER: node
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: password
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: operationaldb
MYSQL_USER: node
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: password
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
redis:
image: redis:7
ports:
- 6379:6379
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up environment
uses: ./.github/actions/setup

- name: Run Blazegraph
- name: Start Blazegraph
run: /usr/bin/java -Djava.awt.headless=true -jar blazegraph.jar &

- name: Run BDD tests
run: npm run test:bdd
- name: Wait for Blazegraph
run: |
for i in $(seq 1 30); do
if curl -sf http://localhost:9999/blazegraph/status > /dev/null; then
echo "Blazegraph is ready"
exit 0
fi
sleep 2
done
echo "Blazegraph did not start in time"
exit 1

- name: Run full BDD tests
run: |
npx cucumber-js \
--config cucumber.js \
--tags "not @ignore" \
--format progress \
test/bdd/ \
--import test/bdd/steps/ \
--exit

- name: Upload log files
if: '!cancelled()'
uses: actions/upload-artifact@v4
with:
name: bdd-test-logs
name: bdd-tests-logs
path: ./test/bdd/log/
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,6 @@ ignition/deployments/chain-31337

# Redis
dump.rdb

# Blazegraph journal files
*.jnl
2 changes: 1 addition & 1 deletion cucumber.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default {
retry: 1,
failFast: true,
failFast: false,
backtrace: true,
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"start:local_blockchain:v1": "npm explore dkg-evm-module -- npm run dev:v1 -- --port",
"start:local_blockchain:v2": "npm explore dkg-evm-module -- npm run dev:v2 -- --port",
"kill:local_blockchain": "npx kill-port --port",
"test:bdd": "cucumber-js --config cucumber.js --tags \"not @ignore\" --format progress --format-options '{\"colorsEnabled\": true}' test/bdd/ --import test/bdd/steps/ --exit",
"test:bdd": "bash test/bdd/run-bdd.sh",
"test:unit": "nyc --all mocha --exit $(find test/unit -name '*.js')",
"test:modules": "nyc --all mocha --exit $(find test/unit/modules -name '*.js')",
"test:bdd:release": "cucumber-js --tags=@release --fail-fast --format progress --format-options '{\"colorsEnabled\": true}' test/bdd/ --import test/bdd/steps/",
Expand Down
43 changes: 11 additions & 32 deletions test/bdd/features/bid-suggestion.feature
Original file line number Diff line number Diff line change
@@ -1,37 +1,16 @@
Feature: Release related tests
@ignore
Feature: Bid suggestion tests
# @ignore: dkg.js SDK removed network.getBidSuggestion() and assertion.getSizeInBytes()
# in v8. Re-enable once the SDK exposes a bid-suggestion API again.

Background: Setup local blockchain, bootstraps and nodes
Given the blockchains are set up
And 1 bootstrap is running

@ignore
Scenario: Get bid suggestion with a valid assertion and valid hashFunctionId and scoreFunctionId on both blockchains
Given I set R0 to be 1 on blockchain hardhat1:31337
And I set R1 to be 2 on blockchain hardhat1:31337
And I set R0 to be 1 on blockchain hardhat2:31337
And I set R1 to be 2 on blockchain hardhat2:31337
And I setup 4 nodes
And I wait for 5 seconds

When I call Get Bid Suggestion on the node 2 with validPublish_1ForValidUpdate_1 on blockchain hardhat1:31337
Then I call Info route on the node 2

When I call Get Bid Suggestion on the node 2 with validPublish_1ForValidUpdate_1 on blockchain hardhat2:31337
Then I call Info route on the node 2
@bid-suggestion
Scenario: Get bid suggestion with a valid assertion
And I setup 2 additional nodes
And I wait for 15 seconds

When I call Get Bid Suggestion on node 2 using parameters validPublish_1ForValidUpdate_1, hashFunctionId 1, scoreFunctionId 1, within blockchain hardhat1:31337
Then I call Info route on the node 2

When I call Get Bid Suggestion on node 2 using parameters validPublish_1ForValidUpdate_1, hashFunctionId 1, scoreFunctionId 1, within blockchain hardhat2:31337
Then I call Info route on the node 2

When I call Get Bid Suggestion on node 2 using parameters validPublish_1ForValidUpdate_1, hashFunctionId 1, scoreFunctionId 2, within blockchain hardhat1:31337
Then I call Info route on the node 2

When I call Get Bid Suggestion on node 2 using parameters validPublish_1ForValidUpdate_1, hashFunctionId 1, scoreFunctionId 2, within blockchain hardhat2:31337
Then I call Info route on the node 2

When I call Get Bid Suggestion on node 2 using parameters validPublish_1ForValidUpdate_1, hashFunctionId 1, scoreFunctionId 4, within blockchain hardhat1:31337
Then I call Info route on the node 2

When I call Get Bid Suggestion on node 2 using parameters validPublish_1ForValidUpdate_1, hashFunctionId 1, scoreFunctionId 4, within blockchain hardhat2:31337
Then I call Info route on the node 2
When I call Get Bid Suggestion on the node 1 with validPublish_1ForValidUpdate_1 on blockchain hardhat1:31337
Then I call Info route on the node 1
48 changes: 11 additions & 37 deletions test/bdd/features/get-errors.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,21 @@ Feature: Get errors test

@ignore
Scenario: Getting non-existent UAL
Given I setup 4 nodes
And I wait for 5 seconds
# @ignore: A validly-formatted but non-existent UAL causes the node's get
# operation to stay IN_PROGRESS indefinitely while it searches the network.
# The operation never reaches a terminal status, so polling times out.
And I setup 1 additional node
And I wait for 15 seconds

When I call Get directly on the node 1 with nonExistentUAL on blockchain hardhat1:31337
And I wait for latest resolve to finalize
Then Latest Get operation finished with status: GetRouteError
And I wait for latest Get to finalize
Then Latest Get operation finished with status: FAILED

@ignore
@get-error
Scenario: Getting invalid UAL
Given I setup 4 nodes
And I wait for 5 seconds
And I setup 1 additional node
And I wait for 15 seconds

When I call Get directly on the node 1 with invalidUAL on blockchain hardhat1:31337
And I wait for latest resolve to finalize
And I wait for latest Get to finalize
Then Latest Get operation finished with status: GetRouteError

@ignore
Scenario: Getting non-existent state
Given I setup 4 nodes
And I set R0 to be 1 on blockchain hardhat1:31337
And I set R1 to be 2 on blockchain hardhat1:31337
And I set R0 to be 1 on blockchain hardhat2:31337
And I set R1 to be 2 on blockchain hardhat2:31337
And I wait for 5 seconds

When I call Publish on the node 1 with validAssertion on blockchain hardhat1:31337
And I wait for latest Publish to finalize
And I call Get directly on the node 1 with nonExistentState on blockchain hardhat1:31337
Then It should fail with status code 400

@ignore
Scenario: Getting invalid state hash
Given I setup 4 nodes
And I set R0 to be 1 on blockchain hardhat1:31337
And I set R1 to be 2 on blockchain hardhat1:31337
And I set R0 to be 1 on blockchain hardhat2:31337
And I set R1 to be 2 on blockchain hardhat2:31337
And I wait for 5 seconds

When I call Publish on the node 1 with validAssertion on blockchain hardhat1:31337
And I wait for latest Publish to finalize
And I call Get directly on the node 1 with invalidStateHash on blockchain hardhat1:31337
And I wait for latest resolve to finalize
Then Latest Get operation finished with status: GetAssertionIdError
Loading
Loading