registry-sdk/src/util.test.ts
Prathamesh Musale 6a17b1b175 Add support for using auto fee calculation (#22)
Part of [Create a public laconicd testnet](https://www.notion.so/Create-a-public-laconicd-testnet-896a11bdd8094eff8f1b49c0be0ca3b8)

- Add an option for setting gas price
- Use fees as gas estimation multiplier when `gasPrice` is provided (following `cosmjs` pattern)
  - Default gas estimation multiplier: `2`
- Add a method to query bonds by owners and fix tests
- Add a test for inclusion of batch of txs sent at once in the same block

Co-authored-by: IshaVenikar <ishavenikar7@gmail.com>
Co-authored-by: Nabarun <nabarun@deepstacksoft.com>
Reviewed-on: cerc-io/registry-sdk#22
Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2024-09-06 09:07:57 +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);