Skip to content

Commit

Permalink
new test and fixtures of grpc-gateway with 2 params
Browse files Browse the repository at this point in the history
  • Loading branch information
hoangdv2429 committed Jun 17, 2023
1 parent 1e2d128 commit 37e9564
Show file tree
Hide file tree
Showing 2 changed files with 271 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,268 @@ exports[`GRPC-Gateway Query Client 2`] = `
}"
`;
exports[`GRPC-Gateway Query Client with 2 params 1`] = `
"export class Query {
/** Validators queries all validators that match the given status. */
static validators(request: QueryValidatorsRequest, initRequest?: fm.InitReq): Promise<QueryValidatorsResponse> {
return fm.fetchReq(\`/cosmos/staking/v1beta1/validators?\${fm.renderURLSearchParams({
...request
}, [])}\`, {
...initRequest,
method: "GET"
});
}
/** Validator queries validator info for given validator address. */
static validator(request: QueryValidatorRequest, initRequest?: fm.InitReq): Promise<QueryValidatorResponse> {
return fm.fetchReq(\`/cosmos/staking/v1beta1/validators/\${request["validator_addr"]}?\${fm.renderURLSearchParams({
...request
}, ["validator_addr"])}\`, {
...initRequest,
method: "GET"
});
}
/** ValidatorDelegations queries delegate info for given validator. */
static validatorDelegations(request: QueryValidatorDelegationsRequest, initRequest?: fm.InitReq): Promise<QueryValidatorDelegationsResponse> {
return fm.fetchReq(\`/cosmos/staking/v1beta1/validators/\${request["validator_addr"]}/delegations?\${fm.renderURLSearchParams({
...request
}, ["validator_addr"])}\`, {
...initRequest,
method: "GET"
});
}
/** ValidatorUnbondingDelegations queries unbonding delegations of a validator. */
static validatorUnbondingDelegations(request: QueryValidatorUnbondingDelegationsRequest, initRequest?: fm.InitReq): Promise<QueryValidatorUnbondingDelegationsResponse> {
return fm.fetchReq(\`/cosmos/staking/v1beta1/validators/\${request["validator_addr"]}/unbonding_delegations?\${fm.renderURLSearchParams({
...request
}, ["validator_addr"])}\`, {
...initRequest,
method: "GET"
});
}
/** Delegation queries delegate info for given validator delegator pair. */
static delegation(request: QueryDelegationRequest, initRequest?: fm.InitReq): Promise<QueryDelegationResponse> {
return fm.fetchReq(\`/cosmos/staking/v1beta1/validators/\${request["validator_addr"]}/delegations/{delegator_addr}?\${fm.renderURLSearchParams({
...request
}, ["validator_addr"])}\`, {
...initRequest,
method: "GET"
});
}
/**
* UnbondingDelegation queries unbonding info for given validator delegator
* pair.
*/
static unbondingDelegation(request: QueryUnbondingDelegationRequest, initRequest?: fm.InitReq): Promise<QueryUnbondingDelegationResponse> {
return fm.fetchReq(\`/cosmos/staking/v1beta1/validators/\${request["validator_addr"]}/delegations/{delegator_addr}/unbonding_delegation?\${fm.renderURLSearchParams({
...request
}, ["validator_addr"])}\`, {
...initRequest,
method: "GET"
});
}
/** DelegatorDelegations queries all delegations of a given delegator address. */
static delegatorDelegations(request: QueryDelegatorDelegationsRequest, initRequest?: fm.InitReq): Promise<QueryDelegatorDelegationsResponse> {
return fm.fetchReq(\`/cosmos/staking/v1beta1/delegations/\${request["delegator_addr"]}?\${fm.renderURLSearchParams({
...request
}, ["delegator_addr"])}\`, {
...initRequest,
method: "GET"
});
}
/**
* DelegatorUnbondingDelegations queries all unbonding delegations of a given
* delegator address.
*/
static delegatorUnbondingDelegations(request: QueryDelegatorUnbondingDelegationsRequest, initRequest?: fm.InitReq): Promise<QueryDelegatorUnbondingDelegationsResponse> {
return fm.fetchReq(\`/cosmos/staking/v1beta1/delegators/\${request["delegator_addr"]}/unbonding_delegations?\${fm.renderURLSearchParams({
...request
}, ["delegator_addr"])}\`, {
...initRequest,
method: "GET"
});
}
/** Redelegations queries redelegations of given address. */
static redelegations(request: QueryRedelegationsRequest, initRequest?: fm.InitReq): Promise<QueryRedelegationsResponse> {
return fm.fetchReq(\`/cosmos/staking/v1beta1/delegators/\${request["delegator_addr"]}/redelegations?\${fm.renderURLSearchParams({
...request
}, ["delegator_addr"])}\`, {
...initRequest,
method: "GET"
});
}
/**
* DelegatorValidators queries all validators info for given delegator
* address.
*/
static delegatorValidators(request: QueryDelegatorValidatorsRequest, initRequest?: fm.InitReq): Promise<QueryDelegatorValidatorsResponse> {
return fm.fetchReq(\`/cosmos/staking/v1beta1/delegators/\${request["delegator_addr"]}/validators?\${fm.renderURLSearchParams({
...request
}, ["delegator_addr"])}\`, {
...initRequest,
method: "GET"
});
}
/**
* DelegatorValidator queries validator info for given delegator validator
* pair.
*/
static delegatorValidator(request: QueryDelegatorValidatorRequest, initRequest?: fm.InitReq): Promise<QueryDelegatorValidatorResponse> {
return fm.fetchReq(\`/cosmos/staking/v1beta1/delegators/\${request["delegator_addr"]}/validators/{validator_addr}?\${fm.renderURLSearchParams({
...request
}, ["delegator_addr"])}\`, {
...initRequest,
method: "GET"
});
}
/** HistoricalInfo queries the historical info for given height. */
static historicalInfo(request: QueryHistoricalInfoRequest, initRequest?: fm.InitReq): Promise<QueryHistoricalInfoResponse> {
return fm.fetchReq(\`/cosmos/staking/v1beta1/historical_info/\${request["height"]}?\${fm.renderURLSearchParams({
...request
}, ["height"])}\`, {
...initRequest,
method: "GET"
});
}
/** Pool queries the pool info. */
static pool(request: QueryPoolRequest, initRequest?: fm.InitReq): Promise<QueryPoolResponse> {
return fm.fetchReq(\`/cosmos/staking/v1beta1/pool?\${fm.renderURLSearchParams({
...request
}, [])}\`, {
...initRequest,
method: "GET"
});
}
/** Parameters queries the staking parameters. */
static params(request: QueryParamsRequest, initRequest?: fm.InitReq): Promise<QueryParamsResponse> {
return fm.fetchReq(\`/cosmos/staking/v1beta1/params?\${fm.renderURLSearchParams({
...request
}, [])}\`, {
...initRequest,
method: "GET"
});
}
}"
`;
exports[`GRPC-Gateway Query Client with 2 params 2`] = `
"export class Querier {
private readonly url: string;
constructor(url: string) {
this.url = url;
}
/** Validators queries all validators that match the given status. */
async validators(req: QueryValidatorsRequest, headers?: HeadersInit): Promise<QueryValidatorsResponse> {
return Query.validators(req, {
headers,
pathPrefix: this.url
});
}
/** Validator queries validator info for given validator address. */
async validator(req: QueryValidatorRequest, headers?: HeadersInit): Promise<QueryValidatorResponse> {
return Query.validator(req, {
headers,
pathPrefix: this.url
});
}
/** ValidatorDelegations queries delegate info for given validator. */
async validatorDelegations(req: QueryValidatorDelegationsRequest, headers?: HeadersInit): Promise<QueryValidatorDelegationsResponse> {
return Query.validatorDelegations(req, {
headers,
pathPrefix: this.url
});
}
/** ValidatorUnbondingDelegations queries unbonding delegations of a validator. */
async validatorUnbondingDelegations(req: QueryValidatorUnbondingDelegationsRequest, headers?: HeadersInit): Promise<QueryValidatorUnbondingDelegationsResponse> {
return Query.validatorUnbondingDelegations(req, {
headers,
pathPrefix: this.url
});
}
/** Delegation queries delegate info for given validator delegator pair. */
async delegation(req: QueryDelegationRequest, headers?: HeadersInit): Promise<QueryDelegationResponse> {
return Query.delegation(req, {
headers,
pathPrefix: this.url
});
}
/**
* UnbondingDelegation queries unbonding info for given validator delegator
* pair.
*/
async unbondingDelegation(req: QueryUnbondingDelegationRequest, headers?: HeadersInit): Promise<QueryUnbondingDelegationResponse> {
return Query.unbondingDelegation(req, {
headers,
pathPrefix: this.url
});
}
/** DelegatorDelegations queries all delegations of a given delegator address. */
async delegatorDelegations(req: QueryDelegatorDelegationsRequest, headers?: HeadersInit): Promise<QueryDelegatorDelegationsResponse> {
return Query.delegatorDelegations(req, {
headers,
pathPrefix: this.url
});
}
/**
* DelegatorUnbondingDelegations queries all unbonding delegations of a given
* delegator address.
*/
async delegatorUnbondingDelegations(req: QueryDelegatorUnbondingDelegationsRequest, headers?: HeadersInit): Promise<QueryDelegatorUnbondingDelegationsResponse> {
return Query.delegatorUnbondingDelegations(req, {
headers,
pathPrefix: this.url
});
}
/** Redelegations queries redelegations of given address. */
async redelegations(req: QueryRedelegationsRequest, headers?: HeadersInit): Promise<QueryRedelegationsResponse> {
return Query.redelegations(req, {
headers,
pathPrefix: this.url
});
}
/**
* DelegatorValidators queries all validators info for given delegator
* address.
*/
async delegatorValidators(req: QueryDelegatorValidatorsRequest, headers?: HeadersInit): Promise<QueryDelegatorValidatorsResponse> {
return Query.delegatorValidators(req, {
headers,
pathPrefix: this.url
});
}
/**
* DelegatorValidator queries validator info for given delegator validator
* pair.
*/
async delegatorValidator(req: QueryDelegatorValidatorRequest, headers?: HeadersInit): Promise<QueryDelegatorValidatorResponse> {
return Query.delegatorValidator(req, {
headers,
pathPrefix: this.url
});
}
/** HistoricalInfo queries the historical info for given height. */
async historicalInfo(req: QueryHistoricalInfoRequest, headers?: HeadersInit): Promise<QueryHistoricalInfoResponse> {
return Query.historicalInfo(req, {
headers,
pathPrefix: this.url
});
}
/** Pool queries the pool info. */
async pool(req: QueryPoolRequest, headers?: HeadersInit): Promise<QueryPoolResponse> {
return Query.pool(req, {
headers,
pathPrefix: this.url
});
}
/** Parameters queries the staking parameters. */
async params(req: QueryParamsRequest, headers?: HeadersInit): Promise<QueryParamsResponse> {
return Query.params(req, {
headers,
pathPrefix: this.url
});
}
}"
`;
exports[`GRPC-Gateway Service Client 1`] = `
"export class Service {
/** Simulate simulates executing a transaction for estimating gas usage. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,13 @@ it('GRPC-Gateway Service Client', () => {
const context = new GenericParseContext(ref, store, store.options);
expectCode(createGRPCGatewayQueryClass(context, service));
expectCode(createGRPCGatewayWrapperClass(context, service));
});

it('GRPC-Gateway Query Client with 2 params', () => {
const ref = store.findProto('cosmos/staking/v1beta1/query.proto');
const res = traverse(store, ref);
const service: ProtoService = getNestedProto(res).Query;
const context = new GenericParseContext(ref, store, store.options);
expectCode(createGRPCGatewayQueryClass(context, service));
expectCode(createGRPCGatewayWrapperClass(context, service));
});

0 comments on commit 37e9564

Please sign in to comment.