Compare commits

..
Author SHA1 Message Date
0xmuralik 0f6a17527b return error for unkown record type 2023-04-04 10:43:32 +05:30
0xmuralik 76897789e9 / json tag for ref 2023-03-09 16:51:09 +05:30
0xmuralik f622b40ca4 fix typos 2023-02-28 15:48:37 +05:30
0xmuralik 73af07c49f registry expiry tests 2023-02-27 14:03:10 +05:30
0xmuralik 578ed5956e Merge branch 'main' of github.com:cerc-io/laconic-sdk into murali/record-types 2023-02-27 13:39:53 +05:30
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
0xmuralik a7fc72ad31 bond tests 2023-01-30 17:12:26 +05:30
0xmuralik 97994856ff create record types from examples 2023-01-30 16:45:26 +05:30
0xmuralik 37c577fb1d fix sdk tests 2023-01-30 16:00:13 +05:30
0xmuralik 12dfc4362b remaining record types support 2023-01-30 15:49:11 +05:30
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
26 changed files with 2772 additions and 746 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 -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 "$@"
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@cerc-io/laconic-sdk",
"version": "0.1.5",
"version": "0.1.6",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": "git@github.com:cerc-io/laconic-sdk.git",
@@ -16,7 +16,7 @@
"jest": "29.0.0",
"protoc-gen-ts": "^0.8.5",
"ts-jest": "^29.0.2",
"typescript": "^4.6.2"
"typescript": "^4.7.3"
},
"dependencies": {
"@cosmjs/amino": "^0.28.1",
@@ -5,29 +5,109 @@ import "gogoproto/gogo.proto";
option go_package = "github.com/cerc-io/laconicd/x/registry/types";
message ServiceProviderRegistration {
message HashReference{
string ref =1 [(gogoproto.jsontag) = "/"];
}
message ServiceProviderRecord {
string bond_id = 1 [(gogoproto.moretags) = "json:\"bondId\" yaml:\"bondId\""];
string laconic_id = 2 [(gogoproto.moretags) = "json:\"laconicId\" yaml:\"laconicId\""];
X500 x500 = 3 [(gogoproto.moretags) = "json:\"x500\" yaml:\"x500\""];
string type = 4 [(gogoproto.moretags) = "json:\"type\" yaml:\"type\""];
string version = 6 [(gogoproto.moretags) = "json:\"version\" yaml:\"version\""];
message X500 {
string common_name = 1 [(gogoproto.moretags) = "json:\"commonName\" yaml:\"commonName\""];
string organization_unit = 2 [(gogoproto.moretags) = "json:\"organizationUnit\" yaml:\"organizationUnit\""];
string organization_name = 3 [(gogoproto.moretags) = "json:\"organizationName\" yaml:\"organizationName\""];
string locality_name = 4 [(gogoproto.moretags) = "json:\"localityName\" yaml:\"localityName\""];
string state_name = 5 [(gogoproto.moretags) = "json:\"stateName\" yaml:\"stateName\""];
string country = 6 [(gogoproto.moretags) = "json:\"country\" yaml:\"country\""];
}
}
message X500 {
string common_name = 1 [(gogoproto.moretags) = "json:\"commonName\" yaml:\"commonName\""];
string organization_unit = 2 [(gogoproto.moretags) = "json:\"organizationUnit\" yaml:\"organizationUnit\""];
string organization_name = 3 [(gogoproto.moretags) = "json:\"organizationName\" yaml:\"organizationName\""];
string locality_name = 4 [(gogoproto.moretags) = "json:\"localityName\" yaml:\"localityName\""];
string state_name = 5 [(gogoproto.moretags) = "json:\"stateName\" yaml:\"stateName\""];
string country = 6 [(gogoproto.moretags) = "json:\"country\" yaml:\"country\""];
}
message WebsiteRegistrationRecord {
string url = 1 [(gogoproto.moretags) = "json:\"url\" yaml:\"url\""];
string repo_registration_record_cid = 2
[(gogoproto.moretags) = "json:\"repoRegistrationRecordCID\" yaml:\"repoRegistrationRecordCID\""];
string build_artifact_cid = 3 [(gogoproto.moretags) = "json:\"buildArtifactCID\" yaml:\"buildArtifactCID\""];
string tls_cert_cid = 4 [(gogoproto.moretags) = "json:\"TLSCertCID\" yaml:\"TLSCertCID\""];
HashReference repo_reference = 2
[(gogoproto.moretags) = "json:\"repoReference\" yaml:\"repoReference\""];
HashReference build_artifact_ref = 3 [(gogoproto.moretags) = "json:\"buildArtifactRef\" yaml:\"buildArtifactRef\""];
HashReference tls_cert_ref = 4 [(gogoproto.moretags) = "json:\"tlsCertRef\" yaml:\"tlsCertRef\""];
string type = 5 [(gogoproto.moretags) = "json:\"type\" yaml:\"type\""];
string version = 6 [(gogoproto.moretags) = "json:\"version\" yaml:\"version\""];
}
message GitRepository{
string name =1 [(gogoproto.moretags) = "json:\"name\" yaml:\"name\""];
string repo_reference=2 [(gogoproto.moretags) = "json:\"repo_reference\" yaml:\"repo_reference\""];
string description=3 [(gogoproto.moretags) = "json:\"description\" yaml:\"description\""];
string version = 4 [(gogoproto.moretags) = "json:\"version\" yaml:\"version\""];
string type =5 [(gogoproto.moretags) = "json:\"type\" yaml:\"type\""];
}
message Binary{
HashReference hash_reference=1;
string targeted_arch=2;
string runtime_version=3;
HashReference repo_reference=4;
string version=5;
string type=6;
}
message DockerImage{
string image_id=1;
HashReference binary_reference=2;
HashReference repo_reference=3;
string version=4;
string type=5;
}
message WatcherRegistrationRecord{
WatcherMetadata metadata =1;
HashReference repo_reference=2;
WASMBinary wasm=3;
string version=4;
string type=5;
message WatcherMetadata{
string version=1;
HashReference chain_reference=2;
}
message WASMBinary{
HashReference hash_reference=1;
WASMBinaryMetadata metadata=2;
}
message WASMBinaryMetadata{
string compiler_version=1;
string execution_engine_version=2;
}
}
message ResponderContract{
HashReference service_provider_ref=1;
HashReference auction_ref=2;
HashReference watcher_ref=3;
string version=4;
string type=5;
}
message JSPackage{
HashReference repo_reference=1;
HashReference js_package_ref=2;
string version=3;
string type=4;
string name =5;
}
message ChainRegistrationRecord{
string name=1;
repeated string ipld_types=2;
string type=3;
string version=4;
string chain_id=5;
string network_id=6;
HashReference genesis_hash=7;
}
+10 -10
View File
@@ -3,7 +3,7 @@ import path from 'path';
import { Registry } from './index';
import { ensureUpdatedConfig, getConfig } from './testing/helper';
const WATCHER_YML_PATH = path.join(__dirname, './testing/data/watcher.yml');
const WATCHER_YML_PATH = path.join(__dirname, './testing/examples/watcher_registration_example.yml');
const { chainId, restEndpoint, gqlEndpoint, privateKey, fee } = getConfig();
@@ -97,17 +97,17 @@ const bondTests = () => {
// Create a new record.
version1 = await publishNewWatcherVersion(bondId1);
let [record1] = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version1 }, true);
let [record1] = await registry.queryRecords({ "type---": watcher.record.type, "name---": watcher.record.name, "version---": version1 }, true);
expect(record1.bondId).toBe(bondId1);
// Dissociate record, query and confirm.
await registry.dissociateBond({ recordId: record1.id }, privateKey, fee);
[record1] = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version1 }, true);
[record1] = await registry.queryRecords({ "type---": watcher.record.type, "name---": watcher.record.name, "version---": version1 }, true);
expect(record1.bondId).toBe('');
// Associate record with bond, query and confirm.
await registry.associateBond({ recordId: record1.id, bondId: bondId1 }, privateKey, fee);
[record1] = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version1 }, true);
[record1] = await registry.queryRecords({ "type---": watcher.record.type, "name---": watcher.record.name, "version---": version1 }, true);
expect(record1.bondId).toBe(bondId1);
});
@@ -117,9 +117,9 @@ const bondTests = () => {
// Check version1, version2 as associated with bondId1.
let records;
records = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version1 }, true);
records = await registry.queryRecords({ "type---": watcher.record.type, "name---": watcher.record.name, "version---": version1 }, true);
expect(records[0].bondId).toBe(bondId1);
records = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version2 }, true);
records = await registry.queryRecords({ "type---": watcher.record.type, "name---": watcher.record.name, "version---": version2 }, true);
expect(records[0].bondId).toBe(bondId1);
// Create another bond.
@@ -131,16 +131,16 @@ const bondTests = () => {
// Reassociate records from bondId1 to bondId2, verify change.
await registry.reassociateRecords({ oldBondId: bondId1, newBondId: bondId2 }, privateKey, fee);
records = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version1 }, true);
records = await registry.queryRecords({ "type---": watcher.record.type, "name---": watcher.record.name, "version---": version1 }, true);
expect(records[0].bondId).toBe(bondId2);
records = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version2 }, true);
records = await registry.queryRecords({ "type---": watcher.record.type, "name---": watcher.record.name, "version---": version2 }, true);
expect(records[0].bondId).toBe(bondId2);
// Dissociate all records from bond, verify change.
await registry.dissociateRecords({ bondId: bondId2 }, privateKey, fee);
records = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version1 }, true);
records = await registry.queryRecords({ "type---": watcher.record.type, "name---": watcher.record.name, "version---": version1 }, true);
expect(records[0].bondId).toBe('');
records = await registry.queryRecords({ type: watcher.record.type, name: watcher.record.name, version: version2 }, true);
records = await registry.queryRecords({ "type---": watcher.record.type, "name---": watcher.record.name, "version---": version2 }, true);
expect(records[0].bondId).toBe('');
});
};
+10 -9
View File
@@ -3,7 +3,7 @@ import path from 'path';
import { Registry } from './index';
import { ensureUpdatedConfig, getConfig } from './testing/helper';
const WATCHER_YML_PATH = path.join(__dirname, './testing/data/watcher.yml');
const WATCHER_YML_PATH = path.join(__dirname, './testing/examples/git_repo_example.yml');
jest.setTimeout(120 * 1000);
@@ -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---": watcher.record.type, "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---": watcher.record.type, "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---": watcher.record.type, "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:
+5 -6
View File
@@ -5,7 +5,7 @@ import { Account } from './account';
import { Registry } from './index';
import { ensureUpdatedConfig, getConfig } from './testing/helper';
const WATCHER_YML_PATH = path.join(__dirname, './testing/data/watcher.yml');
const WATCHER_YML_PATH = path.join(__dirname, './testing/examples/git_repo_example.yml');
jest.setTimeout(120 * 1000);
@@ -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);
@@ -119,7 +119,7 @@ const namingTests = () => {
await registry.setName({ crn, cid: watcherId }, privateKey, fee);
// Query records should return it (some CRN points to it).
const records = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version });
const records = await registry.queryRecords({ "type---": watcher.record.type, "version---": watcher.record.version });
expect(records).toBeDefined();
expect(records).toHaveLength(1);
});
@@ -229,12 +229,12 @@ const namingTests = () => {
expect(latest.height).toBeDefined();
// Query records should NOT return it (no CRN points to it).
records = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version });
records = await registry.queryRecords({ "type---": watcher.record.type, "version---": watcher.record.version });
expect(records).toBeDefined();
expect(records).toHaveLength(0);
// Query all records should return it (all: true).
records = await registry.queryRecords({ type: 'WebsiteRegistrationRecord', version: watcher.record.version }, true);
records = await registry.queryRecords({ "type---": watcher.record.type, "version---": watcher.record.version }, true);
expect(records).toBeDefined();
expect(records).toHaveLength(1);
});
@@ -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;
File diff suppressed because it is too large Load Diff
+8 -8
View File
@@ -3,7 +3,7 @@ import path from 'path';
import { Registry } from './index';
import { getConfig, ensureUpdatedConfig, provisionBondId } from './testing/helper';
const WATCHER_YML_PATH = path.join(__dirname, './testing/data/watcher.yml');
const WATCHER_YML_PATH = path.join(__dirname, './testing/examples/website_registration_example.yml');
jest.setTimeout(40 * 1000);
@@ -45,17 +45,17 @@ describe('Querying', () => {
});
test('Query records by reference.', async () => {
const { repo_registration_record_cid } = watcher.record;
const records = await registry.queryRecords({ repo_registration_record_cid }, true);
const { ref } = watcher.record.repo_reference;
const records = await registry.queryRecords({ "repo_reference---/---": ref}, true);
expect(records.length).toBeGreaterThanOrEqual(1);
const { attributes: { repo_registration_record_cid: record_repo_registration_record_cid } } = records[0];
expect(repo_registration_record_cid).toBe(record_repo_registration_record_cid);
const { attributes: { repo_reference: {ref: record_repo_registration_record_cid} } } = records[0];
expect(ref).toBe(record_repo_registration_record_cid);
});
test('Query records by attributes.', async () => {
const { version, name } = watcher.record;
const records = await registry.queryRecords({ version, name }, true);
const records = await registry.queryRecords({ "version---": version, "name---": name }, true);
expect(records.length).toBe(1);
[ watcher ] = records;
@@ -74,7 +74,7 @@ describe('Querying', () => {
const [record] = await registry.getRecordsByIds([watcher.id], true);
expect(record.id).toBe(watcher.id);
// temp fix
expect(record.attributes.repo_registration_record_cid).toBeDefined();
expect(record.attributes.repo_registration_record_cid).toHaveLength(46);
expect(record.attributes.repo_reference["/"]).toBeDefined();
expect(record.attributes.repo_reference["/"]).toHaveLength(46);
});
});
+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
+9
View File
@@ -0,0 +1,9 @@
record:
hash_reference:
/: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
targeted_arch: x86_64
runtime_version: go 1.18
repo_reference:
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
version: 1.0.0
type: Binary
@@ -0,0 +1,13 @@
record:
name: Laconic
ipld_types:
- type3
- type11
- schema2
- codec5
type: ChainRegistrationRecord
version: 0.11.2
chain_id: laconic_9000-1
network_id: "1392"
genesis_hash:
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
@@ -0,0 +1,8 @@
record:
image_id: 77af4d6b9913
binary_reference:
/: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
repo_reference:
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
version: 1.0.0
type: DockerImage
+7
View File
@@ -0,0 +1,7 @@
record:
attr1: value1
attr2: value2
link1:
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
link2:
/: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
@@ -0,0 +1,6 @@
record:
name: cosmos-sdk
repo_reference: 'https://github.com/cosmos/cosmos-sdk'
description: This is a description string
version: 0.46.48
type: GitRepository
@@ -0,0 +1,8 @@
record:
repo_reference:
/: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
js_package_ref:
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
version: 1.0.0
type: JSPackage
name: test-JSPackage
@@ -0,0 +1,9 @@
record:
service_provider_ref:
/: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
auction_ref:
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
watcher_ref:
/: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
version: 1.0.0
type: ResponderContract
@@ -0,0 +1,12 @@
record:
type: ServiceProviderRecord
bond_id: madeUpBondID
laconic_id: madeUpLaconicID
version: 1.0.13
x500:
common_name: cerc-io
organization_unit: xyz
organization_name: abc
state_name: california
country: US
locality_name: local
@@ -0,0 +1,15 @@
record:
metadata:
version: 0.32.0
chain_reference:
/: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
repo_reference:
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
wasm:
hash_reference:
/: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
metadata:
compiler_version: 1.15.0
execution_engine_version: 0.16.1
version: 1.0.25
type: WatcherRegistrationRecord
@@ -0,0 +1,10 @@
record:
type: WebsiteRegistrationRecord
url: 'https://cerc.io'
repo_reference:
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
build_artifact_ref:
/: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
tls_cert_ref:
/: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
version: 1.0.20
+145 -6
View File
@@ -32,12 +32,151 @@ export class Record {
var a = new any.google.protobuf.Any()
if (this._record.type=="WebsiteRegistrationRecord"){
var attr= new attributes.vulcanize.registry.v1beta1.WebsiteRegistrationRecord(this._record)
a= new any.google.protobuf.Any({
type_url: "/vulcanize.registry.v1beta1.WebsiteRegistrationRecord",
value: attr.serialize()
})
switch (this._record.type){
case "WebsiteRegistrationRecord": {
var webAttr= new attributes.vulcanize.registry.v1beta1.WebsiteRegistrationRecord({
url: this._record.url,
repo_reference: new attributes.vulcanize.registry.v1beta1.HashReference({ref:this._record.repo_reference["/"],}),
build_artifact_ref: new attributes.vulcanize.registry.v1beta1.HashReference({ref:this._record.build_artifact_ref["/"]}),
tls_cert_ref:new attributes.vulcanize.registry.v1beta1.HashReference({ref:this._record.tls_cert_ref["/"]}),
type: this._record.type,
version:this._record.version,
})
a= new any.google.protobuf.Any({
type_url: "/vulcanize.registry.v1beta1.WebsiteRegistrationRecord",
value: webAttr.serialize()
})
};
break;
case "ServiceProviderRecord": {
var serAttr= new attributes.vulcanize.registry.v1beta1.ServiceProviderRecord({
bond_id:this._record.bond_id,
laconic_id:this._record.laconic_id,
type:this._record.type,
version:this._record.version,
x500: new attributes.vulcanize.registry.v1beta1.ServiceProviderRecord.X500(this._record.x500)
})
a= new any.google.protobuf.Any({
type_url: "/vulcanize.registry.v1beta1.ServiceProviderRecord",
value: serAttr.serialize()
})
};
break;
case "GitRepository": {
var gitAttr= new attributes.vulcanize.registry.v1beta1.GitRepository(this._record)
a= new any.google.protobuf.Any({
type_url: "/vulcanize.registry.v1beta1.GitRepository",
value: gitAttr.serialize()
})
};
break;
case "Binary": {
var binaryAttr= new attributes.vulcanize.registry.v1beta1.Binary({
hash_reference: new attributes.vulcanize.registry.v1beta1.HashReference({ref:this._record.hash_reference["/"]}),
targeted_arch: this._record.targeted_arch,
runtime_version: this._record.runtime_version,
repo_reference: new attributes.vulcanize.registry.v1beta1.HashReference({ref:this._record.repo_reference["/"]}),
version: this._record.version,
type: this._record.type,
})
a= new any.google.protobuf.Any({
type_url: "/vulcanize.registry.v1beta1.Binary",
value: binaryAttr.serialize()
})
};
break;
case "DockerImage": {
var dockerAttr= new attributes.vulcanize.registry.v1beta1.DockerImage({
image_id: this._record.image_id,
binary_reference: new attributes.vulcanize.registry.v1beta1.HashReference({ref:this._record.binary_reference["/"]}),
repo_reference: new attributes.vulcanize.registry.v1beta1.HashReference({ref:this._record.repo_reference["/"]}),
version: this._record.version,
type: this._record.type,
})
a= new any.google.protobuf.Any({
type_url: "/vulcanize.registry.v1beta1.DockerImage",
value: dockerAttr.serialize()
})
};
break;
case "WatcherRegistrationRecord": {
var watcherAttr= new attributes.vulcanize.registry.v1beta1.WatcherRegistrationRecord({
metadata: new attributes.vulcanize.registry.v1beta1.WatcherRegistrationRecord.WatcherMetadata({
version: this._record.metadata.version,
chain_reference: new attributes.vulcanize.registry.v1beta1.HashReference({ref:this._record.metadata.chain_reference["/"]}),
}),
repo_reference: new attributes.vulcanize.registry.v1beta1.HashReference({ref:this._record.repo_reference["/"]}),
wasm: new attributes.vulcanize.registry.v1beta1.WatcherRegistrationRecord.WASMBinary({
hash_reference: new attributes.vulcanize.registry.v1beta1.HashReference({ref:this._record.wasm.hash_reference["/"]}),
metadata: new attributes.vulcanize.registry.v1beta1.WatcherRegistrationRecord.WASMBinaryMetadata(this._record.wasm.metadata),
}),
version: this._record.version,
type: this._record.type,
})
a= new any.google.protobuf.Any({
type_url: "/vulcanize.registry.v1beta1.WatcherRegistrationRecord",
value: watcherAttr.serialize()
})
};
break;
case "ResponderContract": {
var respAttr= new attributes.vulcanize.registry.v1beta1.ResponderContract({
service_provider_ref: new attributes.vulcanize.registry.v1beta1.HashReference({ref:this._record.service_provider_ref["/"]}),
auction_ref: new attributes.vulcanize.registry.v1beta1.HashReference({ref:this._record.auction_ref["/"]}),
watcher_ref: new attributes.vulcanize.registry.v1beta1.HashReference({ref:this._record.watcher_ref["/"]}),
version: this._record.version,
type: this._record.type,
})
a= new any.google.protobuf.Any({
type_url: "/vulcanize.registry.v1beta1.ResponderContract",
value: respAttr.serialize()
})
};
break;
case "JSPackage": {
var jsAttr= new attributes.vulcanize.registry.v1beta1.JSPackage({
repo_reference: new attributes.vulcanize.registry.v1beta1.HashReference({ref:this._record.repo_reference["/"]}),
js_package_ref: new attributes.vulcanize.registry.v1beta1.HashReference({ref:this._record.js_package_ref["/"]}),
version: this._record.version,
type: this._record.type,
name: this._record.name,
})
a= new any.google.protobuf.Any({
type_url: "/vulcanize.registry.v1beta1.JSPackage",
value: jsAttr.serialize()
})
};
break;
case "ChainRegistrationRecord": {
var chainAttr= new attributes.vulcanize.registry.v1beta1.ChainRegistrationRecord({
name: this._record.name,
ipld_types: this._record.ipld_types,
type: this._record.type,
version: this._record.version,
chain_id: this._record.chain_id,
network_id: this._record.network_id,
genesis_hash: new attributes.vulcanize.registry.v1beta1.HashReference({ref:this._record.genesis_hash["/"]}),
})
a= new any.google.protobuf.Any({
type_url: "/vulcanize.registry.v1beta1.ChainRegistrationRecord",
value: chainAttr.serialize()
})
};
break;
default: {
const err = new Error("Unsupported reocrd type");
console.error(err);
throw err;
};
}
return a
}
+1 -1
View File
@@ -4,7 +4,7 @@ import { Registry } from './index';
import { getBaseConfig, getConfig } from './testing/helper';
import { Util } from './util';
const WATCHER_YML_PATH = path.join(__dirname, './testing/data/watcher.yml');
const WATCHER_YML_PATH = path.join(__dirname, './testing/examples/git_repo_example.yml');
jest.setTimeout(90 * 1000);
+455 -455
View File
File diff suppressed because it is too large Load Diff