Skip to content

Commit f764054

Browse files
authored
feat: rosetta data api and construction validation with rosetta-cli
* test: added test for rosetta cli check:construction and check:data * ci: added github workflow to test roseta-cli:data * ci: add github action for rosetta-cli: construction * refactor: refactor cli tests * fix: use localhoust for github actions in rosetta config file * fix: github actions * fix: rebase issue * refactor: update rosetta-cli env files path * refactor: remove hard coded cli container and use rosetta-cli ouput * perf: remove unnecessary wait of 20 seconds
1 parent 285632a commit f764054

26 files changed

+975
-404
lines changed

.github/workflows/stacks-blockchain-api.yml

+120
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,126 @@ jobs:
266266
uses: codecov/codecov-action@v1
267267
if: always()
268268

269+
test-rosetta-cli-data:
270+
runs-on: ubuntu-latest
271+
steps:
272+
- uses: actions/checkout@v2
273+
274+
- name: Use Node.js
275+
uses: actions/setup-node@v2
276+
with:
277+
node-version: '14'
278+
check-latest: true
279+
280+
- name: Cache node modules
281+
uses: actions/cache@v2
282+
env:
283+
cache-name: cache-node-modules
284+
with:
285+
path: |
286+
~/.npm
287+
node_modules
288+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
289+
restore-keys: |
290+
${{ runner.os }}-build-${{ env.cache-name }}-
291+
${{ runner.os }}-build-
292+
${{ runner.os }}-
293+
294+
- name: Install deps
295+
run: npm install --audit=false
296+
297+
- name: Setup env vars
298+
run: echo "STACKS_CORE_EVENT_HOST=http://0.0.0.0">> $GITHUB_ENV
299+
300+
- name: Setup cli enviroment variable
301+
run: |
302+
echo STACKS_BLOCKCHAIN_API_HOST=0.0.0.0>> .env
303+
echo STACKS_CORE_PROXY_HOST=0.0.0.0 >> .env
304+
echo STACKS_CORE_RPC_HOST=0.0.0.0 >> .env
305+
echo STACKS_CORE_EVENT_HOST=0.0.0.0 >> .env
306+
echo BTC_RPC_HOST=http://0.0.0.0 >> .env
307+
308+
- name: Setup integration environment
309+
run: |
310+
sudo ufw disable
311+
npm run devenv:deploy -- -d
312+
npm run devenv:logs -- --no-color &> docker-compose-logs.txt &
313+
314+
- name: Run tests
315+
run: sudo npm run test:rosetta-cli:data
316+
317+
- name: Print integration environment logs
318+
run: cat docker-compose-logs.txt
319+
if: failure()
320+
321+
- name: Teardown integration environment
322+
run: npm run devenv:stop
323+
if: always()
324+
325+
- name: Upload coverage to Codecov
326+
uses: codecov/codecov-action@v1
327+
if: always()
328+
329+
test-rosetta-cli-construction:
330+
runs-on: ubuntu-latest
331+
steps:
332+
- uses: actions/checkout@v2
333+
334+
- name: Use Node.js
335+
uses: actions/setup-node@v2
336+
with:
337+
node-version: '14'
338+
check-latest: true
339+
340+
- name: Cache node modules
341+
uses: actions/cache@v2
342+
env:
343+
cache-name: cache-node-modules
344+
with:
345+
path: |
346+
~/.npm
347+
node_modules
348+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
349+
restore-keys: |
350+
${{ runner.os }}-build-${{ env.cache-name }}-
351+
${{ runner.os }}-build-
352+
${{ runner.os }}-
353+
354+
- name: Install deps
355+
run: npm install --audit=false
356+
357+
- name: Setup env vars
358+
run: echo "STACKS_CORE_EVENT_HOST=http://0.0.0.0">> $GITHUB_ENV
359+
360+
- name: Setup cli enviroment variable
361+
run: |
362+
echo STACKS_BLOCKCHAIN_API_HOST=0.0.0.0>> .env
363+
echo STACKS_CORE_PROXY_HOST=0.0.0.0 >> .env
364+
echo STACKS_CORE_RPC_HOST=0.0.0.0 >> .env
365+
echo STACKS_CORE_EVENT_HOST=0.0.0.0 >> .env
366+
echo BTC_RPC_HOST=http://0.0.0.0 >> .env
367+
368+
- name: Setup integration environment
369+
run: |
370+
sudo ufw disable
371+
npm run devenv:deploy -- -d
372+
npm run devenv:logs -- --no-color &> docker-compose-logs.txt &
373+
374+
- name: Run tests
375+
run: sudo npm run test:rosetta-cli:construction
376+
377+
- name: Print integration environment logs
378+
run: cat docker-compose-logs.txt
379+
if: failure()
380+
381+
- name: Teardown integration environment
382+
run: npm run devenv:stop
383+
if: always()
384+
385+
- name: Upload coverage to Codecov
386+
uses: codecov/codecov-action@v1
387+
if: always()
388+
269389
test-tokens:
270390
runs-on: ubuntu-latest
271391
steps:

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,7 @@ yarn.lock
126126

127127
# Git info output
128128
.git-info
129+
130+
#rosetta-cli results
131+
rosetta-output-construction/rosetta-cli-output-const.json
132+
rosetta-output/rosetta-cli-output.json

docker-compose.dev.rosetta-construction.yml renamed to docker-compose.dev.rosetta-cli.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@ services:
44
build:
55
context: ./rosetta-cli-config
66
dockerfile: docker/Dockerfile
7-
command: /bin/rosetta-cli --configuration-file /app/rosetta-config-docker.json check:construction
7+
command: ${CMD}
8+
volumes:
9+
- ${OUTPUT}
10+
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
rootDir: 'src',
5+
testMatch: ['<rootDir>/tests-rosetta-cli-construction/**/*.ts'],
6+
testPathIgnorePatterns: ['<rootDir>/tests-rosetta-cli-construction/setup.ts', '<rootDir>/tests-rosetta-cli-construction/teardown.ts'],
7+
collectCoverageFrom: ['<rootDir>/**/*.ts'],
8+
coveragePathIgnorePatterns: ['<rootDir>/tests'],
9+
coverageDirectory: '../coverage',
10+
globalSetup: '<rootDir>/tests-rosetta-cli-construction/setup.ts',
11+
globalTeardown: '<rootDir>/tests-rosetta-cli-construction/teardown.ts',
12+
testTimeout: 180000,
13+
transformIgnorePatterns: [
14+
"node_modules/(?!(@stacks/stacks-transactions)/)"
15+
]
16+
}

jest.config.rosetta-cli-data.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
testEnvironment: 'node',
4+
rootDir: 'src',
5+
testMatch: ['<rootDir>/tests-rosetta-cli-data/**/*.ts'],
6+
testPathIgnorePatterns: ['<rootDir>/tests-rosetta-cli-data/setup.ts', '<rootDir>/tests-rosetta-cli-data/teardown.ts'],
7+
collectCoverageFrom: ['<rootDir>/**/*.ts'],
8+
coveragePathIgnorePatterns: ['<rootDir>/tests'],
9+
coverageDirectory: '../coverage',
10+
globalSetup: '<rootDir>/tests-rosetta-cli-data/setup.ts',
11+
globalTeardown: '<rootDir>/tests-rosetta-cli-data/teardown.ts',
12+
testTimeout: 240000,
13+
transformIgnorePatterns: [
14+
"node_modules/(?!(@stacks/stacks-transactions)/)"
15+
]
16+
};

jest.config.rosetta-cli.js

-16
This file was deleted.

0 commit comments

Comments
 (0)