Skip to content

Commit

Permalink
test: Test case update
Browse files Browse the repository at this point in the history
  • Loading branch information
rrr523 committed Sep 8, 2023
1 parent 6d94a48 commit 989b07f
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 56 deletions.
19 changes: 19 additions & 0 deletions examples/nextjs/src/components/query/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,25 @@ export const QueryComponent = () => {
const { paymentAccounts } = await client.payment.getPaymentAccountsByOwner({
owner: address,
});
console.log('paymentAccounts', paymentAccounts);
const res = await client.payment.paymentAccount({
addr: paymentAccounts[0],
});
console.log('res', res);
}}
>
get paymentAccount
</button>
</li>
<li>
<button
onClick={async () => {
if (!address) return;

const { paymentAccounts } = await client.payment.getPaymentAccountsByOwner({
owner: address,
});
console.log('paymentAccounts', paymentAccounts);

const res = await client.bucket.listBucketsByPaymentAccount({
paymentAccount: paymentAccounts[0],
Expand Down
12 changes: 0 additions & 12 deletions packages/chain-sdk/src/api/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ export interface IAccount {
*/
getAccountBalance(request: QueryBalanceRequest): Promise<QueryBalanceResponse>;

/**
* takes an address string as parameters and returns a pointer to a paymentTypes.
*/
getPaymentAccount(request: QueryPaymentAccountRequest): Promise<QueryPaymentAccountResponse>;

getModuleAccounts(): Promise<QueryModuleAccountsResponse>;

getModuleAccountByName(name: string): Promise<QueryModuleAccountByNameResponse>;
Expand Down Expand Up @@ -110,13 +105,6 @@ export class Account implements IAccount {
return await rpc.ModuleAccounts();
}

public async getPaymentAccount(
request: QueryPaymentAccountRequest,
): Promise<QueryPaymentAccountResponse> {
const rpc = await this.queryClient.getPaymentQueryClient();
return await rpc.PaymentAccount(request);
}

public async getAccountBalance(request: QueryBalanceRequest): Promise<QueryBalanceResponse> {
const rpc = await this.queryClient.getBankQueryClient();
return await rpc.Balance(request);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@ describe('accountQuery', () => {
});
});

describe('getPaymentAccount', () => {
test('it works', async () => {
const res = await client.account.getPaymentAccount({
addr: ACCOUNT.address,
});

expect(res).not.toBeNull();
});
});

describe('getModuleAccounts', () => {
test('it works', async () => {
const res = await client.account.getModuleAccounts();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Client } from '..';
import { ISimulateGasFee } from '../types';
import { Client } from '../src';
import { ISimulateGasFee } from '../src/types';
import { ACCOUNT_ADDRESS, ACCOUNT_PRIVATEKEY, GREENFIELD_CHAIN_ID, GRPC_URL } from './.env';

export const client = Client.create(GRPC_URL, GREENFIELD_CHAIN_ID);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from 'chai';
import { parseListObjectsByBucketNameResponse } from '../clients/spclient/spApis/listObjectsByBucket';
import { parseGetUserBucketsResponse } from '../clients/spclient/spApis/getUserBuckets';
import { parseListObjectsByBucketNameResponse } from '../src/clients/spclient/spApis/listObjectsByBucket';
import { parseGetUserBucketsResponse } from '../src/clients/spclient/spApis/getUserBuckets';

describe('parseListObjectsByBucketNameResponse', () => {
test('parse CommonPrefixes contains 2 element at least', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ describe('groupTx', () => {
creator: ACCOUNT.address,
extra: EXTRA,
groupName: GROUP_NAME,
members: [ACCOUNT.address],
});

const simulateInfo = await createGroupTx.simulate({
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,22 @@ describe('storageTx', () => {

test('create bucket', async () => {
const spInfo = await selectSp();
const createBucketTx = await client.bucket.createBucket({
bucketName: BUCKET_NAME,
creator: ACCOUNT.address,
visibility: 'VISIBILITY_TYPE_PUBLIC_READ',
chargedReadQuota: '0',
spInfo,
signType: 'authTypeV2',
});
const createBucketTx = await client.bucket.createBucket(
{
bucketName: BUCKET_NAME,
creator: ACCOUNT.address,
visibility: 'VISIBILITY_TYPE_PUBLIC_READ',
chargedReadQuota: '0',
spInfo: {
primarySpAddress: spInfo.primarySpAddress,
},
paymentAddress: ACCOUNT.address,
},
{
type: 'ECDSA',
privateKey: ACCOUNT.privateKey,
},
);

const simulateInfo = await createBucketTx.simulate({
denom: 'BNB',
Expand Down Expand Up @@ -56,25 +64,28 @@ describe('storageTx', () => {
console.log('object name', OBJECT_NAME);

test('create Object', async () => {
const spInfo = await selectSp();
const createObjectTx = await client.object.createObject({
bucketName: BUCKET_NAME,
objectName: OBJECT_NAME,
spInfo,
contentLength: 0,
fileType: 'text/plain',
expectCheckSums: [
'47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',
'47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',
'47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',
'47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',
'47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',
'47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',
'47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',
],
creator: ACCOUNT.address,
signType: 'authTypeV2',
});
const createObjectTx = await client.object.createObject(
{
bucketName: BUCKET_NAME,
objectName: OBJECT_NAME,
contentLength: 0,
fileType: 'text/plain',
expectCheckSums: [
'47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',
'47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',
'47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',
'47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',
'47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',
'47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',
'47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU=',
],
creator: ACCOUNT.address,
},
{
type: 'ECDSA',
privateKey: ACCOUNT.privateKey,
},
);

const simulateInfo = await createObjectTx.simulate({
denom: 'BNB',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import { encodePath } from '../clients/spclient/auth';
import { encodePath } from '../src/clients/spclient/auth';

describe('encodePaths', () => {
it('encode english chars', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ async function makeTransferTx() {
return await client.account.transfer({
amount: [
{
amount: '10',
amount: '1000000000000000',
denom: 'BNB',
},
],
Expand Down

0 comments on commit 989b07f

Please sign in to comment.