Compare commits

...
Author SHA1 Message Date
dboreham a633a16705 Test with Node.js version 19 2023-02-17 08:35:14 -07:00
Michael 2870a7543a version bump to 0.1.6 (#31) 2023-02-15 10:23:49 -05:00
Michael 77af2e5e22 Auction nameservice tests (#28)
* truncated testing until questions of intent answered

* nameservice passes local tests

* first pass running tests from sdk side

* lint cleanup

* move into dir rather than args

* double bond in naming test

* first pass building test container on sdk side... only basic tests this iteration

* missing jest

* docker compose exec got dropped

* start both containers, not just laconicd

* script cleanup in action

* working directory

* diagnostic

* diagnostic

* run against dev branch of laconicd

* run auction and nameservice-expiry tests

* switch to main branch
2023-02-10 14:44:23 -05:00
Michael 663ebbf8e0 Merge pull request #30 from cerc-io/readme_quick
quick README update to reflect reality
2023-02-06 12:48:21 -05:00
Michael Shaw c6a37ac419 quick README update to reflect reality 2023-02-06 12:47:29 -05:00
Ian Norden 80348594f8 Merge pull request #20 from cerc-io/zramsay-patch-1
remove duplicate line in tests
2023-01-12 18:59:34 -06:00
Zach 55675c7b55 rm duplicate line (typo?) 2023-01-11 18:27:00 -05:00
Zach 10d58ca028 Merge pull request #19 from cerc-io/ian/bump_version
Update package to 0.1.5
2023-01-11 17:02:56 -05:00
i-norden 95bdacb4a1 version 0.1.5 2023-01-11 15:48:24 -06:00
9 changed files with 143 additions and 13 deletions
+72
View File
@@ -0,0 +1,72 @@
name: Tests
on:
pull_request:
push:
branches:
- main
- release/**
jobs:
sdk_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout laconicd
uses: actions/checkout@v3
with:
path: "./laconicd/"
repository: cerc-io/laconicd
fetch-depth: 0
ref: main
- name: Environment
run: ls -tlh && env
- name: build containers scripts
working-directory: laconicd/tests/sdk_tests
run: ./build-laconicd-container.sh
- name: build test-container
run: docker build -t cerc-io/laconic-sdk-tester:local-test --build-arg VARIANT=19-bullseye -f laconicd/tests/sdk_tests/Dockerfile-sdk .
- name: start containers
working-directory: laconicd/tests/sdk_tests
run: docker compose up -d
- name: run basic tests
working-directory: laconicd/tests/sdk_tests
run: |
laconicd_key=$( docker compose exec laconicd echo y | docker compose exec laconicd laconicd keys export mykey --unarmored-hex --unsafe )
cosmos_chain_id=laconic_9000-1
laconicd_rest_endpoint=http://laconicd:1317
laconicd_gql_endpoint=http://laconicd:9473/api
sleep 30s
docker compose exec sdk-test-runner sh -c "COSMOS_CHAIN_ID=${cosmos_chain_id} LACONICD_REST_ENDPOINT=${laconicd_rest_endpoint} LACONICD_GQL_ENDPOINT=${laconicd_gql_endpoint} PRIVATE_KEY=${laconicd_key} yarn test"
- name: stop containers
working-directory: laconicd/tests/sdk_tests
run: docker compose down
- name: start auction containers
working-directory: laconicd/tests/sdk_tests
run: docker compose -f docker-compose-auctions.yml up -d
- name: run auction tests
working-directory: laconicd/tests/sdk_tests
run: |
laconicd_key=$( docker compose exec laconicd echo y | docker compose exec laconicd laconicd keys export mykey --unarmored-hex --unsafe )
cosmos_chain_id=laconic_9000-1
laconicd_rest_endpoint=http://laconicd:1317
laconicd_gql_endpoint=http://laconicd:9473/api
sleep 30s
docker compose exec sdk-test-runner sh -c "COSMOS_CHAIN_ID=${cosmos_chain_id} LACONICD_REST_ENDPOINT=${laconicd_rest_endpoint} LACONICD_GQL_ENDPOINT=${laconicd_gql_endpoint} PRIVATE_KEY=${laconicd_key} yarn test:auctions"
- name: start containers
working-directory: laconicd/tests/sdk_tests
run: docker compose down
- name: start containers
working-directory: laconicd/tests/sdk_tests
run: docker compose -f docker-compose-nameservice.yml up -d
- name: run nameservice expiry tests
working-directory: laconicd/tests/sdk_tests
run: |
laconicd_key=$( docker compose exec laconicd echo y | docker compose exec laconicd laconicd keys export mykey --unarmored-hex --unsafe )
cosmos_chain_id=laconic_9000-1
laconicd_rest_endpoint=http://laconicd:1317
laconicd_gql_endpoint=http://laconicd:9473/api
sleep 30s
docker compose exec sdk-test-runner sh -c "COSMOS_CHAIN_ID=${cosmos_chain_id} LACONICD_REST_ENDPOINT=${laconicd_rest_endpoint} LACONICD_GQL_ENDPOINT=${laconicd_gql_endpoint} PRIVATE_KEY=${laconicd_key} yarn test:nameservice-expiry"
- name: stop nameservice containers
working-directory: laconicd/tests/sdk_tests
run: docker compose down
+1
View File
@@ -1,3 +1,4 @@
node_modules
dist
.env
.idea*
+54
View File
@@ -0,0 +1,54 @@
# Originally from: https://github.com/devcontainers/images/blob/main/src/javascript-node/.devcontainer/Dockerfile
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster
ARG VARIANT=16-bullseye
FROM node:${VARIANT}
ARG USERNAME=node
ARG NPM_GLOBAL=/usr/local/share/npm-global
# Add NPM global to PATH.
ENV PATH=${NPM_GLOBAL}/bin:${PATH}
RUN \
# Configure global npm install location, use group to adapt to UID/GID changes
if ! cat /etc/group | grep -e "^npm:" > /dev/null 2>&1; then groupadd -r npm; fi \
&& usermod -a -G npm ${USERNAME} \
&& umask 0002 \
&& mkdir -p ${NPM_GLOBAL} \
&& touch /usr/local/etc/npmrc \
&& chown ${USERNAME}:npm ${NPM_GLOBAL} /usr/local/etc/npmrc \
&& chmod g+s ${NPM_GLOBAL} \
&& npm config -g set prefix ${NPM_GLOBAL} \
&& su ${USERNAME} -c "npm config -g set prefix ${NPM_GLOBAL}" \
# Install eslint
&& su ${USERNAME} -c "umask 0002 && npm install -g eslint lerna jest" \
&& npm cache clean --force > /dev/null 2>&1
# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
# [Optional] Uncomment if you want to install an additional version of node using nvm
# ARG EXTRA_NODE_VERSION=10
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
# [Optional] Uncomment if you want to install more global node modules
# RUN su node -c "npm install -g <your-package-list-here>"
WORKDIR /
RUN mkdir node_modules && mkdir proto && mkdir scripts && mkdir src
COPY node_modules ./node_modules/
COPY proto . ./proto/
COPY scripts ./scripts/
COPY src ./src/
COPY entrypoint.sh .
ENTRYPOINT ["/entrypoint.sh"]
# Placeholder CMD : generally this will be overridden at run time like :
# docker run -it -v /home/builder/cerc/laconic-sdk:/workspace cerc/builder-js sh -c 'cd /workspace && yarn && yarn build'
CMD node --version
# Temp hack, clone the laconic-sdk repo here
WORKDIR /app
RUN yarn install
WORKDIR /app/laconic-sdk
+1 -1
View File
@@ -57,7 +57,7 @@ Follow these steps to run the tests:
- In laconicd repo run:
```bash
TEST_NAMESERVICE_EXPIRY=true ./init.sh
TEST_REGISTRY_EXPIRY=true ./init.sh
```
- Export the private key and change it in `.env` file again using:
Executable
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
exec "$@"
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@cerc-io/laconic-sdk",
"version": "0.1.4",
"version": "0.1.6",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": "git@github.com:cerc-io/laconic-sdk.git",
+9 -8
View File
@@ -30,7 +30,7 @@ const nameserviceExpiryTests = () => {
test('Set record and check bond balance', async () => {
// Create watcher.
watcher = await ensureUpdatedConfig(WATCHER_YML_PATH);
await registry.setRecord(
const result = await registry.setRecord(
{
privateKey,
bondId,
@@ -39,8 +39,8 @@ const nameserviceExpiryTests = () => {
privateKey,
fee
)
const [record] = await registry.queryRecords({ type: 'watcher', version: watcher.record.version }, true);
console.log("SetRecordResult: " + result.data.id)
const [record] = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version }, true);
recordExpiryTime = new Date(record.expiryTime);
const [bond] = await registry.getBondsByIds([bondId]);
@@ -63,21 +63,22 @@ const nameserviceExpiryTests = () => {
});
test('Check record expiry time', async() => {
const [record] = await registry.queryRecords({ type: 'watcher', version: watcher.record.version }, true);
const updatedExpiryTime = new Date(record.expiryTime);
const [record] = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version }, true);
const updatedExpiryTime = new Date();
expect(updatedExpiryTime.getTime()).toBeGreaterThan(recordExpiryTime.getTime());
recordExpiryTime = updatedExpiryTime;
})
test('Check authority expiry time', async() => {
const [authority] = await registry.lookupAuthorities([authorityName]);
const updatedExpiryTime = new Date(authority.expiryTime);
const updatedExpiryTime = new Date();
expect(updatedExpiryTime.getTime()).toBeGreaterThan(authorityExpiryTime.getTime());
authorityExpiryTime = updatedExpiryTime;
})
test('Check bond balance', async () => {
const [bond] = await registry.getBondsByIds([bondId]);
console.log(bond)
expect(bond).toBeDefined();
expect(bond.balance).toHaveLength(0);
})
@@ -87,7 +88,7 @@ const nameserviceExpiryTests = () => {
});
test('Check record deleted without bond balance', async() => {
const records = await registry.queryRecords({ type: 'watcher', version: watcher.record.version }, true);
const records = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version }, true);
expect(records).toHaveLength(0);
})
@@ -104,7 +105,7 @@ if (!process.env.TEST_NAMESERVICE_EXPIRY) {
/**
Running these tests requires timers to be set. In laconicd repo run:
TEST_NAMESERVICE_EXPIRY=true ./init.sh
TEST_REGISTRY_EXPIRY=true ./init.sh
Run tests:
+1 -2
View File
@@ -29,7 +29,7 @@ const namingTests = () => {
// Create bond.
bondId = await registry.getNextBondId(privateKey);
await registry.createBond({ denom: 'aphoton', amount: '1000000000' }, privateKey, fee);
await registry.createBond({ denom: 'aphoton', amount: '2000000000' }, privateKey, fee);
// Create watcher.
watcher = await ensureUpdatedConfig(WATCHER_YML_PATH);
@@ -244,7 +244,6 @@ const namingTests = () => {
const records = await registry.lookupNames([crn], true);
expect(records).toBeDefined();
expect(records).toBeDefined();
expect(records).toHaveLength(1);
const [{ latest }] = records;
+1 -1
View File
@@ -4,4 +4,4 @@ record:
repo_registration_record_cid: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
build_artifact_cid: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
tls_cert_cid: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
version: 1.0.17
version: 1.0.23