Compare commits

..

4 Commits

Author SHA1 Message Date
3dabf399f7 Add context to error message (#57)
All checks were successful
Tests / sdk_tests (push) Successful in 22m48s
Part of [Fix error propagation from laconicd to client SDK](https://www.notion.so/Fix-error-propagation-from-laconicd-to-client-SDK-1bd20c5a4e8141a99e5809ea1fd7832f)

- Use error in response raw log from laconicd

Co-authored-by: neeraj <neeraj.rtly@gmail.com>
Reviewed-on: cerc-io/laconic-sdk#57
2024-04-02 12:57:33 +00:00
73bef00dd3 Handle record attributes with null values (#56)
All checks were successful
Tests / sdk_tests (push) Successful in 22m32s
Part of cerc-io/laconicd#144

Reviewed-on: cerc-io/laconic-sdk#56
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2024-02-08 05:39:31 +00:00
809c4d8f5b Run tests only from src folder (#55)
All checks were successful
Tests / sdk_tests (push) Successful in 21m47s
Reviewed-on: cerc-io/laconic-sdk#55
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2024-01-23 12:10:56 +00:00
fedf35d702 Tests cleanup (#53)
Some checks failed
Tests / sdk_tests (push) Failing after 7m52s
General test improvements.
- Simplifies Dockerfile
- Refactors tests so they can be run independently

Co-authored-by: Roy Crihfield <roy@manteia.ltd>
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Reviewed-on: cerc-io/laconic-sdk#53
Reviewed-by: Thomas E Lackey <telackey@noreply.git.vdb.to>
Co-authored-by: Prathamesh Musale <prathamesh@noreply.git.vdb.to>
Co-committed-by: Prathamesh Musale <prathamesh@noreply.git.vdb.to>
2024-01-22 08:30:35 +00:00
5 changed files with 10 additions and 25 deletions

View File

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

View File

@ -54,7 +54,7 @@ import {
export const DEFAULT_CHAIN_ID = 'laconic_9000-1'; 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. // Parse Tx response from cosmos-sdk.
export const parseTxResponse = (result: any, parseResponse?: (data: string) => any) => { export const parseTxResponse = (result: any, parseResponse?: (data: string) => any) => {
@ -117,7 +117,8 @@ export class Registry {
console.error(error) console.error(error)
} }
return errorMessage || DEFAULT_WRITE_ERROR; const [lastErrorLine] = error.split("\n").slice(-1);
return `${errorMessage || DEFAULT_WRITE_ERROR}: ${lastErrorLine}`;
} }
constructor(gqlUrl: string, restUrl: string = "", chainId: string = DEFAULT_CHAIN_ID) { 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 = [ export const NAMESERVICE_ERRORS = [
'Name already reserved.', 'Name already reserved',
'Authority bond not found.', 'Authority bond not found',
'Name authority not found.', 'Name authority not found',
'Access denied.', 'Access denied',
] ]
export interface MessageMsgReserveAuthority { export interface MessageMsgReserveAuthority {

View File

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

View File

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