forked from cerc-io/laconic-sdk
Compare commits
4 Commits
pm-tests-c
...
main
Author | SHA1 | Date | |
---|---|---|---|
3dabf399f7 | |||
73bef00dd3 | |||
809c4d8f5b | |||
fedf35d702 |
@ -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"
|
||||||
|
@ -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) {
|
||||||
|
@ -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 {
|
||||||
|
@ -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 () => {
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user