Update test to query bonds by owner
Some checks failed
Lint & Build / lint_and_build (20.x) (pull_request) Successful in 1m58s
Tests / sdk_tests (pull_request) Failing after 9m59s

This commit is contained in:
IshaVenikar 2024-09-05 17:30:54 +05:30 committed by Prathamesh Musale
parent 19374935b5
commit 91a4792346
2 changed files with 22 additions and 12 deletions

View File

@ -1,6 +1,6 @@
import path from 'path';
import { Registry } from './index';
import { Account, Registry } from './index';
import { ensureUpdatedConfig, getConfig } from './testing/helper';
import { DENOM } from './constants';
@ -61,13 +61,23 @@ const bondTests = () => {
});
test('Query bonds by owner.', async () => {
const [result] = await registry.queryBondsByOwner([bond1.owner]);
expect(result).toBeDefined();
expect(result.bonds).toBeDefined();
const mnenonic = Account.generateMnemonic();
const otherAccount = await Account.generateFromMnemonic(mnenonic);
await otherAccount.init();
await registry.sendCoins({ denom: DENOM, amount: '1000000000000', destinationAddress: otherAccount.address }, privateKey, fee);
const filteredBonds = result.bonds.filter((bond: any) => bond.id === bond1.id);
expect(filteredBonds).toHaveLength(1);
expect(filteredBonds[0]).toMatchObject({ id: bond1.id, owner: bond1.owner });
const { id: bondId2 } = await registry.createBond({ denom: DENOM, amount: BOND_AMOUNT }, otherAccount.getPrivateKey(), fee);
const [owner1Bonds] = await registry.queryBondsByOwner(bond1.owner);
expect(owner1Bonds.bonds).toHaveLength(2);
const owner1Bond = owner1Bonds.bonds.filter((bond: any) => bond.id === bond1.id);
expect(owner1Bond).toBeDefined();
const [bond2] = await registry.getBondsByIds([bondId2]);
const [owner2Bonds] = await registry.queryBondsByOwner(bond2.owner);
expect(owner2Bonds.bonds).toHaveLength(1);
const owner2Bond = owner2Bonds.bonds.filter((bond: any) => bond.id === bond2.id);
expect(owner2Bond).toBeDefined();
});
test('Refill bond.', async () => {

View File

@ -31,7 +31,7 @@ import { Coin } from './proto/cosmos/base/v1beta1/coin';
import { MsgCancelBondResponse, MsgCreateBondResponse, MsgRefillBondResponse, MsgWithdrawBondResponse } from './proto/cerc/bond/v1/tx';
import { MsgOnboardParticipantResponse } from './proto/cerc/onboarding/v1/tx';
import { MsgSendResponse } from './proto/cosmos/bank/v1beta1/tx';
import { DEFAULT_CHAIN_ID, DEFAULT_GAS_ESTIMATION_MULTIPLIER } from './constants';
import { DEFAULT_GAS_ESTIMATION_MULTIPLIER } from './constants';
/**
* Create an auction bid.
@ -60,7 +60,7 @@ export const createBid = async (chainId: string, auctionId: string, bidderAddres
};
interface RegistryOptions {
chainId?: string
chainId: string
gasPrice?: GasPrice
}
@ -70,15 +70,15 @@ export class Registry {
_client: RegistryClient;
_gasPrice?: GasPrice;
constructor (gqlUrl: string, rpcUrl = '', options?: RegistryOptions) {
constructor (gqlUrl: string, rpcUrl = '', options: RegistryOptions) {
this._endpoints = {
rpc: rpcUrl,
gql: gqlUrl
};
this._client = new RegistryClient(gqlUrl, rpcUrl);
this._chainID = options?.chainId ?? DEFAULT_CHAIN_ID;
this._gasPrice = options?.gasPrice;
this._chainID = options.chainId;
this._gasPrice = options.gasPrice;
}
/**