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
6 changed files with 16 additions and 36 deletions

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "@cerc-io/laconic-sdk",
"version": "0.1.14",
"version": "0.1.16",
"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",
"test": "jest --runInBand --verbose --testPathPattern=src",
"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,7 +117,8 @@ export class Registry {
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) {

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,20 +19,14 @@ 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,
@ -44,9 +38,6 @@ const namingTests = () => {
)
watcherId = result.data.id;
console.log('watcherId', watcherId)
console.log('done running parent beforeAll')
});
describe('Authority tests', () => {
@ -54,7 +45,6 @@ const namingTests = () => {
const authorityName = `laconic-${Date.now()}`;
await registry.reserveAuthority({ name: authorityName }, privateKey, fee);
console.log('done Reserve authority')
});
describe('With authority reserved', () => {
@ -62,13 +52,11 @@ 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 () => {
@ -78,7 +66,6 @@ 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 () => {
@ -87,13 +74,11 @@ 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 () => {
@ -105,7 +90,6 @@ 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] = this.fromGQLValue(attr.value);
res[attr.key] = (attr.value === null) ? null : this.fromGQLValue(attr.value);
});
return res;