registry-sdk/src/util.test.ts
Prathamesh Musale ad07856267 Rename laconic2d to laconicd (#10)
Part of https://www.notion.so/Rename-laconic2d-to-laconicd-9028d0c020d24d1288e92ebcb773d7a7

Co-authored-by: neeraj <neeraj.rtly@gmail.com>
Reviewed-on: cerc-io/registry-sdk#10
Co-authored-by: Prathamesh Musale <prathamesh@noreply.git.vdb.to>
Co-committed-by: Prathamesh Musale <prathamesh@noreply.git.vdb.to>
2024-04-01 14:23:34 +00:00

50 lines
1.2 KiB
TypeScript

import path from 'path';
import { Registry } from './index';
import { getBaseConfig, getConfig } from './testing/helper';
import { Util } from './util';
import { DENOM } from './constants';
const WATCHER_YML_PATH = path.join(__dirname, './testing/data/watcher.yml');
jest.setTimeout(90 * 1000);
const { chainId, rpcEndpoint, gqlEndpoint, privateKey, fee } = getConfig();
const utilTests = () => {
let registry: Registry;
let bondId: string;
let watcher: any;
let watcherId: string;
beforeAll(async () => {
registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
// Create bond.
bondId = await registry.getNextBondId(privateKey);
await registry.createBond({ denom: DENOM, amount: '1000000000' }, privateKey, fee);
// Create watcher.
watcher = await getBaseConfig(WATCHER_YML_PATH);
const result = await registry.setRecord(
{
privateKey,
bondId,
record: watcher.record
},
privateKey,
fee
);
watcherId = result.id;
});
test('Generate content id.', async () => {
const cid = await Util.getContentId(watcher.record);
expect(cid).toBe(watcherId);
});
};
describe('Util', utilTests);