From 531101a2e272dd2d94c9bec278dfd58957ed87c7 Mon Sep 17 00:00:00 2001 From: Davide Segullo Date: Fri, 6 Sep 2024 16:44:48 +0200 Subject: [PATCH 1/5] feat: :sparkles: Removed an unnecessary request to the nodes --- packages/tendermint-rpc/src/comet38/comet38client.ts | 6 +++++- .../tendermint-rpc/src/tendermint34/tendermint34client.ts | 6 +++++- .../tendermint-rpc/src/tendermint37/tendermint37client.ts | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/tendermint-rpc/src/comet38/comet38client.ts b/packages/tendermint-rpc/src/comet38/comet38client.ts index 2d20513fac..94065d70c5 100644 --- a/packages/tendermint-rpc/src/comet38/comet38client.ts +++ b/packages/tendermint-rpc/src/comet38/comet38client.ts @@ -39,7 +39,11 @@ export class Comet38Client { // (our CI) when skipping the status call before doing other queries. Sleeping a little // while did not help. Thus we query the version as a way to say "hi" to the backend, // even in cases where we don't use the result. - const _version = await this.detectVersion(rpcClient); + // However we can run this code only inside our CI, so we don't have to run this code inside the prod build, + // this avoids an unnecessary request to the RPC nodes + if (process.env.TENDERMINT_ENABLED) { + const _version = await this.detectVersion(rpcClient); + } return Comet38Client.create(rpcClient); } diff --git a/packages/tendermint-rpc/src/tendermint34/tendermint34client.ts b/packages/tendermint-rpc/src/tendermint34/tendermint34client.ts index 6704a6f066..7111d52150 100644 --- a/packages/tendermint-rpc/src/tendermint34/tendermint34client.ts +++ b/packages/tendermint-rpc/src/tendermint34/tendermint34client.ts @@ -39,7 +39,11 @@ export class Tendermint34Client { // (our CI) when skipping the status call before doing other queries. Sleeping a little // while did not help. Thus we query the version as a way to say "hi" to the backend, // even in cases where we don't use the result. - const _version = await this.detectVersion(rpcClient); + // However we can run this code only inside our CI, so we don't have to run this code inside the prod build, + // this avoids an unnecessary request to the RPC nodes + if (process.env.TENDERMINT_ENABLED) { + const _version = await this.detectVersion(rpcClient); + } return Tendermint34Client.create(rpcClient); } diff --git a/packages/tendermint-rpc/src/tendermint37/tendermint37client.ts b/packages/tendermint-rpc/src/tendermint37/tendermint37client.ts index 3d55949720..d7118a3a03 100644 --- a/packages/tendermint-rpc/src/tendermint37/tendermint37client.ts +++ b/packages/tendermint-rpc/src/tendermint37/tendermint37client.ts @@ -39,7 +39,11 @@ export class Tendermint37Client { // (our CI) when skipping the status call before doing other queries. Sleeping a little // while did not help. Thus we query the version as a way to say "hi" to the backend, // even in cases where we don't use the result. - const _version = await this.detectVersion(rpcClient); + // However we can run this code only inside our CI, so we don't have to run this code inside the prod build, + // this avoids an unnecessary request to the RPC nodes + if (process.env.TENDERMINT_ENABLED) { + const _version = await this.detectVersion(rpcClient); + } return Tendermint37Client.create(rpcClient); } From 6afd20a69047b77b067164518f4acbcccb231525 Mon Sep 17 00:00:00 2001 From: Davide Segullo Date: Fri, 6 Sep 2024 17:35:21 +0200 Subject: [PATCH 2/5] feat: :wrench: add karma process mock --- packages/cosmwasm-stargate/global-variables.js | 5 +++++ packages/cosmwasm-stargate/karma.conf.js | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 packages/cosmwasm-stargate/global-variables.js diff --git a/packages/cosmwasm-stargate/global-variables.js b/packages/cosmwasm-stargate/global-variables.js new file mode 100644 index 0000000000..fdf77db086 --- /dev/null +++ b/packages/cosmwasm-stargate/global-variables.js @@ -0,0 +1,5 @@ +const process = { + env: { + TENDERMINT_ENABLED: 1, + } +}; \ No newline at end of file diff --git a/packages/cosmwasm-stargate/karma.conf.js b/packages/cosmwasm-stargate/karma.conf.js index 31c44e8edf..e13315aadc 100644 --- a/packages/cosmwasm-stargate/karma.conf.js +++ b/packages/cosmwasm-stargate/karma.conf.js @@ -15,7 +15,7 @@ module.exports = function (config) { frameworks: ["jasmine"], // list of files / patterns to load in the browser - files: ["dist/web/tests.js"], + files: ["./global-variables.js", "dist/web/tests.js"], client: { jasmine: { @@ -50,5 +50,13 @@ module.exports = function (config) { // Keep brower open for debugging. This is overridden by yarn scripts singleRun: false, + + webpack: { + plugins: [ + new webpack.ProvidePlugin({ + process: 'process/browser' + }) + ] + } }); }; From 8597e3ccd5d1f991ccb1bb314751f3cfbd2f97b0 Mon Sep 17 00:00:00 2001 From: Davide Segullo Date: Fri, 6 Sep 2024 18:11:13 +0200 Subject: [PATCH 3/5] feat: :wrench: add karma stargaze process mock --- packages/stargate/global-variables.js | 5 +++++ packages/stargate/karma.conf.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 packages/stargate/global-variables.js diff --git a/packages/stargate/global-variables.js b/packages/stargate/global-variables.js new file mode 100644 index 0000000000..fdf77db086 --- /dev/null +++ b/packages/stargate/global-variables.js @@ -0,0 +1,5 @@ +const process = { + env: { + TENDERMINT_ENABLED: 1, + } +}; \ No newline at end of file diff --git a/packages/stargate/karma.conf.js b/packages/stargate/karma.conf.js index 31c44e8edf..c8e74820fb 100644 --- a/packages/stargate/karma.conf.js +++ b/packages/stargate/karma.conf.js @@ -15,7 +15,7 @@ module.exports = function (config) { frameworks: ["jasmine"], // list of files / patterns to load in the browser - files: ["dist/web/tests.js"], + files: ["./global-variables.js", "dist/web/tests.js"], client: { jasmine: { From 5336b5382c0930b668439fbfe2c2fbb81f3b6f53 Mon Sep 17 00:00:00 2001 From: Davide Segullo Date: Fri, 6 Sep 2024 18:28:32 +0200 Subject: [PATCH 4/5] feat: :wrench: add jasmine global variables --- jasmine-global-variables.js | 13 +++++++++++++ packages/amino/karma.conf.js | 2 +- packages/cosmwasm-stargate/global-variables.js | 5 ----- packages/cosmwasm-stargate/karma.conf.js | 10 +--------- packages/crypto/karma.conf.js | 2 +- packages/encoding/karma.conf.js | 2 +- packages/faucet-client/karma.conf.js | 2 +- packages/math/karma.conf.js | 2 +- packages/proto-signing/karma.conf.js | 2 +- packages/socket/karma.conf.js | 2 +- packages/stargate/global-variables.js | 5 ----- packages/stargate/karma.conf.js | 2 +- packages/stream/karma.conf.js | 2 +- packages/tendermint-rpc/karma.conf.js | 2 +- packages/utils/karma.conf.js | 2 +- 15 files changed, 25 insertions(+), 30 deletions(-) create mode 100644 jasmine-global-variables.js delete mode 100644 packages/cosmwasm-stargate/global-variables.js delete mode 100644 packages/stargate/global-variables.js diff --git a/jasmine-global-variables.js b/jasmine-global-variables.js new file mode 100644 index 0000000000..4e06d84714 --- /dev/null +++ b/jasmine-global-variables.js @@ -0,0 +1,13 @@ +const process = { + ...process, + env: { + ...process.env, + HTTPSERVER_ENABLED: 1, + SIMAPP44_ENABLED: 1, + SLOW_SIMAPP44_ENABLED: 1, + TENDERMINT_ENABLED: 1, + SOCKETSERVER_ENABLED: 1, + SKIP_BUILD: 1, + WASMD_ENABLED: 1 + } +}; \ No newline at end of file diff --git a/packages/amino/karma.conf.js b/packages/amino/karma.conf.js index 31c44e8edf..711ab471cc 100644 --- a/packages/amino/karma.conf.js +++ b/packages/amino/karma.conf.js @@ -15,7 +15,7 @@ module.exports = function (config) { frameworks: ["jasmine"], // list of files / patterns to load in the browser - files: ["dist/web/tests.js"], + files: ["../../jasmine-global-variables.js", "dist/web/tests.js"], client: { jasmine: { diff --git a/packages/cosmwasm-stargate/global-variables.js b/packages/cosmwasm-stargate/global-variables.js deleted file mode 100644 index fdf77db086..0000000000 --- a/packages/cosmwasm-stargate/global-variables.js +++ /dev/null @@ -1,5 +0,0 @@ -const process = { - env: { - TENDERMINT_ENABLED: 1, - } -}; \ No newline at end of file diff --git a/packages/cosmwasm-stargate/karma.conf.js b/packages/cosmwasm-stargate/karma.conf.js index e13315aadc..711ab471cc 100644 --- a/packages/cosmwasm-stargate/karma.conf.js +++ b/packages/cosmwasm-stargate/karma.conf.js @@ -15,7 +15,7 @@ module.exports = function (config) { frameworks: ["jasmine"], // list of files / patterns to load in the browser - files: ["./global-variables.js", "dist/web/tests.js"], + files: ["../../jasmine-global-variables.js", "dist/web/tests.js"], client: { jasmine: { @@ -50,13 +50,5 @@ module.exports = function (config) { // Keep brower open for debugging. This is overridden by yarn scripts singleRun: false, - - webpack: { - plugins: [ - new webpack.ProvidePlugin({ - process: 'process/browser' - }) - ] - } }); }; diff --git a/packages/crypto/karma.conf.js b/packages/crypto/karma.conf.js index 31c44e8edf..711ab471cc 100644 --- a/packages/crypto/karma.conf.js +++ b/packages/crypto/karma.conf.js @@ -15,7 +15,7 @@ module.exports = function (config) { frameworks: ["jasmine"], // list of files / patterns to load in the browser - files: ["dist/web/tests.js"], + files: ["../../jasmine-global-variables.js", "dist/web/tests.js"], client: { jasmine: { diff --git a/packages/encoding/karma.conf.js b/packages/encoding/karma.conf.js index 31c44e8edf..711ab471cc 100644 --- a/packages/encoding/karma.conf.js +++ b/packages/encoding/karma.conf.js @@ -15,7 +15,7 @@ module.exports = function (config) { frameworks: ["jasmine"], // list of files / patterns to load in the browser - files: ["dist/web/tests.js"], + files: ["../../jasmine-global-variables.js", "dist/web/tests.js"], client: { jasmine: { diff --git a/packages/faucet-client/karma.conf.js b/packages/faucet-client/karma.conf.js index 31c44e8edf..711ab471cc 100644 --- a/packages/faucet-client/karma.conf.js +++ b/packages/faucet-client/karma.conf.js @@ -15,7 +15,7 @@ module.exports = function (config) { frameworks: ["jasmine"], // list of files / patterns to load in the browser - files: ["dist/web/tests.js"], + files: ["../../jasmine-global-variables.js", "dist/web/tests.js"], client: { jasmine: { diff --git a/packages/math/karma.conf.js b/packages/math/karma.conf.js index 31c44e8edf..711ab471cc 100644 --- a/packages/math/karma.conf.js +++ b/packages/math/karma.conf.js @@ -15,7 +15,7 @@ module.exports = function (config) { frameworks: ["jasmine"], // list of files / patterns to load in the browser - files: ["dist/web/tests.js"], + files: ["../../jasmine-global-variables.js", "dist/web/tests.js"], client: { jasmine: { diff --git a/packages/proto-signing/karma.conf.js b/packages/proto-signing/karma.conf.js index 31c44e8edf..711ab471cc 100644 --- a/packages/proto-signing/karma.conf.js +++ b/packages/proto-signing/karma.conf.js @@ -15,7 +15,7 @@ module.exports = function (config) { frameworks: ["jasmine"], // list of files / patterns to load in the browser - files: ["dist/web/tests.js"], + files: ["../../jasmine-global-variables.js", "dist/web/tests.js"], client: { jasmine: { diff --git a/packages/socket/karma.conf.js b/packages/socket/karma.conf.js index 31c44e8edf..711ab471cc 100644 --- a/packages/socket/karma.conf.js +++ b/packages/socket/karma.conf.js @@ -15,7 +15,7 @@ module.exports = function (config) { frameworks: ["jasmine"], // list of files / patterns to load in the browser - files: ["dist/web/tests.js"], + files: ["../../jasmine-global-variables.js", "dist/web/tests.js"], client: { jasmine: { diff --git a/packages/stargate/global-variables.js b/packages/stargate/global-variables.js deleted file mode 100644 index fdf77db086..0000000000 --- a/packages/stargate/global-variables.js +++ /dev/null @@ -1,5 +0,0 @@ -const process = { - env: { - TENDERMINT_ENABLED: 1, - } -}; \ No newline at end of file diff --git a/packages/stargate/karma.conf.js b/packages/stargate/karma.conf.js index c8e74820fb..711ab471cc 100644 --- a/packages/stargate/karma.conf.js +++ b/packages/stargate/karma.conf.js @@ -15,7 +15,7 @@ module.exports = function (config) { frameworks: ["jasmine"], // list of files / patterns to load in the browser - files: ["./global-variables.js", "dist/web/tests.js"], + files: ["../../jasmine-global-variables.js", "dist/web/tests.js"], client: { jasmine: { diff --git a/packages/stream/karma.conf.js b/packages/stream/karma.conf.js index 31c44e8edf..711ab471cc 100644 --- a/packages/stream/karma.conf.js +++ b/packages/stream/karma.conf.js @@ -15,7 +15,7 @@ module.exports = function (config) { frameworks: ["jasmine"], // list of files / patterns to load in the browser - files: ["dist/web/tests.js"], + files: ["../../jasmine-global-variables.js", "dist/web/tests.js"], client: { jasmine: { diff --git a/packages/tendermint-rpc/karma.conf.js b/packages/tendermint-rpc/karma.conf.js index 9ee4e92603..75cd1626f6 100644 --- a/packages/tendermint-rpc/karma.conf.js +++ b/packages/tendermint-rpc/karma.conf.js @@ -15,7 +15,7 @@ module.exports = function (config) { frameworks: ["jasmine"], // list of files / patterns to load in the browser - files: ["dist/web/tests.js"], + files: ["../../jasmine-global-variables.js", "dist/web/tests.js"], client: { jasmine: { diff --git a/packages/utils/karma.conf.js b/packages/utils/karma.conf.js index 9ee4e92603..75cd1626f6 100644 --- a/packages/utils/karma.conf.js +++ b/packages/utils/karma.conf.js @@ -15,7 +15,7 @@ module.exports = function (config) { frameworks: ["jasmine"], // list of files / patterns to load in the browser - files: ["dist/web/tests.js"], + files: ["../../jasmine-global-variables.js", "dist/web/tests.js"], client: { jasmine: { From 59c406eb323833dc8214a53b89572e76741c6e63 Mon Sep 17 00:00:00 2001 From: Davide Segullo Date: Fri, 6 Sep 2024 18:39:14 +0200 Subject: [PATCH 5/5] fix: :bug: fix runtime error --- jasmine-global-variables.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/jasmine-global-variables.js b/jasmine-global-variables.js index 4e06d84714..467a56b11b 100644 --- a/jasmine-global-variables.js +++ b/jasmine-global-variables.js @@ -1,7 +1,5 @@ const process = { - ...process, env: { - ...process.env, HTTPSERVER_ENABLED: 1, SIMAPP44_ENABLED: 1, SLOW_SIMAPP44_ENABLED: 1,