launchpad: Add PrivateSigningCosmosClient class to help tests

This commit is contained in:
willclarktech 2020-08-18 14:57:00 +01:00
parent 4571b9cb19
commit aee57597a2
No known key found for this signature in database
GPG Key ID: 551A86E2E398ADF7
2 changed files with 12 additions and 4 deletions

View File

@ -6,7 +6,7 @@ import { assertIsBroadcastTxSuccess, PrivateCosmosClient } from "./cosmosclient"
import { GasPrice } from "./gas";
import { MsgDelegate } from "./msgs";
import { Secp256k1Wallet } from "./secp256k1wallet";
import { SigningCosmosClient } from "./signingcosmosclient";
import { PrivateSigningCosmosClient, SigningCosmosClient } from "./signingcosmosclient";
import { makeRandomAddress, pendingWithoutWasmd, validatorAddress } from "./testutils.spec";
const httpUrl = "http://localhost:1317";
@ -33,7 +33,8 @@ describe("SigningCosmosClient", () => {
const wallet = await Secp256k1Wallet.fromMnemonic(faucet.mnemonic);
const gasPrice = new GasPrice(3.14, "utest");
const client = new SigningCosmosClient(httpUrl, faucet.address, wallet, gasPrice);
expect((client as any).fees).toEqual({
const openedClient = (client as unknown) as PrivateSigningCosmosClient;
expect(openedClient.fees).toEqual({
send: {
amount: [
{
@ -52,7 +53,8 @@ describe("SigningCosmosClient", () => {
send: 160000,
};
const client = new SigningCosmosClient(httpUrl, faucet.address, wallet, undefined, gasLimits);
expect((client as any).fees).toEqual({
const openedClient = (client as unknown) as PrivateSigningCosmosClient;
expect(openedClient.fees).toEqual({
send: {
amount: [
{
@ -72,7 +74,8 @@ describe("SigningCosmosClient", () => {
send: 160000,
};
const client = new SigningCosmosClient(httpUrl, faucet.address, wallet, gasPrice, gasLimits);
expect((client as any).fees).toEqual({
const openedClient = (client as unknown) as PrivateSigningCosmosClient;
expect(openedClient.fees).toEqual({
send: {
amount: [
{

View File

@ -11,6 +11,11 @@ import { OfflineSigner } from "./wallet";
const defaultGasPrice = new GasPrice(0.025, "ucosm");
const defaultGasLimits: GasLimits = { send: 80000 };
/** Use for testing only */
export interface PrivateSigningCosmosClient {
readonly fees: FeeTable;
}
export class SigningCosmosClient extends CosmosClient {
public readonly senderAddress: string;