Compare commits

..

10 Commits

6 changed files with 36 additions and 16 deletions

View File

@ -6,6 +6,7 @@ on:
push:
branches:
- main
- test-ci
- release/**
env:
@ -17,12 +18,16 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Checkout laconicd
uses: actions/checkout@v3
with:
path: "./laconicd/"
repository: cerc-io/laconicd
fetch-depth: 0
ref: main
# uses: actions/checkout@v3
# with:
# path: "./laconicd/"
# repository: cerc-io/laconicd
# fetch-depth: 0
# ref: main
run: |
git clone https://git.vdb.to/deep-stack/laconicd.git
cd laconicd
git checkout pm-qol-improvements
- name: Environment
run: ls -tlh && env

View File

@ -1,6 +1,6 @@
{
"name": "@cerc-io/laconic-sdk",
"version": "0.1.16",
"version": "0.1.14",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"repository": "git@github.com:cerc-io/laconic-sdk.git",
@ -48,7 +48,7 @@
"tiny-secp256k1": "^1.1.6"
},
"scripts": {
"test": "jest --runInBand --verbose --testPathPattern=src",
"test": "jest --runInBand --verbose",
"test:auctions": "TEST_AUCTIONS_ENABLED=1 jest --runInBand --verbose src/auction.test.ts",
"test:nameservice-expiry": "TEST_NAMESERVICE_EXPIRY=1 jest --runInBand --verbose src/nameservice-expiry.test.ts",
"build": "tsc"

View File

@ -54,7 +54,7 @@ import {
export const DEFAULT_CHAIN_ID = 'laconic_9000-1';
const DEFAULT_WRITE_ERROR = 'Unable to write to laconicd';
const DEFAULT_WRITE_ERROR = 'Unable to write to laconicd.';
// Parse Tx response from cosmos-sdk.
export const parseTxResponse = (result: any, parseResponse?: (data: string) => any) => {
@ -117,8 +117,7 @@ export class Registry {
console.error(error)
}
const [lastErrorLine] = error.split("\n").slice(-1);
return `${errorMessage || DEFAULT_WRITE_ERROR}: ${lastErrorLine}`;
return errorMessage || DEFAULT_WRITE_ERROR;
}
constructor(gqlUrl: string, restUrl: string = "", chainId: string = DEFAULT_CHAIN_ID) {

View File

@ -81,10 +81,10 @@ export const parseMsgSetRecordResponse = (data: string) => {
}
export const NAMESERVICE_ERRORS = [
'Name already reserved',
'Authority bond not found',
'Name authority not found',
'Access denied',
'Name already reserved.',
'Authority bond not found.',
'Name authority not found.',
'Access denied.',
]
export interface MessageMsgReserveAuthority {

View File

@ -19,14 +19,20 @@ const namingTests = () => {
let watcherId: string;
beforeAll(async () => {
console.log('running parent beforeAll')
registry = new Registry(gqlEndpoint, restEndpoint, chainId);
console.log('registry = new Registry')
// Create bond.
bondId = await registry.getNextBondId(privateKey);
console.log('bondId', bondId)
await registry.createBond({ denom: 'aphoton', amount: '2000000000' }, privateKey, fee);
console.log('done registry.createBond')
// Create watcher.
watcher = await ensureUpdatedConfig(WATCHER_YML_PATH);
console.log('done await ensureUpdatedConfig')
const result = await registry.setRecord(
{
privateKey,
@ -38,6 +44,9 @@ const namingTests = () => {
)
watcherId = result.data.id;
console.log('watcherId', watcherId)
console.log('done running parent beforeAll')
});
describe('Authority tests', () => {
@ -45,6 +54,7 @@ const namingTests = () => {
const authorityName = `laconic-${Date.now()}`;
await registry.reserveAuthority({ name: authorityName }, privateKey, fee);
console.log('done Reserve authority')
});
describe('With authority reserved', () => {
@ -52,11 +62,13 @@ const namingTests = () => {
let crn: string;
beforeAll(async () => {
console.log('running beforeAll')
authorityName = `laconic-${Date.now()}`;
crn = `crn://${authorityName}/app/test`;
await registry.reserveAuthority({ name: authorityName }, privateKey, fee);
console.log('done running beforeAll')
})
test('Lookup authority.', async () => {
@ -66,6 +78,7 @@ const namingTests = () => {
expect(record.ownerAddress).not.toBe('');
expect(record.ownerPublicKey).not.toBe('');
expect(Number(record.height)).toBeGreaterThan(0);
console.log('done Lookup authority')
});
test('Lookup non existing authority', async () => {
@ -74,11 +87,13 @@ const namingTests = () => {
expect(record.ownerAddress).toBe('');
expect(record.ownerPublicKey).toBe('');
expect(Number(record.height)).toBe(0);
console.log('done Lookup non existing authority')
});
test('Reserve already reserved authority', async () => {
await expect(registry.reserveAuthority({ name: authorityName }, privateKey, fee)).
rejects.toThrow('Name already reserved.');
console.log('done Reserve already reserved authority')
});
test('Reserve sub-authority.', async () => {
@ -90,6 +105,7 @@ const namingTests = () => {
expect(record.ownerAddress).not.toBe('');
expect(record.ownerPublicKey).not.toBe('');
expect(Number(record.height)).toBeGreaterThan(0);
console.log('done Reserve sub-authority')
});
test('Reserve sub-authority with different owner.', async () => {

View File

@ -79,7 +79,7 @@ export class Util {
const res: {[key: string]: any} = {};
attributes.forEach(attr => {
res[attr.key] = (attr.value === null) ? null : this.fromGQLValue(attr.value);
res[attr.key] = this.fromGQLValue(attr.value);
});
return res;