Clean up test cases

This commit is contained in:
Ethan Frey 2020-02-16 20:12:04 +01:00 committed by Simon Warta
parent 6d3865a27e
commit 2d7c4e09a3
3 changed files with 13 additions and 43 deletions

View File

@ -222,50 +222,23 @@ describe("CosmWasmClient", () => {
beforeAll(async () => {
if (cosmosEnabled()) {
const pen = await Secp256k1Pen.fromMnemonic(faucet.mnemonic);
const client = CosmWasmClient.makeReadOnly(httpUrl);
const client = CosmWasmClient.makeWritable(httpUrl, faucet.address, signBytes => pen.sign(signBytes));
const memo = "My first contract on chain";
const sendMsg: MsgSend = {
type: "cosmos-sdk/MsgSend",
value: {
from_address: faucet.address,
to_address: makeRandomAddress(),
amount: [
{
denom: "ucosm",
amount: "1234567",
},
],
const recipient = makeRandomAddress();
const transferAmount = [
{
denom: "ucosm",
amount: "1234567",
},
};
];
const result = await client.sendToken(recipient, transferAmount, memo);
const fee: StdFee = {
amount: [
{
amount: "5000",
denom: "ucosm",
},
],
gas: "890000",
};
const chainId = await client.chainId();
const { accountNumber, sequence } = await client.getNonce(faucet.address);
const signBytes = makeSignBytes([sendMsg], fee, chainId, memo, accountNumber, sequence);
const signature = await pen.sign(signBytes);
const signedTx = {
msg: [sendMsg],
fee: fee,
memo: memo,
signatures: [signature],
};
const result = await client.postTx(marshalTx(signedTx));
await sleep(50); // wait until tx is indexed
const txDetails = await new RestClient(httpUrl).txsById(result.transactionHash);
posted = {
sender: sendMsg.value.from_address,
recipient: sendMsg.value.to_address,
sender: faucet.address,
recipient: recipient,
hash: result.transactionHash,
height: Number.parseInt(txDetails.height, 10),
tx: txDetails.tx,

View File

@ -334,7 +334,7 @@ export class CosmWasmClient {
recipientAddress: string,
transferAmount: readonly Coin[],
memo = "",
): Promise<ExecuteResult> {
): Promise<PostTxResult> {
const sendMsg: MsgSend = {
type: "cosmos-sdk/MsgSend",
value: {
@ -357,10 +357,7 @@ export class CosmWasmClient {
signatures: [signature],
};
const result = await this.postTx(marshalTx(signedTx));
return {
logs: result.logs,
};
return this.postTx(marshalTx(signedTx));
}
/**

View File

@ -83,7 +83,7 @@ export declare class CosmWasmClient {
memo?: string,
transferAmount?: readonly Coin[],
): Promise<ExecuteResult>;
sendToken(recipientAddress: string, transferAmount: readonly Coin[], memo?: string): Promise<ExecuteResult>;
sendToken(recipientAddress: string, transferAmount: readonly Coin[], memo?: string): Promise<PostTxResult>;
/**
* Returns the data at the key if present (raw contract dependent storage data)
* or null if no data at this key.