2022-04-14 04:34:52 +00:00
|
|
|
import path from 'path';
|
|
|
|
|
|
|
|
import { Registry } from './index';
|
|
|
|
import { getBaseConfig, getConfig } from './testing/helper';
|
|
|
|
import { Util } from './util';
|
|
|
|
|
|
|
|
const WATCHER_YML_PATH = path.join(__dirname, './testing/data/watcher.yml');
|
|
|
|
|
|
|
|
jest.setTimeout(90 * 1000);
|
|
|
|
|
|
|
|
const { chainId, restEndpoint, gqlEndpoint, privateKey, fee } = getConfig();
|
|
|
|
|
|
|
|
const utilTests = () => {
|
|
|
|
let registry: Registry;
|
|
|
|
|
|
|
|
let bondId: string;
|
|
|
|
let watcher: any;
|
|
|
|
let watcherId: string;
|
|
|
|
|
|
|
|
beforeAll(async () => {
|
|
|
|
registry = new Registry(restEndpoint, gqlEndpoint, chainId);
|
|
|
|
|
|
|
|
// Create bond.
|
|
|
|
bondId = await registry.getNextBondId(privateKey);
|
|
|
|
await registry.createBond({ denom: 'aphoton', amount: '1000000000' }, privateKey, fee);
|
|
|
|
|
2022-04-19 10:24:41 +00:00
|
|
|
// Create watcher.
|
2022-04-14 04:34:52 +00:00
|
|
|
watcher = await getBaseConfig(WATCHER_YML_PATH);
|
2022-04-20 11:54:37 +00:00
|
|
|
const result = await registry.setRecord(
|
2022-04-14 04:34:52 +00:00
|
|
|
{
|
|
|
|
privateKey,
|
|
|
|
bondId,
|
|
|
|
record: watcher.record
|
|
|
|
},
|
|
|
|
privateKey,
|
|
|
|
fee
|
|
|
|
)
|
|
|
|
|
2022-04-20 11:54:37 +00:00
|
|
|
watcherId = result.data.id;
|
2022-04-14 04:34:52 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
xtest('generate content id.', async () => {
|
|
|
|
const cid = await Util.getContentId(watcher.record);
|
|
|
|
expect(cid).toBe(watcherId)
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
describe('Util', utilTests);
|