mirror of
https://github.com/cosmos/cosmjs.git
synced 2025-03-11 14:09:15 +00:00
Make lcdapi/wasm.spec.ts independent of erc20
This commit is contained in:
parent
4af419b365
commit
195014b357
@ -33,11 +33,10 @@ import {
|
||||
base64Matcher,
|
||||
bech32AddressMatcher,
|
||||
ContractUploadInstructions,
|
||||
deployedErc20,
|
||||
deployedHackatom,
|
||||
fromOneElementArray,
|
||||
getHackatom,
|
||||
makeRandomAddress,
|
||||
pendingWithoutErc20,
|
||||
pendingWithoutWasmd,
|
||||
wasmd,
|
||||
wasmdEnabled,
|
||||
@ -373,45 +372,48 @@ describe("WasmExtension", () => {
|
||||
describe("txsQuery", () => {
|
||||
it("can query by tags (module + code_id)", async () => {
|
||||
pendingWithoutWasmd();
|
||||
pendingWithoutErc20();
|
||||
const client = makeWasmClient(wasmd.endpoint);
|
||||
const result = await client.txsQuery(`message.module=wasm&message.code_id=${deployedErc20.codeId}`);
|
||||
const result = await client.txsQuery(`message.module=wasm&message.code_id=${deployedHackatom.codeId}`);
|
||||
expect(parseInt(result.count, 10)).toBeGreaterThanOrEqual(4);
|
||||
|
||||
// Check first 4 results
|
||||
const [store, hash, isa, jade] = result.txs.map((tx) => fromOneElementArray(tx.tx.value.msg));
|
||||
const [store, zero, one, two] = result.txs.map((tx) => fromOneElementArray(tx.tx.value.msg));
|
||||
assert(isMsgStoreCode(store));
|
||||
assert(isMsgInstantiateContract(hash));
|
||||
assert(isMsgInstantiateContract(isa));
|
||||
assert(isMsgInstantiateContract(jade));
|
||||
assert(isMsgInstantiateContract(zero));
|
||||
assert(isMsgInstantiateContract(one));
|
||||
assert(isMsgInstantiateContract(two));
|
||||
expect(store.value).toEqual(
|
||||
jasmine.objectContaining({
|
||||
sender: alice.address0,
|
||||
source: deployedErc20.source,
|
||||
builder: deployedErc20.builder,
|
||||
source: deployedHackatom.source,
|
||||
builder: deployedHackatom.builder,
|
||||
}),
|
||||
);
|
||||
expect(hash.value).toEqual({
|
||||
code_id: deployedErc20.codeId.toString(),
|
||||
expect(zero.value).toEqual({
|
||||
code_id: deployedHackatom.codeId.toString(),
|
||||
init_funds: [],
|
||||
init_msg: jasmine.objectContaining({
|
||||
symbol: "HASH",
|
||||
beneficiary: deployedHackatom.instances[0].beneficiary,
|
||||
}),
|
||||
label: "HASH",
|
||||
label: deployedHackatom.instances[0].label,
|
||||
sender: alice.address0,
|
||||
});
|
||||
expect(isa.value).toEqual({
|
||||
code_id: deployedErc20.codeId.toString(),
|
||||
expect(one.value).toEqual({
|
||||
code_id: deployedHackatom.codeId.toString(),
|
||||
init_funds: [],
|
||||
init_msg: jasmine.objectContaining({ symbol: "ISA" }),
|
||||
label: "ISA",
|
||||
init_msg: jasmine.objectContaining({
|
||||
beneficiary: deployedHackatom.instances[1].beneficiary,
|
||||
}),
|
||||
label: deployedHackatom.instances[1].label,
|
||||
sender: alice.address0,
|
||||
});
|
||||
expect(jade.value).toEqual({
|
||||
code_id: deployedErc20.codeId.toString(),
|
||||
expect(two.value).toEqual({
|
||||
code_id: deployedHackatom.codeId.toString(),
|
||||
init_funds: [],
|
||||
init_msg: jasmine.objectContaining({ symbol: "JADE" }),
|
||||
label: "JADE",
|
||||
init_msg: jasmine.objectContaining({
|
||||
beneficiary: deployedHackatom.instances[2].beneficiary,
|
||||
}),
|
||||
label: deployedHackatom.instances[2].label,
|
||||
sender: alice.address0,
|
||||
admin: alice.address1,
|
||||
});
|
||||
@ -420,12 +422,11 @@ describe("WasmExtension", () => {
|
||||
// Like previous test but filtered by message.action=store-code and message.action=instantiate
|
||||
it("can query by tags (module + code_id + action)", async () => {
|
||||
pendingWithoutWasmd();
|
||||
pendingWithoutErc20();
|
||||
const client = makeWasmClient(wasmd.endpoint);
|
||||
|
||||
{
|
||||
const uploads = await client.txsQuery(
|
||||
`message.module=wasm&message.code_id=${deployedErc20.codeId}&message.action=store-code`,
|
||||
`message.module=wasm&message.code_id=${deployedHackatom.codeId}&message.action=store-code`,
|
||||
);
|
||||
expect(parseInt(uploads.count, 10)).toEqual(1);
|
||||
const store = fromOneElementArray(uploads.txs[0].tx.value.msg);
|
||||
@ -433,42 +434,46 @@ describe("WasmExtension", () => {
|
||||
expect(store.value).toEqual(
|
||||
jasmine.objectContaining({
|
||||
sender: alice.address0,
|
||||
source: deployedErc20.source,
|
||||
builder: deployedErc20.builder,
|
||||
source: deployedHackatom.source,
|
||||
builder: deployedHackatom.builder,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
const instantiations = await client.txsQuery(
|
||||
`message.module=wasm&message.code_id=${deployedErc20.codeId}&message.action=instantiate`,
|
||||
`message.module=wasm&message.code_id=${deployedHackatom.codeId}&message.action=instantiate`,
|
||||
);
|
||||
expect(parseInt(instantiations.count, 10)).toBeGreaterThanOrEqual(3);
|
||||
const [hash, isa, jade] = instantiations.txs.map((tx) => fromOneElementArray(tx.tx.value.msg));
|
||||
assert(isMsgInstantiateContract(hash));
|
||||
assert(isMsgInstantiateContract(isa));
|
||||
assert(isMsgInstantiateContract(jade));
|
||||
expect(hash.value).toEqual({
|
||||
code_id: deployedErc20.codeId.toString(),
|
||||
const [zero, one, two] = instantiations.txs.map((tx) => fromOneElementArray(tx.tx.value.msg));
|
||||
assert(isMsgInstantiateContract(zero));
|
||||
assert(isMsgInstantiateContract(one));
|
||||
assert(isMsgInstantiateContract(two));
|
||||
expect(zero.value).toEqual({
|
||||
code_id: deployedHackatom.codeId.toString(),
|
||||
init_funds: [],
|
||||
init_msg: jasmine.objectContaining({
|
||||
symbol: "HASH",
|
||||
beneficiary: deployedHackatom.instances[0].beneficiary,
|
||||
}),
|
||||
label: "HASH",
|
||||
label: deployedHackatom.instances[0].label,
|
||||
sender: alice.address0,
|
||||
});
|
||||
expect(isa.value).toEqual({
|
||||
code_id: deployedErc20.codeId.toString(),
|
||||
expect(one.value).toEqual({
|
||||
code_id: deployedHackatom.codeId.toString(),
|
||||
init_funds: [],
|
||||
init_msg: jasmine.objectContaining({ symbol: "ISA" }),
|
||||
label: "ISA",
|
||||
init_msg: jasmine.objectContaining({
|
||||
beneficiary: deployedHackatom.instances[1].beneficiary,
|
||||
}),
|
||||
label: deployedHackatom.instances[1].label,
|
||||
sender: alice.address0,
|
||||
});
|
||||
expect(jade.value).toEqual({
|
||||
code_id: deployedErc20.codeId.toString(),
|
||||
expect(two.value).toEqual({
|
||||
code_id: deployedHackatom.codeId.toString(),
|
||||
init_funds: [],
|
||||
init_msg: jasmine.objectContaining({ symbol: "JADE" }),
|
||||
label: "JADE",
|
||||
init_msg: jasmine.objectContaining({
|
||||
beneficiary: deployedHackatom.instances[2].beneficiary,
|
||||
}),
|
||||
label: deployedHackatom.instances[2].label,
|
||||
sender: alice.address0,
|
||||
admin: alice.address1,
|
||||
});
|
||||
|
@ -29,40 +29,6 @@ export const base64Matcher = /^(?:[a-zA-Z0-9+/]{4})*(?:|(?:[a-zA-Z0-9+/]{3}=)|(?
|
||||
// https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki#bech32
|
||||
export const bech32AddressMatcher = /^[\x21-\x7e]{1,83}1[02-9ac-hj-np-z]{38}$/;
|
||||
|
||||
/** Deployed as part of scripts/wasmd/init.sh */
|
||||
export const deployedHackatom = {
|
||||
codeId: 1,
|
||||
source: "https://crates.io/api/v1/crates/hackatom/not-yet-released/download",
|
||||
builder: "cosmwasm/rust-optimizer:0.9.1",
|
||||
checksum: "3defc33a41f58c71d38b176d521c411d8e74d26403fde7660486930c7579a016",
|
||||
instances: [
|
||||
{ address: "cosmos18vd8fpwxzck93qlwghaj6arh4p7c5n89uzcee5", label: "From deploy_hackatom.js (0)" },
|
||||
{ address: "cosmos1hqrdl6wstt8qzshwc6mrumpjk9338k0lr4dqxd", label: "From deploy_hackatom.js (1)" },
|
||||
{ address: "cosmos18r5szma8hm93pvx6lwpjwyxruw27e0k5uw835c", label: "From deploy_hackatom.js (2)" },
|
||||
],
|
||||
};
|
||||
|
||||
/** Deployed as part of scripts/wasmd/init.sh */
|
||||
export const deployedErc20 = {
|
||||
codeId: 2,
|
||||
source: "https://crates.io/api/v1/crates/cw-erc20/not-yet-released/download",
|
||||
builder: "cosmwasm/rust-optimizer:0.9.0",
|
||||
checksum: "0f14abcc6fed08f2dd06896db974989db97dbcc6e8e30188b73fe5ab427c7785",
|
||||
instances: [
|
||||
"cosmos18vd8fpwxzck93qlwghaj6arh4p7c5n89uzcee5", // HASH
|
||||
"cosmos1hqrdl6wstt8qzshwc6mrumpjk9338k0lr4dqxd", // ISA
|
||||
"cosmos18r5szma8hm93pvx6lwpjwyxruw27e0k5uw835c", // JADE
|
||||
],
|
||||
};
|
||||
|
||||
export const wasmd = {
|
||||
endpoint: "http://localhost:1317",
|
||||
chainId: "testing",
|
||||
validator: {
|
||||
address: "cosmosvaloper1yfkkk04ve8a0sugj4fe6q6zxuvmvza8r3arurr",
|
||||
},
|
||||
};
|
||||
|
||||
export const alice = {
|
||||
mnemonic: "enlist hip relief stomach skate base shallow young switch frequent cry park",
|
||||
pubkey0: {
|
||||
@ -87,6 +53,52 @@ export const unused = {
|
||||
sequence: 0,
|
||||
};
|
||||
|
||||
/** Deployed as part of scripts/wasmd/init.sh */
|
||||
export const deployedHackatom = {
|
||||
codeId: 1,
|
||||
source: "https://crates.io/api/v1/crates/hackatom/not-yet-released/download",
|
||||
builder: "cosmwasm/rust-optimizer:0.9.1",
|
||||
checksum: "3defc33a41f58c71d38b176d521c411d8e74d26403fde7660486930c7579a016",
|
||||
instances: [
|
||||
{
|
||||
beneficiary: alice.address0,
|
||||
address: "cosmos18vd8fpwxzck93qlwghaj6arh4p7c5n89uzcee5",
|
||||
label: "From deploy_hackatom.js (0)",
|
||||
},
|
||||
{
|
||||
beneficiary: alice.address1,
|
||||
address: "cosmos1hqrdl6wstt8qzshwc6mrumpjk9338k0lr4dqxd",
|
||||
label: "From deploy_hackatom.js (1)",
|
||||
},
|
||||
{
|
||||
beneficiary: alice.address2,
|
||||
address: "cosmos18r5szma8hm93pvx6lwpjwyxruw27e0k5uw835c",
|
||||
label: "From deploy_hackatom.js (2)",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/** Deployed as part of scripts/wasmd/init.sh */
|
||||
export const deployedErc20 = {
|
||||
codeId: 2,
|
||||
source: "https://crates.io/api/v1/crates/cw-erc20/not-yet-released/download",
|
||||
builder: "cosmwasm/rust-optimizer:0.9.0",
|
||||
checksum: "0f14abcc6fed08f2dd06896db974989db97dbcc6e8e30188b73fe5ab427c7785",
|
||||
instances: [
|
||||
"cosmos18vd8fpwxzck93qlwghaj6arh4p7c5n89uzcee5", // HASH
|
||||
"cosmos1hqrdl6wstt8qzshwc6mrumpjk9338k0lr4dqxd", // ISA
|
||||
"cosmos18r5szma8hm93pvx6lwpjwyxruw27e0k5uw835c", // JADE
|
||||
],
|
||||
};
|
||||
|
||||
export const wasmd = {
|
||||
endpoint: "http://localhost:1317",
|
||||
chainId: "testing",
|
||||
validator: {
|
||||
address: "cosmosvaloper1yfkkk04ve8a0sugj4fe6q6zxuvmvza8r3arurr",
|
||||
},
|
||||
};
|
||||
|
||||
export function wasmdEnabled(): boolean {
|
||||
return !!process.env.WASMD_ENABLED;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user