Merge pull request #454 from CosmWasm/add-ERC20_ENABLED
Add ERC20_ENABLED to make the contract optional
This commit is contained in:
@@ -136,6 +136,7 @@ jobs:
|
||||
- run:
|
||||
environment:
|
||||
WASMD_ENABLED: 1
|
||||
ERC20_ENABLED: 1
|
||||
SIMAPP_ENABLED: 1
|
||||
TENDERMINT_ENABLED: 1
|
||||
SOCKETSERVER_ENABLED: 1
|
||||
@@ -244,6 +245,7 @@ jobs:
|
||||
- run:
|
||||
environment:
|
||||
WASMD_ENABLED: 1
|
||||
ERC20_ENABLED: 1
|
||||
SIMAPP_ENABLED: 1
|
||||
TENDERMINT_ENABLED: 1
|
||||
SOCKETSERVER_ENABLED: 1
|
||||
@@ -333,6 +335,7 @@ jobs:
|
||||
- run:
|
||||
environment:
|
||||
WASMD_ENABLED: 1
|
||||
ERC20_ENABLED: 1
|
||||
SIMAPP_ENABLED: 1
|
||||
TENDERMINT_ENABLED: 1
|
||||
SOCKETSERVER_ENABLED: 1
|
||||
|
||||
+3
-1
@@ -41,7 +41,7 @@ yarn test
|
||||
|
||||
To run the entire test suite, you need to run some local blockchain to test
|
||||
against. We use [wasmd](https://github.com/CosmWasm/wasmd) for both CosmWasm
|
||||
tests and as a generic Cosmos SDK 0.38 blockchain. We also spawn multiple
|
||||
tests and as a generic Cosmos SDK 0.39 blockchain. We also spawn multiple
|
||||
versions of raw Tendermint and a basic WebSocket server.
|
||||
|
||||
```sh
|
||||
@@ -49,6 +49,7 @@ versions of raw Tendermint and a basic WebSocket server.
|
||||
./scripts/wasmd/start.sh
|
||||
./scripts/wasmd/init.sh
|
||||
export WASMD_ENABLED=1
|
||||
export ERC20_ENABLED=1
|
||||
|
||||
# Start Tendermint
|
||||
./scripts/tendermint/all_start.sh
|
||||
@@ -64,6 +65,7 @@ yarn test
|
||||
# And at the end of the day
|
||||
unset SOCKETSERVER_ENABLED
|
||||
unset TENDERMINT_ENABLED
|
||||
unset ERC20_ENABLED
|
||||
unset WASMD_ENABLED
|
||||
./scripts/socketserver/stop.sh
|
||||
./scripts/tendermint/all_stop.sh
|
||||
|
||||
@@ -19,8 +19,10 @@ import { SigningCosmWasmClient } from "./signingcosmwasmclient";
|
||||
import {
|
||||
alice,
|
||||
deployedErc20,
|
||||
erc20Enabled,
|
||||
fromOneElementArray,
|
||||
makeRandomAddress,
|
||||
pendingWithoutErc20,
|
||||
pendingWithoutWasmd,
|
||||
wasmd,
|
||||
wasmdEnabled,
|
||||
@@ -49,7 +51,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
let execute: TestTxExecute | undefined;
|
||||
|
||||
beforeAll(async () => {
|
||||
if (wasmdEnabled()) {
|
||||
if (wasmdEnabled() && erc20Enabled()) {
|
||||
const wallet = await Secp256k1HdWallet.fromMnemonic(alice.mnemonic);
|
||||
const client = new SigningCosmWasmClient(wasmd.endpoint, alice.address0, wallet);
|
||||
|
||||
@@ -148,6 +150,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
describe("with SearchByIdQuery", () => {
|
||||
it("can search successful tx by ID", async () => {
|
||||
pendingWithoutWasmd();
|
||||
pendingWithoutErc20();
|
||||
assert(sendSuccessful, "value must be set in beforeAll()");
|
||||
const client = new CosmWasmClient(wasmd.endpoint);
|
||||
const result = await client.searchTx({ id: sendSuccessful.hash });
|
||||
@@ -164,6 +167,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
|
||||
it("can search unsuccessful tx by ID", async () => {
|
||||
pendingWithoutWasmd();
|
||||
pendingWithoutErc20();
|
||||
assert(sendUnsuccessful, "value must be set in beforeAll()");
|
||||
const client = new CosmWasmClient(wasmd.endpoint);
|
||||
const result = await client.searchTx({ id: sendUnsuccessful.hash });
|
||||
@@ -180,6 +184,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
|
||||
it("can search by ID (non existent)", async () => {
|
||||
pendingWithoutWasmd();
|
||||
pendingWithoutErc20();
|
||||
const client = new CosmWasmClient(wasmd.endpoint);
|
||||
const nonExistentId = "0000000000000000000000000000000000000000000000000000000000000000";
|
||||
const result = await client.searchTx({ id: nonExistentId });
|
||||
@@ -188,6 +193,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
|
||||
it("can search by ID and filter by minHeight", async () => {
|
||||
pendingWithoutWasmd();
|
||||
pendingWithoutErc20();
|
||||
assert(sendSuccessful);
|
||||
const client = new CosmWasmClient(wasmd.endpoint);
|
||||
const query = { id: sendSuccessful.hash };
|
||||
@@ -217,6 +223,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
describe("with SearchByHeightQuery", () => {
|
||||
it("can search successful tx by height", async () => {
|
||||
pendingWithoutWasmd();
|
||||
pendingWithoutErc20();
|
||||
assert(sendSuccessful, "value must be set in beforeAll()");
|
||||
const client = new CosmWasmClient(wasmd.endpoint);
|
||||
const result = await client.searchTx({ height: sendSuccessful.height });
|
||||
@@ -233,6 +240,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
|
||||
it("can search unsuccessful tx by height", async () => {
|
||||
pendingWithoutWasmd();
|
||||
pendingWithoutErc20();
|
||||
assert(sendUnsuccessful, "value must be set in beforeAll()");
|
||||
const client = new CosmWasmClient(wasmd.endpoint);
|
||||
const result = await client.searchTx({ height: sendUnsuccessful.height });
|
||||
@@ -251,6 +259,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
describe("with SearchBySentFromOrToQuery", () => {
|
||||
it("can search by sender", async () => {
|
||||
pendingWithoutWasmd();
|
||||
pendingWithoutErc20();
|
||||
assert(sendSuccessful, "value must be set in beforeAll()");
|
||||
const client = new CosmWasmClient(wasmd.endpoint);
|
||||
const results = await client.searchTx({ sentFromOrTo: sendSuccessful.sender });
|
||||
@@ -279,6 +288,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
|
||||
it("can search by recipient", async () => {
|
||||
pendingWithoutWasmd();
|
||||
pendingWithoutErc20();
|
||||
assert(sendSuccessful, "value must be set in beforeAll()");
|
||||
const client = new CosmWasmClient(wasmd.endpoint);
|
||||
const results = await client.searchTx({ sentFromOrTo: sendSuccessful.recipient });
|
||||
@@ -306,6 +316,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
|
||||
it("can search by sender or recipient (sorted and deduplicated)", async () => {
|
||||
pendingWithoutWasmd();
|
||||
pendingWithoutErc20();
|
||||
assert(sendSelfSuccessful, "value must be set in beforeAll()");
|
||||
const txhash = sendSelfSuccessful.hash;
|
||||
const client = new CosmWasmClient(wasmd.endpoint);
|
||||
@@ -317,6 +328,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
|
||||
it("can search by recipient and filter by minHeight", async () => {
|
||||
pendingWithoutWasmd();
|
||||
pendingWithoutErc20();
|
||||
assert(sendSuccessful);
|
||||
const client = new CosmWasmClient(wasmd.endpoint);
|
||||
const query = { sentFromOrTo: sendSuccessful.recipient };
|
||||
@@ -344,6 +356,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
|
||||
it("can search by recipient and filter by maxHeight", async () => {
|
||||
pendingWithoutWasmd();
|
||||
pendingWithoutErc20();
|
||||
assert(sendSuccessful);
|
||||
const client = new CosmWasmClient(wasmd.endpoint);
|
||||
const query = { sentFromOrTo: sendSuccessful.recipient };
|
||||
@@ -373,6 +386,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
describe("with SearchByTagsQuery", () => {
|
||||
it("can search by transfer.recipient", async () => {
|
||||
pendingWithoutWasmd();
|
||||
pendingWithoutErc20();
|
||||
assert(sendSuccessful, "value must be set in beforeAll()");
|
||||
const client = new CosmWasmClient(wasmd.endpoint);
|
||||
const results = await client.searchTx({
|
||||
@@ -399,6 +413,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
|
||||
it("can search by message.contract_address", async () => {
|
||||
pendingWithoutWasmd();
|
||||
pendingWithoutErc20();
|
||||
assert(execute, "value must be set in beforeAll()");
|
||||
const client = new CosmWasmClient(wasmd.endpoint);
|
||||
const results = await client.searchTx({
|
||||
@@ -441,6 +456,7 @@ describe("CosmWasmClient.searchTx", () => {
|
||||
|
||||
it("can search by message.contract_address + message.action", async () => {
|
||||
pendingWithoutWasmd();
|
||||
pendingWithoutErc20();
|
||||
assert(execute, "value must be set in beforeAll()");
|
||||
const client = new CosmWasmClient(wasmd.endpoint);
|
||||
const results = await client.searchTx({
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
deployedErc20,
|
||||
getHackatom,
|
||||
makeRandomAddress,
|
||||
pendingWithoutErc20,
|
||||
pendingWithoutWasmd,
|
||||
tendermintIdMatcher,
|
||||
unused,
|
||||
@@ -254,6 +255,7 @@ describe("CosmWasmClient", () => {
|
||||
describe("getCodes", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutWasmd();
|
||||
pendingWithoutErc20(); // TODO: Adapt test to use hackatom instead
|
||||
const client = new CosmWasmClient(wasmd.endpoint);
|
||||
const result = await client.getCodes();
|
||||
expect(result.length).toBeGreaterThanOrEqual(1);
|
||||
@@ -271,6 +273,7 @@ describe("CosmWasmClient", () => {
|
||||
describe("getCodeDetails", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutWasmd();
|
||||
pendingWithoutErc20(); // TODO: Adapt test to use hackatom instead
|
||||
const client = new CosmWasmClient(wasmd.endpoint);
|
||||
const result = await client.getCodeDetails(1);
|
||||
|
||||
@@ -290,6 +293,7 @@ describe("CosmWasmClient", () => {
|
||||
|
||||
it("caches downloads", async () => {
|
||||
pendingWithoutWasmd();
|
||||
pendingWithoutErc20(); // TODO: Adapt test to use hackatom instead
|
||||
const client = new CosmWasmClient(wasmd.endpoint);
|
||||
const openedClient = (client as unknown) as PrivateCosmWasmClient;
|
||||
const getCodeSpy = spyOn(openedClient.lcdClient.wasm, "getCode").and.callThrough();
|
||||
@@ -305,6 +309,7 @@ describe("CosmWasmClient", () => {
|
||||
describe("getContracts", () => {
|
||||
it("works", async () => {
|
||||
pendingWithoutWasmd();
|
||||
pendingWithoutErc20(); // TODO: Adapt test to use hackatom instead
|
||||
const client = new CosmWasmClient(wasmd.endpoint);
|
||||
const result = await client.getContracts(1);
|
||||
expect(result.length).toBeGreaterThanOrEqual(3);
|
||||
@@ -336,6 +341,7 @@ describe("CosmWasmClient", () => {
|
||||
describe("getContract", () => {
|
||||
it("works for instance without admin", async () => {
|
||||
pendingWithoutWasmd();
|
||||
pendingWithoutErc20(); // TODO: Adapt test to use hackatom instead
|
||||
const client = new CosmWasmClient(wasmd.endpoint);
|
||||
const hash = await client.getContract("cosmos18vd8fpwxzck93qlwghaj6arh4p7c5n89uzcee5");
|
||||
expect(hash).toEqual({
|
||||
@@ -349,6 +355,7 @@ describe("CosmWasmClient", () => {
|
||||
|
||||
it("works for instance with admin", async () => {
|
||||
pendingWithoutWasmd();
|
||||
pendingWithoutErc20(); // TODO: Adapt test to use hackatom instead
|
||||
const client = new CosmWasmClient(wasmd.endpoint);
|
||||
const jade = await client.getContract("cosmos18r5szma8hm93pvx6lwpjwyxruw27e0k5uw835c");
|
||||
expect(jade).toEqual(
|
||||
|
||||
@@ -37,6 +37,7 @@ import {
|
||||
fromOneElementArray,
|
||||
getHackatom,
|
||||
makeRandomAddress,
|
||||
pendingWithoutErc20,
|
||||
pendingWithoutWasmd,
|
||||
wasmd,
|
||||
wasmdEnabled,
|
||||
@@ -368,6 +369,7 @@ 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}`);
|
||||
expect(parseInt(result.count, 10)).toBeGreaterThanOrEqual(4);
|
||||
@@ -414,6 +416,7 @@ 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);
|
||||
|
||||
{
|
||||
|
||||
@@ -83,6 +83,16 @@ export function pendingWithoutWasmd(): void {
|
||||
}
|
||||
}
|
||||
|
||||
export function erc20Enabled(): boolean {
|
||||
return !!process.env.ERC20_ENABLED;
|
||||
}
|
||||
|
||||
export function pendingWithoutErc20(): void {
|
||||
if (!erc20Enabled()) {
|
||||
return pending("Set ERC20_ENABLED to enable Wasmd based tests");
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns first element. Throws if array has a different length than 1. */
|
||||
export function fromOneElementArray<T>(elements: ArrayLike<T>): T {
|
||||
if (elements.length !== 1) throw new Error(`Expected exactly one element but got ${elements.length}`);
|
||||
|
||||
@@ -14,6 +14,6 @@ module.exports = [
|
||||
path: distdir,
|
||||
filename: "tests.js",
|
||||
},
|
||||
plugins: [new webpack.EnvironmentPlugin(["WASMD_ENABLED"])],
|
||||
plugins: [new webpack.EnvironmentPlugin(["WASMD_ENABLED", "ERC20_ENABLED"])],
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user