Skip to content

Commit

Permalink
Merge pull request #1513 from cosmos/simapp-50
Browse files Browse the repository at this point in the history
Test against Cosmos SDK 0.50
  • Loading branch information
webmaster128 committed Nov 22, 2023
2 parents 2dc388f + 9e6b82c commit b7c66d8
Show file tree
Hide file tree
Showing 46 changed files with 3,477 additions and 24 deletions.
4 changes: 3 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ workflows:
- build
matrix:
parameters:
simapp: ["simapp44", "simapp46", "simapp47"]
simapp: ["simapp44", "simapp46", "simapp47", "simapp50"]
- test-node:
requires:
- build
Expand Down Expand Up @@ -170,6 +170,7 @@ jobs:
[ "<< parameters.simapp >>" = "simapp44" ] && export SIMAPP44_ENABLED=1 SLOW_SIMAPP44_ENABLED=1
[ "<< parameters.simapp >>" = "simapp46" ] && export SIMAPP46_ENABLED=1 SLOW_SIMAPP46_ENABLED=1
[ "<< parameters.simapp >>" = "simapp47" ] && export SIMAPP47_ENABLED=1 SLOW_SIMAPP47_ENABLED=1
[ "<< parameters.simapp >>" = "simapp50" ] && export SIMAPP50_ENABLED=1 SLOW_SIMAPP50_ENABLED=1
yarn test --stream
- run:
name: Run CLI selftest
Expand All @@ -190,6 +191,7 @@ jobs:
[ "<< parameters.simapp >>" = "simapp44" ] && export SIMAPP44_ENABLED=1 SLOW_SIMAPP44_ENABLED=1
[ "<< parameters.simapp >>" = "simapp46" ] && export SIMAPP46_ENABLED=1 SLOW_SIMAPP46_ENABLED=1
[ "<< parameters.simapp >>" = "simapp47" ] && export SIMAPP47_ENABLED=1 SLOW_SIMAPP47_ENABLED=1
[ "<< parameters.simapp >>" = "simapp50" ] && export SIMAPP50_ENABLED=1 SLOW_SIMAPP50_ENABLED=1
./run_examples.sh
- run:
name: Stop chains
Expand Down
9 changes: 7 additions & 2 deletions packages/faucet/src/faucet.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ import { Faucet } from "./faucet";
import { TokenConfiguration } from "./tokenmanager";

function pendingWithoutSimapp(): void {
if (!process.env.SIMAPP44_ENABLED && !process.env.SIMAPP46_ENABLED && !process.env.SIMAPP47_ENABLED) {
return pending("Set SIMAPP{44,46,47}_ENABLED to enabled Stargate node-based tests");
if (
!process.env.SIMAPP44_ENABLED &&
!process.env.SIMAPP46_ENABLED &&
!process.env.SIMAPP47_ENABLED &&
!process.env.SIMAPP50_ENABLED
) {
return pending("Set SIMAPP{44,46,47,50}_ENABLED to enabled Stargate node-based tests");
}
}

Expand Down
9 changes: 7 additions & 2 deletions packages/ledger-amino/src/testutils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,17 @@ export function pendingWithoutLedger(): void {
}

export function simappEnabled(): boolean {
return !!process.env.SIMAPP44_ENABLED || !!process.env.SIMAPP46_ENABLED || !!process.env.SIMAPP47_ENABLED;
return (
!!process.env.SIMAPP44_ENABLED ||
!!process.env.SIMAPP46_ENABLED ||
!!process.env.SIMAPP47_ENABLED ||
!!process.env.SIMAPP50_ENABLED
);
}

export function pendingWithoutSimapp(): void {
if (!simappEnabled()) {
return pending("Set SIMAPP{44,46,47}_ENABLED to enable Simapp-based tests");
return pending("Set SIMAPP{44,46,47,50}_ENABLED to enable Simapp-based tests");
}
}

Expand Down
10 changes: 6 additions & 4 deletions packages/stargate/src/modules/gov/messages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
nonNegativeIntegerMatcher,
pendingWithoutSimapp,
simapp,
simapp50Enabled,
simappEnabled,
validator,
} from "../../testutils.spec";
Expand Down Expand Up @@ -68,10 +69,10 @@ describe("gov messages", () => {
"Test proposal for simd",
);
assertIsDeliverTxSuccess(proposalResult);
const logs = JSON.parse(proposalResult.rawLog || "");
proposalId = logs[0].events
.find(({ type }: any) => type === "submit_proposal")
.attributes.find(({ key }: any) => key === "proposal_id").value;

proposalId = proposalResult.events
.find(({ type }) => type === "submit_proposal")
?.attributes.find(({ key }: any) => key === "proposal_id")?.value;
assert(proposalId, "Proposal ID not found in events");
assert(proposalId.match(nonNegativeIntegerMatcher));

Expand Down Expand Up @@ -204,6 +205,7 @@ describe("gov messages", () => {

it("works with Amino JSON sign mode", async () => {
pendingWithoutSimapp();
if (simapp50Enabled()) pending("Not working, see https://github.com/cosmos/cosmos-sdk/issues/18546");
assert(voterWalletAmino);
assert(proposalId, "Missing proposal ID");
const client = await SigningStargateClient.connectWithSigner(simapp.tendermintUrl, voterWalletAmino);
Expand Down
8 changes: 4 additions & 4 deletions packages/stargate/src/modules/gov/queries.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ describe("GovExtension", () => {
"Test proposal for simd",
);
assertIsDeliverTxSuccess(proposalResult);
const logs = JSON.parse(proposalResult.rawLog || "");
proposalId = logs[0].events
.find(({ type }: any) => type === "submit_proposal")
.attributes.find(({ key }: any) => key === "proposal_id").value;

proposalId = proposalResult.events
.find(({ type }) => type === "submit_proposal")
?.attributes.find(({ key }: any) => key === "proposal_id")?.value;
assert(proposalId, "Proposal ID not found in events");
assert(proposalId.match(nonNegativeIntegerMatcher));

Expand Down
3 changes: 3 additions & 0 deletions packages/stargate/src/modules/staking/messages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
faucet,
pendingWithoutSimapp,
simapp,
simapp50Enabled,
} from "../../testutils.spec";
import { MsgCreateValidatorEncodeObject, MsgEditValidatorEncodeObject } from "./messages";

Expand Down Expand Up @@ -95,6 +96,7 @@ describe("staking messages", () => {

it("works with Amino JSON sign mode", async () => {
pendingWithoutSimapp();
if (simapp50Enabled()) pending("Not working, see https://github.com/cosmos/cosmos-sdk/issues/18546");

const valWallet = await Secp256k1HdWallet.generate();
const [valAccount] = await valWallet.getAccounts();
Expand Down Expand Up @@ -235,6 +237,7 @@ describe("staking messages", () => {

it("works with Amino JSON sign mode", async () => {
pendingWithoutSimapp();
if (simapp50Enabled()) pending("Not working, see https://github.com/cosmos/cosmos-sdk/issues/18546");

const valWallet = await Secp256k1HdWallet.generate();
const [valAccount] = await valWallet.getAccounts();
Expand Down
15 changes: 13 additions & 2 deletions packages/stargate/src/signingstargateclient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
ModifyingSecp256k1HdWallet,
pendingWithoutSimapp,
simapp,
simapp50Enabled,
validator,
} from "./testutils.spec";

Expand Down Expand Up @@ -119,7 +120,12 @@ describe("SigningStargateClient", () => {
memo,
);
assertIsDeliverTxSuccess(result);
expect(result.rawLog).toBeTruthy();

if (simapp50Enabled()) {
expect(result.rawLog).toEqual(""); // empty now (https://github.com/cosmos/cosmos-sdk/pull/15845)
} else {
expect(result.rawLog).toBeTruthy();
}

// got tokens
const after = await client.getBalance(beneficiaryAddress, "ucosm");
Expand Down Expand Up @@ -155,7 +161,12 @@ describe("SigningStargateClient", () => {
memo,
);
assertIsDeliverTxSuccess(result);
expect(result.rawLog).toBeTruthy();

if (simapp50Enabled()) {
expect(result.rawLog).toEqual(""); // empty now (https://github.com/cosmos/cosmos-sdk/pull/15845)
} else {
expect(result.rawLog).toBeTruthy();
}

// got tokens
const after = await client.getBalance(beneficiaryAddress, "ucosm");
Expand Down
23 changes: 20 additions & 3 deletions packages/stargate/src/stargateclient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ import {
pendingWithoutSlowSimapp,
simapp,
simapp44Enabled,
simapp46Enabled,
simapp47Enabled,
simapp50Enabled,
slowSimapp,
tendermintIdMatcher,
unused,
Expand Down Expand Up @@ -395,7 +398,11 @@ describe("StargateClient", () => {

const { gasUsed, rawLog, transactionHash } = txResult;
expect(gasUsed).toBeGreaterThan(0);
expect(rawLog).toMatch(/{"key":"amount","value":"1234567ucosm"}/);
if (simapp50Enabled()) {
expect(rawLog).toEqual(""); // empty now (https://github.com/cosmos/cosmos-sdk/pull/15845)
} else {
expect(rawLog).toMatch(/{"key":"amount","value":"1234567ucosm"}/);
}
expect(transactionHash).toMatch(/^[0-9A-F]{64}$/);

client.disconnect();
Expand Down Expand Up @@ -462,10 +469,20 @@ describe("StargateClient", () => {
assert(false, "Expected broadcastTx to throw");
} catch (error: any) {
expect(error).toMatch(
simapp44Enabled() ? /invalid recipient address/i : /Broadcasting transaction failed with code 7/i,
simapp44Enabled()
? /invalid recipient address/i
: simapp46Enabled() || simapp47Enabled()
? /Broadcasting transaction failed with code 7/i
: // New error code for SDK 0.50+
/Broadcasting transaction failed with code 4/i,
);
assert(error instanceof BroadcastTxError);
expect(error.code).toEqual(7);
if (simapp50Enabled()) {
// New error code for SDK 0.50+
expect(error.code).toEqual(4);
} else {
expect(error.code).toEqual(7);
}
expect(error.codespace).toEqual("sdk");
}

Expand Down
17 changes: 11 additions & 6 deletions packages/stargate/src/testutils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,33 +28,38 @@ export function simapp47Enabled(): boolean {
return !!process.env.SIMAPP47_ENABLED;
}

export function simapp50Enabled(): boolean {
return !!process.env.SIMAPP50_ENABLED;
}

export function simappEnabled(): boolean {
return simapp44Enabled() || simapp46Enabled() || simapp47Enabled();
return simapp44Enabled() || simapp46Enabled() || simapp47Enabled() || simapp50Enabled();
}

export function pendingWithoutSimapp46OrHigher(): void {
if (!simapp46Enabled() && !simapp47Enabled()) {
return pending("Set SIMAPP46_ENABLED or SIMAPP47_ENABLED to enable Simapp based tests");
if (!simapp46Enabled() && !simapp47Enabled() && !simapp50Enabled()) {
return pending("Set SIMAPP{46,47,50}_ENABLED to enable Simapp based tests");
}
}

export function pendingWithoutSimapp(): void {
if (!simappEnabled()) {
return pending("Set SIMAPP{44,46,47}_ENABLED to enable Simapp based tests");
return pending("Set SIMAPP{44,46,47,50}_ENABLED to enable Simapp based tests");
}
}

export function slowSimappEnabled(): boolean {
return (
!!process.env.SLOW_SIMAPP44_ENABLED ||
!!process.env.SLOW_SIMAPP46_ENABLED ||
!!process.env.SLOW_SIMAPP47_ENABLED
!!process.env.SLOW_SIMAPP47_ENABLED ||
!!process.env.SLOW_SIMAPP50_ENABLED
);
}

export function pendingWithoutSlowSimapp(): void {
if (!slowSimappEnabled()) {
return pending("Set SLOW_SIMAPP{44,46,47}_ENABLED to enable slow Simapp based tests");
return pending("Set SLOW_SIMAPP{44,46,47,50}_ENABLED to enable slow Simapp based tests");
}
}

Expand Down
2 changes: 2 additions & 0 deletions packages/stargate/webpack.web.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ module.exports = [
SLOW_SIMAPP46_ENABLED: "",
SIMAPP47_ENABLED: "",
SLOW_SIMAPP47_ENABLED: "",
SIMAPP50_ENABLED: "",
SLOW_SIMAPP50_ENABLED: "",
}),
new webpack.ProvidePlugin({
Buffer: ["buffer", "Buffer"],
Expand Down
69 changes: 69 additions & 0 deletions scripts/simapp50/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Local Simd development network

## Starting the blockchain

Run the following:

```
cd scripts/simapp50
./start.sh
```

## Preset accounts

1. **Faucet**\
economy stock theory fatal elder harbor betray wasp final emotion task crumble
siren bottom lizard educate guess current outdoor pair theory focus wife stone\
Address 0: cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6\
Address 1: cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5\
Address 2: cosmos1xy4yqngt0nlkdcenxymg8tenrghmek4nmqm28k\
Address 3: cosmos142u9fgcjdlycfcez3lw8x6x5h7rfjlnfhpw2lx\
Address 4: cosmos1hsm76p4ahyhl5yh3ve9ur49r5kemhp2r0dcjvx\
Pubkey 0: A08EGB7ro1ORuFhjOnZcSgwYlpe0DSFjVNUIkNNQxwKQ\
Pubkey 1: AiDosfIbBi54XJ1QjCeApumcy/FjdtF+YhywPf3DKTx7\
Pubkey 2: AzQg33JZqH7vSsm09esZY5bZvmzYwE/SY78cA0iLxpD7\
Pubkey 3: A3gOAlB6aiRTCPvWMQg2+ZbGYNsLd8qlvV28m8p2UhY2\
Pubkey 4: Aum2063ub/ErUnIUB36sK55LktGUStgcbSiaAnL1wadu
2. **Alice**: Test account for the cosmwasm package that can run in parallel
with faucet without sequence conflicts\
enlist hip relief stomach skate base shallow young switch frequent cry park\
Address 0: cosmos14qemq0vw6y3gc3u3e0aty2e764u4gs5le3hada\
Address 1: cosmos1hhg2rlu9jscacku2wwckws7932qqqu8x3gfgw0\
Address 2: cosmos1xv9tklw7d82sezh9haa573wufgy59vmwe6xxe5\
Address 3: cosmos17yg9mssjenmc3jkqth6ulcwj9cxujrxxzezwta\
Address 4: cosmos1f7j7ryulwjfe9ljplvhtcaxa6wqgula3etktce\
Pubkey 0: A9cXhWb8ZpqCzkA8dQCPV29KdeRLV3rUYxrkHudLbQtS\
Pubkey 1: A4XluzvcUx0ViLF0DjYW5/noArGwpltDstoUUZo+g1b0\
Pubkey 2: A5TKr1NKc/MKRJ7+EHDD9PlzmGaPD/di/6hzZyBwxoy5\
Pubkey 3: A/HSABDUqMB2qDy+PA7fiuuuA+hfrco2VwwiThMiTzUx\
Pubkey 4: A7usTiqgqfxL/WKhoephDUSCHBQlLagtwI/qTmEteTRM
3. **Bob**: Test account (unused for now)\
remain fragile remove stamp quiz bus country dress critic mammal office need\
Address 0: cosmos1lvrwcvrqlc5ktzp2c4t22xgkx29q3y83lktgzl\
Address 1: cosmos1vkv9sfwaak76weyamqx0flmng2vuquxqcuqukh\
Address 2: cosmos106jwym4s9aujcmes26myzzwqsccw09sdm0v5au\
Address 3: cosmos1c7wpeen2uv8thayf7g8q2rgpm29clj0dgrdtzw\
Address 4: cosmos1mjxpv9ft30wer7ma7kwfxhm42l379xutplrdk6\
Pubkey 0: A0d/GxY+UALE+miWJP0qyq4/EayG1G6tsg24v+cbD6By\
Pubkey 1: Agqd6njsVEQD1CR+F2aqEb8hil5NXZ06mjKgetaNC12t\
Pubkey 2: A6e9ElvKaM0DKWh1bIdK3bgB14dyEDgIXYMA0Lbs1GoQ\
Pubkey 3: AkAK5PQaucieWMb0+tTRY01feYI+upRnoNK556eD0Ibb\
Pubkey 4: A5HMVEAJsupdQWItbZv5Z1xZifDixQi6tjU/hJpZY1bF
4. **Unused**: for testing account state; this account never changes balances or
sequences\
oyster design unusual machine spread century engine gravity focus cave carry slot\
ArkCaFUJ/IH+vKBmNRCdUVl3mCAhbopk9jjW4Ko4OfRQ\
cosmos1cjsxept9rkggzxztslae9ndgpdyt2408lk850u
5. **Guest**: account for manual testing\
degree tackle suggest window test behind mesh extra cover prepare oak script\
Am/+YV0LaeqQPu7BDJuDHV7J8y68ptkGs10YS+9s71Nq\
cosmos17d0jcz59jf68g52vq38tuuncmwwjk42u6mcxej

### Multisig accounts

1. 1/5 threshold multisig of the first 5 faucet accounts\
cosmos1v75snhly7wfndk83ud4daygh397vcmkta8rlzq
2. 2/5 threshold multisig of the first 5 faucet accounts\
cosmos1h90ml36rcu7yegwduzgzderj2jmq49hcpfclw9
3. 3/5 threshold multisig of the first 5 faucet accounts\
cosmos1d2mg2euvus3tu2tprfwrfzeal4xu7kygugjxjc
5 changes: 5 additions & 0 deletions scripts/simapp50/env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Choose from https://github.com/cosmos/cosmos-sdk/pkgs/container/simapp
REPOSITORY="ghcr.io/cosmos/simapp"
VERSION="0.50.1"
CONTAINER_NAME="simapp"
CONTAINER_NAME_SLOW="simapp-slow"
Loading

0 comments on commit b7c66d8

Please sign in to comment.