Dedup wasmdEndpoint, faucet
This commit is contained in:
parent
a43a81b0ff
commit
5aca5ebd69
@ -7,25 +7,15 @@ import { RestClient } from "./restclient";
|
||||
import { SigningCosmWasmClient } from "./signingcosmwasmclient";
|
||||
import {
|
||||
deployedErc20,
|
||||
faucet,
|
||||
fromOneElementArray,
|
||||
makeRandomAddress,
|
||||
pendingWithoutWasmd,
|
||||
wasmdEnabled,
|
||||
wasmdEndpoint,
|
||||
} from "./testutils.spec";
|
||||
import { Coin, CosmosSdkTx, isMsgExecuteContract, isMsgInstantiateContract, isMsgSend } from "./types";
|
||||
|
||||
const httpUrl = "http://localhost:1317";
|
||||
|
||||
const faucet = {
|
||||
mnemonic:
|
||||
"economy stock theory fatal elder harbor betray wasp final emotion task crumble siren bottom lizard educate guess current outdoor pair theory focus wife stone",
|
||||
pubkey: {
|
||||
type: "tendermint/PubKeySecp256k1",
|
||||
value: "A08EGB7ro1ORuFhjOnZcSgwYlpe0DSFjVNUIkNNQxwKQ",
|
||||
},
|
||||
address: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
};
|
||||
|
||||
describe("CosmWasmClient.searchTx", () => {
|
||||
let postedSend:
|
||||
| {
|
||||
@ -49,7 +39,9 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
beforeAll(async () => {
|
||||
if (wasmdEnabled()) {
|
||||
const pen = await Secp256k1Pen.fromMnemonic(faucet.mnemonic);
|
||||
const client = new SigningCosmWasmClient(httpUrl, faucet.address, signBytes => pen.sign(signBytes));
|
||||
const client = new SigningCosmWasmClient(wasmdEndpoint, faucet.address, signBytes =>
|
||||
pen.sign(signBytes),
|
||||
);
|
||||
|
||||
{
|
||||
const recipient = makeRandomAddress();
|
||||
@ -59,7 +51,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
};
|
||||
const result = await client.sendTokens(recipient, [transferAmount]);
|
||||
await sleep(50); // wait until tx is indexed
|
||||
const txDetails = await new RestClient(httpUrl).txsById(result.transactionHash);
|
||||
const txDetails = await new RestClient(wasmdEndpoint).txsById(result.transactionHash);
|
||||
postedSend = {
|
||||
sender: faucet.address,
|
||||
recipient: recipient,
|
||||
@ -79,7 +71,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
};
|
||||
const result = await client.execute(hashInstance, msg);
|
||||
await sleep(50); // wait until tx is indexed
|
||||
const txDetails = await new RestClient(httpUrl).txsById(result.transactionHash);
|
||||
const txDetails = await new RestClient(wasmdEndpoint).txsById(result.transactionHash);
|
||||
postedExecute = {
|
||||
sender: faucet.address,
|
||||
contract: hashInstance,
|
||||
@ -95,7 +87,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
it("can search by ID", async () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(postedSend, "value must be set in beforeAll()");
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
const result = await client.searchTx({ id: postedSend.hash });
|
||||
expect(result.length).toEqual(1);
|
||||
expect(result[0]).toEqual(
|
||||
@ -109,7 +101,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
|
||||
it("can search by ID (non existent)", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
const nonExistentId = "0000000000000000000000000000000000000000000000000000000000000000";
|
||||
const result = await client.searchTx({ id: nonExistentId });
|
||||
expect(result.length).toEqual(0);
|
||||
@ -118,7 +110,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
it("can search by ID and filter by minHeight", async () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(postedSend);
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
const query = { id: postedSend.hash };
|
||||
|
||||
{
|
||||
@ -147,7 +139,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
it("can search by height", async () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(postedSend, "value must be set in beforeAll()");
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
const result = await client.searchTx({ height: postedSend.height });
|
||||
expect(result.length).toEqual(1);
|
||||
expect(result[0]).toEqual(
|
||||
@ -164,7 +156,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
it("can search by sender", async () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(postedSend, "value must be set in beforeAll()");
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
const results = await client.searchTx({ sentFromOrTo: postedSend.sender });
|
||||
expect(results.length).toBeGreaterThanOrEqual(1);
|
||||
|
||||
@ -190,7 +182,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
it("can search by recipient", async () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(postedSend, "value must be set in beforeAll()");
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
const results = await client.searchTx({ sentFromOrTo: postedSend.recipient });
|
||||
expect(results.length).toBeGreaterThanOrEqual(1);
|
||||
|
||||
@ -216,7 +208,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
it("can search by recipient and filter by minHeight", async () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(postedSend);
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
const query = { sentFromOrTo: postedSend.recipient };
|
||||
|
||||
{
|
||||
@ -243,7 +235,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
it("can search by recipient and filter by maxHeight", async () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(postedSend);
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
const query = { sentFromOrTo: postedSend.recipient };
|
||||
|
||||
{
|
||||
@ -272,7 +264,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
it("can search by transfer.recipient", async () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(postedSend, "value must be set in beforeAll()");
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
const results = await client.searchTx({
|
||||
tags: [{ key: "transfer.recipient", value: postedSend.recipient }],
|
||||
});
|
||||
@ -298,7 +290,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
it("can search by message.contract_address", async () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(postedExecute, "value must be set in beforeAll()");
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
const results = await client.searchTx({
|
||||
tags: [{ key: "message.contract_address", value: postedExecute.contract }],
|
||||
});
|
||||
@ -340,7 +332,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
it("can search by message.contract_address + message.action", async () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(postedExecute, "value must be set in beforeAll()");
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
const results = await client.searchTx({
|
||||
tags: [
|
||||
{ key: "message.contract_address", value: postedExecute.contract },
|
||||
|
||||
@ -12,28 +12,18 @@ import { SigningCosmWasmClient } from "./signingcosmwasmclient";
|
||||
import cosmoshub from "./testdata/cosmoshub.json";
|
||||
import {
|
||||
deployedErc20,
|
||||
faucet,
|
||||
getRandomizedHackatom,
|
||||
makeRandomAddress,
|
||||
pendingWithoutWasmd,
|
||||
tendermintIdMatcher,
|
||||
wasmdEnabled,
|
||||
wasmdEndpoint,
|
||||
} from "./testutils.spec";
|
||||
import { MsgSend, StdFee } from "./types";
|
||||
|
||||
const { fromAscii, fromHex, fromUtf8, toAscii, toBase64 } = Encoding;
|
||||
|
||||
const httpUrl = "http://localhost:1317";
|
||||
|
||||
const faucet = {
|
||||
mnemonic:
|
||||
"economy stock theory fatal elder harbor betray wasp final emotion task crumble siren bottom lizard educate guess current outdoor pair theory focus wife stone",
|
||||
pubkey: {
|
||||
type: "tendermint/PubKeySecp256k1",
|
||||
value: "A08EGB7ro1ORuFhjOnZcSgwYlpe0DSFjVNUIkNNQxwKQ",
|
||||
},
|
||||
address: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
};
|
||||
|
||||
const unused = {
|
||||
address: "cosmos1cjsxept9rkggzxztslae9ndgpdyt2408lk850u",
|
||||
};
|
||||
@ -53,7 +43,7 @@ interface HackatomInstance {
|
||||
describe("CosmWasmClient", () => {
|
||||
describe("makeReadOnly", () => {
|
||||
it("can be constructed", () => {
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
expect(client).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@ -61,7 +51,7 @@ describe("CosmWasmClient", () => {
|
||||
describe("chainId", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
expect(await client.chainId()).toEqual("testing");
|
||||
});
|
||||
});
|
||||
@ -69,7 +59,7 @@ describe("CosmWasmClient", () => {
|
||||
describe("getNonce", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
expect(await client.getNonce(unused.address)).toEqual({
|
||||
accountNumber: 5,
|
||||
sequence: 0,
|
||||
@ -78,7 +68,7 @@ describe("CosmWasmClient", () => {
|
||||
|
||||
it("throws for missing accounts", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
const missing = makeRandomAddress();
|
||||
await client.getNonce(missing).then(
|
||||
() => fail("this must not succeed"),
|
||||
@ -90,7 +80,7 @@ describe("CosmWasmClient", () => {
|
||||
describe("getAccount", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
expect(await client.getAccount(unused.address)).toEqual({
|
||||
address: unused.address,
|
||||
account_number: 5,
|
||||
@ -105,7 +95,7 @@ describe("CosmWasmClient", () => {
|
||||
|
||||
it("returns undefined for missing accounts", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
const missing = makeRandomAddress();
|
||||
expect(await client.getAccount(missing)).toBeUndefined();
|
||||
});
|
||||
@ -114,7 +104,7 @@ describe("CosmWasmClient", () => {
|
||||
describe("getBlock", () => {
|
||||
it("works for latest block", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
const response = await client.getBlock();
|
||||
|
||||
// id
|
||||
@ -134,7 +124,7 @@ describe("CosmWasmClient", () => {
|
||||
|
||||
it("works for block by height", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
const height = parseInt((await client.getBlock()).block.header.height, 10);
|
||||
const response = await client.getBlock(height - 1);
|
||||
|
||||
@ -157,7 +147,7 @@ describe("CosmWasmClient", () => {
|
||||
describe("getIdentifier", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
expect(await client.getIdentifier(cosmoshub.tx)).toEqual(cosmoshub.id);
|
||||
});
|
||||
});
|
||||
@ -166,7 +156,7 @@ describe("CosmWasmClient", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const pen = await Secp256k1Pen.fromMnemonic(faucet.mnemonic);
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
|
||||
const memo = "My first contract on chain";
|
||||
const sendMsg: MsgSend = {
|
||||
@ -213,7 +203,7 @@ describe("CosmWasmClient", () => {
|
||||
describe("getCodes", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
const result = await client.getCodes();
|
||||
expect(result.length).toBeGreaterThanOrEqual(1);
|
||||
const [first] = result;
|
||||
@ -230,7 +220,7 @@ describe("CosmWasmClient", () => {
|
||||
describe("getCodeDetails", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
const result = await client.getCodeDetails(1);
|
||||
|
||||
const expectedInfo: Code = {
|
||||
@ -251,7 +241,7 @@ describe("CosmWasmClient", () => {
|
||||
describe("getContracts", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
const result = await client.getContracts(1);
|
||||
expect(result.length).toBeGreaterThanOrEqual(3);
|
||||
const [hash, isa, jade] = result;
|
||||
@ -279,7 +269,7 @@ describe("CosmWasmClient", () => {
|
||||
describe("getContract", () => {
|
||||
it("works for HASH instance", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
const hash = await client.getContract("cosmos18vd8fpwxzck93qlwghaj6arh4p7c5n89uzcee5");
|
||||
expect(hash).toEqual({
|
||||
address: "cosmos18vd8fpwxzck93qlwghaj6arh4p7c5n89uzcee5",
|
||||
@ -318,7 +308,9 @@ describe("CosmWasmClient", () => {
|
||||
if (wasmdEnabled()) {
|
||||
pendingWithoutWasmd();
|
||||
const pen = await Secp256k1Pen.fromMnemonic(faucet.mnemonic);
|
||||
const client = new SigningCosmWasmClient(httpUrl, faucet.address, signBytes => pen.sign(signBytes));
|
||||
const client = new SigningCosmWasmClient(wasmdEndpoint, faucet.address, signBytes =>
|
||||
pen.sign(signBytes),
|
||||
);
|
||||
const { codeId } = await client.upload(getRandomizedHackatom());
|
||||
const initMsg = { verifier: makeRandomAddress(), beneficiary: makeRandomAddress() };
|
||||
const contractAddress = await client.instantiate(codeId, initMsg, "random hackatom");
|
||||
@ -330,7 +322,7 @@ describe("CosmWasmClient", () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(contract);
|
||||
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
const raw = await client.queryContractRaw(contract.address, configKey);
|
||||
assert(raw, "must get result");
|
||||
expect(JSON.parse(fromUtf8(raw))).toEqual({
|
||||
@ -344,7 +336,7 @@ describe("CosmWasmClient", () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(contract);
|
||||
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
const raw = await client.queryContractRaw(contract.address, otherKey);
|
||||
expect(raw).toBeNull();
|
||||
});
|
||||
@ -354,7 +346,7 @@ describe("CosmWasmClient", () => {
|
||||
assert(contract);
|
||||
|
||||
const nonExistentAddress = makeRandomAddress();
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
await client.queryContractRaw(nonExistentAddress, configKey).then(
|
||||
() => fail("must not succeed"),
|
||||
error => expect(error).toMatch(`No contract found at address "${nonExistentAddress}"`),
|
||||
@ -369,7 +361,9 @@ describe("CosmWasmClient", () => {
|
||||
if (wasmdEnabled()) {
|
||||
pendingWithoutWasmd();
|
||||
const pen = await Secp256k1Pen.fromMnemonic(faucet.mnemonic);
|
||||
const client = new SigningCosmWasmClient(httpUrl, faucet.address, signBytes => pen.sign(signBytes));
|
||||
const client = new SigningCosmWasmClient(wasmdEndpoint, faucet.address, signBytes =>
|
||||
pen.sign(signBytes),
|
||||
);
|
||||
const { codeId } = await client.upload(getRandomizedHackatom());
|
||||
const initMsg = { verifier: makeRandomAddress(), beneficiary: makeRandomAddress() };
|
||||
const contractAddress = await client.instantiate(codeId, initMsg, "a different hackatom");
|
||||
@ -381,7 +375,7 @@ describe("CosmWasmClient", () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(contract);
|
||||
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
const verifier = await client.queryContractSmart(contract.address, { verifier: {} });
|
||||
expect(fromAscii(verifier)).toEqual(contract.initMsg.verifier);
|
||||
});
|
||||
@ -390,7 +384,7 @@ describe("CosmWasmClient", () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(contract);
|
||||
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
await client.queryContractSmart(contract.address, { broken: {} }).then(
|
||||
() => fail("must not succeed"),
|
||||
error => expect(error).toMatch(/Error parsing QueryMsg/i),
|
||||
@ -401,7 +395,7 @@ describe("CosmWasmClient", () => {
|
||||
pendingWithoutWasmd();
|
||||
|
||||
const nonExistentAddress = makeRandomAddress();
|
||||
const client = new CosmWasmClient(httpUrl);
|
||||
const client = new CosmWasmClient(wasmdEndpoint);
|
||||
await client.queryContractSmart(nonExistentAddress, { verifier: {} }).then(
|
||||
() => fail("must not succeed"),
|
||||
error => expect(error).toMatch(`No contract found at address "${nonExistentAddress}"`),
|
||||
|
||||
@ -14,6 +14,7 @@ import cosmoshub from "./testdata/cosmoshub.json";
|
||||
import {
|
||||
bech32AddressMatcher,
|
||||
deployedErc20,
|
||||
faucet,
|
||||
fromOneElementArray,
|
||||
getRandomizedHackatom,
|
||||
makeRandomAddress,
|
||||
@ -22,6 +23,7 @@ import {
|
||||
tendermintIdMatcher,
|
||||
tendermintOptionalIdMatcher,
|
||||
wasmdEnabled,
|
||||
wasmdEndpoint,
|
||||
} from "./testutils.spec";
|
||||
import {
|
||||
Coin,
|
||||
@ -39,17 +41,7 @@ import {
|
||||
|
||||
const { fromAscii, fromBase64, fromHex, toAscii, toBase64, toHex } = Encoding;
|
||||
|
||||
const httpUrl = "http://localhost:1317";
|
||||
const defaultNetworkId = "testing";
|
||||
const faucet = {
|
||||
mnemonic:
|
||||
"economy stock theory fatal elder harbor betray wasp final emotion task crumble siren bottom lizard educate guess current outdoor pair theory focus wife stone",
|
||||
pubkey: {
|
||||
type: "tendermint/PubKeySecp256k1",
|
||||
value: "A08EGB7ro1ORuFhjOnZcSgwYlpe0DSFjVNUIkNNQxwKQ",
|
||||
},
|
||||
address: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
};
|
||||
const emptyAddress = "cosmos1ltkhnmdcqemmd2tkhnx7qx66tq7e0wykw2j85k";
|
||||
const unusedAccount = {
|
||||
address: "cosmos1cjsxept9rkggzxztslae9ndgpdyt2408lk850u",
|
||||
@ -172,7 +164,7 @@ async function executeContract(
|
||||
|
||||
describe("RestClient", () => {
|
||||
it("can be constructed", () => {
|
||||
const client = new RestClient(httpUrl);
|
||||
const client = new RestClient(wasmdEndpoint);
|
||||
expect(client).toBeTruthy();
|
||||
});
|
||||
|
||||
@ -181,7 +173,7 @@ describe("RestClient", () => {
|
||||
describe("authAccounts", () => {
|
||||
it("works for unused account without pubkey", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = new RestClient(httpUrl);
|
||||
const client = new RestClient(wasmdEndpoint);
|
||||
const { result } = await client.authAccounts(unusedAccount.address);
|
||||
expect(result).toEqual({
|
||||
type: "cosmos-sdk/Account",
|
||||
@ -207,7 +199,7 @@ describe("RestClient", () => {
|
||||
// This fails in the first test run if you forget to run `./scripts/wasmd/init.sh`
|
||||
it("has correct pubkey for faucet", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = new RestClient(httpUrl);
|
||||
const client = new RestClient(wasmdEndpoint);
|
||||
const { result } = await client.authAccounts(faucet.address);
|
||||
expect(result.value).toEqual(
|
||||
jasmine.objectContaining({
|
||||
@ -219,7 +211,7 @@ describe("RestClient", () => {
|
||||
// This property is used by CosmWasmClient.getAccount
|
||||
it("returns empty address for non-existent account", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = new RestClient(httpUrl);
|
||||
const client = new RestClient(wasmdEndpoint);
|
||||
const nonExistentAccount = makeRandomAddress();
|
||||
const { result } = await client.authAccounts(nonExistentAccount);
|
||||
expect(result).toEqual({
|
||||
@ -234,7 +226,7 @@ describe("RestClient", () => {
|
||||
describe("blocksLatest", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = new RestClient(httpUrl);
|
||||
const client = new RestClient(wasmdEndpoint);
|
||||
const response = await client.blocksLatest();
|
||||
|
||||
// id
|
||||
@ -267,7 +259,7 @@ describe("RestClient", () => {
|
||||
describe("blocks", () => {
|
||||
it("works for block by height", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = new RestClient(httpUrl);
|
||||
const client = new RestClient(wasmdEndpoint);
|
||||
const height = parseInt((await client.blocksLatest()).block.header.height, 10);
|
||||
const response = await client.blocks(height - 1);
|
||||
|
||||
@ -303,7 +295,7 @@ describe("RestClient", () => {
|
||||
describe("nodeInfo", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = new RestClient(httpUrl);
|
||||
const client = new RestClient(wasmdEndpoint);
|
||||
const info = await client.nodeInfo();
|
||||
expect(info.node_info.network).toEqual(defaultNetworkId);
|
||||
});
|
||||
@ -325,7 +317,9 @@ describe("RestClient", () => {
|
||||
beforeAll(async () => {
|
||||
if (wasmdEnabled()) {
|
||||
const pen = await Secp256k1Pen.fromMnemonic(faucet.mnemonic);
|
||||
const client = new SigningCosmWasmClient(httpUrl, faucet.address, signBytes => pen.sign(signBytes));
|
||||
const client = new SigningCosmWasmClient(wasmdEndpoint, faucet.address, signBytes =>
|
||||
pen.sign(signBytes),
|
||||
);
|
||||
|
||||
const recipient = makeRandomAddress();
|
||||
const transferAmount = [
|
||||
@ -337,7 +331,7 @@ describe("RestClient", () => {
|
||||
const result = await client.sendTokens(recipient, transferAmount);
|
||||
|
||||
await sleep(50); // wait until tx is indexed
|
||||
const txDetails = await new RestClient(httpUrl).txsById(result.transactionHash);
|
||||
const txDetails = await new RestClient(wasmdEndpoint).txsById(result.transactionHash);
|
||||
posted = {
|
||||
sender: faucet.address,
|
||||
recipient: recipient,
|
||||
@ -351,7 +345,7 @@ describe("RestClient", () => {
|
||||
it("can query transactions by height", async () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(posted);
|
||||
const client = new RestClient(httpUrl);
|
||||
const client = new RestClient(wasmdEndpoint);
|
||||
const result = await client.txsQuery(`tx.height=${posted.height}&limit=26`);
|
||||
expect(parseInt(result.count, 10)).toEqual(1);
|
||||
expect(parseInt(result.limit, 10)).toEqual(26);
|
||||
@ -364,7 +358,7 @@ describe("RestClient", () => {
|
||||
it("can query transactions by ID", async () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(posted);
|
||||
const client = new RestClient(httpUrl);
|
||||
const client = new RestClient(wasmdEndpoint);
|
||||
const result = await client.txsQuery(`tx.hash=${posted.hash}&limit=26`);
|
||||
expect(parseInt(result.count, 10)).toEqual(1);
|
||||
expect(parseInt(result.limit, 10)).toEqual(26);
|
||||
@ -377,7 +371,7 @@ describe("RestClient", () => {
|
||||
it("can query transactions by sender", async () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(posted);
|
||||
const client = new RestClient(httpUrl);
|
||||
const client = new RestClient(wasmdEndpoint);
|
||||
const result = await client.txsQuery(`message.sender=${posted.sender}&limit=200`);
|
||||
expect(parseInt(result.count, 10)).toBeGreaterThanOrEqual(1);
|
||||
expect(parseInt(result.limit, 10)).toEqual(200);
|
||||
@ -391,7 +385,7 @@ describe("RestClient", () => {
|
||||
it("can query transactions by recipient", async () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(posted);
|
||||
const client = new RestClient(httpUrl);
|
||||
const client = new RestClient(wasmdEndpoint);
|
||||
const result = await client.txsQuery(`transfer.recipient=${posted.recipient}&limit=200`);
|
||||
expect(parseInt(result.count, 10)).toEqual(1);
|
||||
expect(parseInt(result.limit, 10)).toEqual(200);
|
||||
@ -406,7 +400,7 @@ describe("RestClient", () => {
|
||||
pending("This combination is broken 🤷♂️. Handle client-side at higher level.");
|
||||
pendingWithoutWasmd();
|
||||
assert(posted);
|
||||
const client = new RestClient(httpUrl);
|
||||
const client = new RestClient(wasmdEndpoint);
|
||||
const hashQuery = `tx.hash=${posted.hash}`;
|
||||
|
||||
{
|
||||
@ -433,7 +427,7 @@ describe("RestClient", () => {
|
||||
it("can filter by recipient and tx.minheight", async () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(posted);
|
||||
const client = new RestClient(httpUrl);
|
||||
const client = new RestClient(wasmdEndpoint);
|
||||
const recipientQuery = `transfer.recipient=${posted.recipient}`;
|
||||
|
||||
{
|
||||
@ -460,7 +454,7 @@ describe("RestClient", () => {
|
||||
it("can filter by recipient and tx.maxheight", async () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(posted);
|
||||
const client = new RestClient(httpUrl);
|
||||
const client = new RestClient(wasmdEndpoint);
|
||||
const recipientQuery = `transfer.recipient=${posted.recipient}`;
|
||||
|
||||
{
|
||||
@ -487,7 +481,7 @@ describe("RestClient", () => {
|
||||
it("can query by tags (module + code_id)", async () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(posted);
|
||||
const client = new RestClient(httpUrl);
|
||||
const client = new RestClient(wasmdEndpoint);
|
||||
const result = await client.txsQuery(`message.module=wasm&message.code_id=${deployedErc20.codeId}`);
|
||||
expect(parseInt(result.count, 10)).toBeGreaterThanOrEqual(4);
|
||||
|
||||
@ -533,7 +527,7 @@ describe("RestClient", () => {
|
||||
it("can query by tags (module + code_id + action)", async () => {
|
||||
pendingWithoutWasmd();
|
||||
assert(posted);
|
||||
const client = new RestClient(httpUrl);
|
||||
const client = new RestClient(wasmdEndpoint);
|
||||
|
||||
{
|
||||
const uploads = await client.txsQuery(
|
||||
@ -590,7 +584,7 @@ describe("RestClient", () => {
|
||||
describe("encodeTx", () => {
|
||||
it("works for cosmoshub example", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const client = new RestClient(httpUrl);
|
||||
const client = new RestClient(wasmdEndpoint);
|
||||
expect(await client.encodeTx(cosmoshub.tx)).toEqual(fromBase64(cosmoshub.tx_data));
|
||||
});
|
||||
});
|
||||
@ -625,7 +619,7 @@ describe("RestClient", () => {
|
||||
gas: "890000",
|
||||
};
|
||||
|
||||
const client = new RestClient(httpUrl);
|
||||
const client = new RestClient(wasmdEndpoint);
|
||||
const { account_number, sequence } = (await client.authAccounts(faucet.address)).result.value;
|
||||
|
||||
const signBytes = makeSignBytes([theMsg], fee, defaultNetworkId, memo, account_number, sequence);
|
||||
@ -639,7 +633,7 @@ describe("RestClient", () => {
|
||||
it("can upload, instantiate and execute wasm", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const pen = await Secp256k1Pen.fromMnemonic(faucet.mnemonic);
|
||||
const client = new RestClient(httpUrl);
|
||||
const client = new RestClient(wasmdEndpoint);
|
||||
|
||||
const transferAmount: readonly Coin[] = [
|
||||
{
|
||||
@ -713,7 +707,7 @@ describe("RestClient", () => {
|
||||
it("can list upload code", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const pen = await Secp256k1Pen.fromMnemonic(faucet.mnemonic);
|
||||
const client = new RestClient(httpUrl);
|
||||
const client = new RestClient(wasmdEndpoint);
|
||||
|
||||
// check with contracts were here first to compare
|
||||
const existingInfos = await client.listCodeInfo();
|
||||
@ -753,7 +747,7 @@ describe("RestClient", () => {
|
||||
it("can list contracts and get info", async () => {
|
||||
pendingWithoutWasmd();
|
||||
const pen = await Secp256k1Pen.fromMnemonic(faucet.mnemonic);
|
||||
const client = new RestClient(httpUrl);
|
||||
const client = new RestClient(wasmdEndpoint);
|
||||
const beneficiaryAddress = makeRandomAddress();
|
||||
const transferAmount: readonly Coin[] = [
|
||||
{
|
||||
@ -814,7 +808,7 @@ describe("RestClient", () => {
|
||||
});
|
||||
|
||||
describe("contract state", () => {
|
||||
const client = new RestClient(httpUrl);
|
||||
const client = new RestClient(wasmdEndpoint);
|
||||
const noContract = makeRandomAddress();
|
||||
const expectedKey = toAscii("config");
|
||||
let contractAddress: string | undefined;
|
||||
|
||||
@ -76,6 +76,18 @@ export const deployedErc20 = {
|
||||
],
|
||||
};
|
||||
|
||||
export const wasmdEndpoint = "http://localhost:1317";
|
||||
|
||||
export const faucet = {
|
||||
mnemonic:
|
||||
"economy stock theory fatal elder harbor betray wasp final emotion task crumble siren bottom lizard educate guess current outdoor pair theory focus wife stone",
|
||||
pubkey: {
|
||||
type: "tendermint/PubKeySecp256k1",
|
||||
value: "A08EGB7ro1ORuFhjOnZcSgwYlpe0DSFjVNUIkNNQxwKQ",
|
||||
},
|
||||
address: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
|
||||
};
|
||||
|
||||
export function wasmdEnabled(): boolean {
|
||||
return !!process.env.WASMD_ENABLED;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user