mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-11 14:09:15 +00:00
cosmwasm-stargate: Update tests for stargate changes
This commit is contained in:
parent
dc21d72be7
commit
b52add190a
@ -15,14 +15,7 @@ import {
|
|||||||
import { assert, assertDefined } from "@cosmjs/utils";
|
import { assert, assertDefined } from "@cosmjs/utils";
|
||||||
import Long from "long";
|
import Long from "long";
|
||||||
|
|
||||||
import {
|
import { MsgExecuteContract, MsgInstantiateContract, MsgStoreCode } from "../codec/x/wasm/internal/types/tx";
|
||||||
MsgExecuteContract,
|
|
||||||
MsgExecuteContractResponse,
|
|
||||||
MsgInstantiateContract,
|
|
||||||
MsgInstantiateContractResponse,
|
|
||||||
MsgStoreCode,
|
|
||||||
MsgStoreCodeResponse,
|
|
||||||
} from "../codec/x/wasm/internal/types/tx";
|
|
||||||
import { ContractCodeHistoryOperationType } from "../codec/x/wasm/internal/types/types";
|
import { ContractCodeHistoryOperationType } from "../codec/x/wasm/internal/types/types";
|
||||||
import { SigningCosmWasmClient } from "../signingcosmwasmclient";
|
import { SigningCosmWasmClient } from "../signingcosmwasmclient";
|
||||||
import {
|
import {
|
||||||
@ -30,7 +23,6 @@ import {
|
|||||||
base64Matcher,
|
base64Matcher,
|
||||||
bech32AddressMatcher,
|
bech32AddressMatcher,
|
||||||
ContractUploadInstructions,
|
ContractUploadInstructions,
|
||||||
fromOneElementArray,
|
|
||||||
getHackatom,
|
getHackatom,
|
||||||
makeRandomAddress,
|
makeRandomAddress,
|
||||||
makeWasmClient,
|
makeWasmClient,
|
||||||
@ -393,13 +385,8 @@ describe("WasmExtension", () => {
|
|||||||
codeId = Number.parseInt(codeIdAttr.value, 10);
|
codeId = Number.parseInt(codeIdAttr.value, 10);
|
||||||
expect(codeId).toBeGreaterThanOrEqual(1);
|
expect(codeId).toBeGreaterThanOrEqual(1);
|
||||||
expect(codeId).toBeLessThanOrEqual(200);
|
expect(codeId).toBeLessThanOrEqual(200);
|
||||||
|
const actionAttr = logs.findAttribute(parsedLogs, "message", "action");
|
||||||
assertDefined(result.data);
|
expect(actionAttr.value).toEqual("store-code");
|
||||||
const msgData = fromOneElementArray(result.data);
|
|
||||||
expect(msgData.msgType).toEqual("store-code");
|
|
||||||
expect(MsgStoreCodeResponse.decode(msgData.data)).toEqual(
|
|
||||||
MsgStoreCodeResponse.fromPartial({ codeId: Long.fromNumber(codeId, true) }),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let contractAddress: string;
|
let contractAddress: string;
|
||||||
@ -413,12 +400,8 @@ describe("WasmExtension", () => {
|
|||||||
contractAddress = contractAddressAttr.value;
|
contractAddress = contractAddressAttr.value;
|
||||||
const amountAttr = logs.findAttribute(parsedLogs, "transfer", "amount");
|
const amountAttr = logs.findAttribute(parsedLogs, "transfer", "amount");
|
||||||
expect(amountAttr.value).toEqual("1234ucosm,321ustake");
|
expect(amountAttr.value).toEqual("1234ucosm,321ustake");
|
||||||
|
const actionAttr = logs.findAttribute(parsedLogs, "message", "action");
|
||||||
assertDefined(result.data);
|
expect(actionAttr.value).toEqual("instantiate");
|
||||||
const msgData = fromOneElementArray(result.data);
|
|
||||||
expect(msgData.msgType).toEqual("instantiate");
|
|
||||||
const response = MsgInstantiateContractResponse.decode(msgData.data);
|
|
||||||
expect(response).toEqual(MsgInstantiateContractResponse.fromPartial({ address: contractAddress }));
|
|
||||||
|
|
||||||
const balanceUcosm = await client.bank.balance(contractAddress, "ucosm");
|
const balanceUcosm = await client.bank.balance(contractAddress, "ucosm");
|
||||||
expect(balanceUcosm).toEqual(transferAmount[0]);
|
expect(balanceUcosm).toEqual(transferAmount[0]);
|
||||||
@ -439,13 +422,6 @@ describe("WasmExtension", () => {
|
|||||||
value: beneficiaryAddress,
|
value: beneficiaryAddress,
|
||||||
});
|
});
|
||||||
|
|
||||||
assertDefined(result.data);
|
|
||||||
const msgData = fromOneElementArray(result.data);
|
|
||||||
expect(msgData.msgType).toEqual("execute");
|
|
||||||
expect(MsgExecuteContractResponse.decode(msgData.data)).toEqual(
|
|
||||||
MsgExecuteContractResponse.fromPartial({ data: fromHex("F00BAA") }),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Verify token transfer from contract to beneficiary
|
// Verify token transfer from contract to beneficiary
|
||||||
const beneficiaryBalanceUcosm = await client.bank.balance(beneficiaryAddress, "ucosm");
|
const beneficiaryBalanceUcosm = await client.bank.balance(beneficiaryAddress, "ucosm");
|
||||||
expect(beneficiaryBalanceUcosm).toEqual(transferAmount[0]);
|
expect(beneficiaryBalanceUcosm).toEqual(transferAmount[0]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user