Merge pull request #1240 from cosmos/test-node-18

Test node.js 18
This commit is contained in:
Simon Warta 2022-12-08 12:18:18 +01:00 committed by GitHub
commit 6b05c122fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 102 additions and 126 deletions

View File

@ -34,7 +34,7 @@ workflows:
- build
matrix:
parameters:
node-version: ["14", "16"]
node-version: ["14", "16", "18"]
- test-chrome:
requires:
- build
@ -245,6 +245,7 @@ jobs:
declare -A node_links=(
["14"]="https://deb.nodesource.com/node_14.x/pool/main/n/nodejs/nodejs_14.18.0-deb-1nodesource1_amd64.deb"
["16"]="https://deb.nodesource.com/node_16.x/pool/main/n/nodejs/nodejs_16.13.2-deb-1nodesource1_amd64.deb"
["18"]="https://deb.nodesource.com/node_18.x/pool/main/n/nodejs/nodejs_18.7.0-deb-1nodesource1_amd64.deb"
)
wget -O "$HOME/nodejs.deb" "${node_links[<< parameters.node-version >>]}"
sudo dpkg -i "$HOME/nodejs.deb"

79
.pnp.cjs generated
View File

@ -2026,6 +2026,10 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
"node-gyp",\
"npm:8.0.0"\
],\
[\
"node-gyp-build",\
"npm:4.5.0"\
],\
[\
"node-hid",\
"npm:2.1.1"\
@ -2676,7 +2680,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
],\
[\
"usb",\
"npm:1.7.1"\
"npm:1.9.2"\
],\
[\
"util-deprecate",\
@ -2746,10 +2750,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
"which-module",\
"npm:2.0.0"\
],\
[\
"which-pm-runs",\
"npm:1.0.0"\
],\
[\
"wide-align",\
"npm:1.1.3"\
@ -4121,7 +4121,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["@ledgerhq/logs", "npm:5.50.0"],\
["lodash", "npm:4.17.21"],\
["node-hid", "npm:2.1.1"],\
["usb", "npm:1.7.1"]\
["usb", "npm:1.9.2"]\
],\
"linkType": "HARD"\
}]\
@ -9918,14 +9918,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["node-addon-api", [\
["npm:3.0.2", {\
"packageLocation": "./.yarn/unplugged/node-addon-api-npm-3.0.2-4c22ea0673/node_modules/node-addon-api/",\
"packageDependencies": [\
["node-addon-api", "npm:3.0.2"],\
["node-gyp", "npm:8.0.0"]\
],\
"linkType": "HARD"\
}],\
["npm:3.2.0", {\
"packageLocation": "./.yarn/unplugged/node-addon-api-npm-3.2.0-061ff0dbab/node_modules/node-addon-api/",\
"packageDependencies": [\
@ -9933,6 +9925,14 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
["node-gyp", "npm:8.0.0"]\
],\
"linkType": "HARD"\
}],\
["npm:4.3.0", {\
"packageLocation": "./.yarn/unplugged/node-addon-api-npm-4.3.0-a07a1232df/node_modules/node-addon-api/",\
"packageDependencies": [\
["node-addon-api", "npm:4.3.0"],\
["node-gyp", "npm:8.0.0"]\
],\
"linkType": "HARD"\
}]\
]],\
["node-gyp", [\
@ -9954,6 +9954,15 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
"linkType": "HARD"\
}]\
]],\
["node-gyp-build", [\
["npm:4.5.0", {\
"packageLocation": "./.yarn/cache/node-gyp-build-npm-4.5.0-2538da6152-d888bae0fb.zip/node_modules/node-gyp-build/",\
"packageDependencies": [\
["node-gyp-build", "npm:4.5.0"]\
],\
"linkType": "HARD"\
}]\
]],\
["node-hid", [\
["npm:2.1.1", {\
"packageLocation": "./.yarn/unplugged/node-hid-npm-2.1.1-840235e168/node_modules/node-hid/",\
@ -10457,28 +10466,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["prebuild-install", [\
["npm:5.3.6", {\
"packageLocation": "./.yarn/cache/prebuild-install-npm-5.3.6-843a9baf36-9b99e5ea2c.zip/node_modules/prebuild-install/",\
"packageDependencies": [\
["prebuild-install", "npm:5.3.6"],\
["detect-libc", "npm:1.0.3"],\
["expand-template", "npm:2.0.3"],\
["github-from-package", "npm:0.0.0"],\
["minimist", "npm:1.2.6"],\
["mkdirp-classic", "npm:0.5.3"],\
["napi-build-utils", "npm:1.0.2"],\
["node-abi", "npm:2.26.0"],\
["noop-logger", "npm:0.1.1"],\
["npmlog", "npm:4.1.2"],\
["pump", "npm:3.0.0"],\
["rc", "npm:1.2.8"],\
["simple-get", "npm:3.1.1"],\
["tar-fs", "npm:2.1.1"],\
["tunnel-agent", "npm:0.6.0"],\
["which-pm-runs", "npm:1.0.0"]\
],\
"linkType": "HARD"\
}],\
["npm:6.1.2", {\
"packageLocation": "./.yarn/cache/prebuild-install-npm-6.1.2-5d6abe684c-db205c9f40.zip/node_modules/prebuild-install/",\
"packageDependencies": [\
@ -12265,14 +12252,13 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
}]\
]],\
["usb", [\
["npm:1.7.1", {\
"packageLocation": "./.yarn/unplugged/usb-npm-1.7.1-d03d3a15f5/node_modules/usb/",\
["npm:1.9.2", {\
"packageLocation": "./.yarn/unplugged/usb-npm-1.9.2-7362a49b80/node_modules/usb/",\
"packageDependencies": [\
["usb", "npm:1.7.1"],\
["bindings", "npm:1.5.0"],\
["node-addon-api", "npm:3.0.2"],\
["usb", "npm:1.9.2"],\
["node-addon-api", "npm:4.3.0"],\
["node-gyp", "npm:8.0.0"],\
["prebuild-install", "npm:5.3.6"]\
["node-gyp-build", "npm:4.5.0"]\
],\
"linkType": "HARD"\
}]\
@ -13622,15 +13608,6 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
"linkType": "HARD"\
}]\
]],\
["which-pm-runs", [\
["npm:1.0.0", {\
"packageLocation": "./.yarn/cache/which-pm-runs-npm-1.0.0-c3252bc9d6-30cf7aee31.zip/node_modules/which-pm-runs/",\
"packageDependencies": [\
["which-pm-runs", "npm:1.0.0"]\
],\
"linkType": "HARD"\
}]\
]],\
["wide-align", [\
["npm:1.1.3", {\
"packageLocation": "./.yarn/cache/wide-align-npm-1.1.3-48c7d4953c-d09c801265.zip/node_modules/wide-align/",\

Binary file not shown.

BIN
.yarn/cache/node-addon-api-npm-4.3.0-a07a1232df-3de396e23c.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

BIN
.yarn/cache/node-gyp-build-npm-4.5.0-2538da6152-d888bae0fb.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

Binary file not shown.

BIN
.yarn/cache/usb-npm-1.7.1-d03d3a15f5-7d20ffef8b.zip (Stored with Git LFS) vendored

Binary file not shown.

BIN
.yarn/cache/usb-npm-1.9.2-7362a49b80-7aaf6669f0.zip (Stored with Git LFS) vendored Normal file

Binary file not shown.

Binary file not shown.

View File

@ -9,6 +9,7 @@ and this project adheres to
### Changed
- all: The TypeScript compilation target is now ES2020 ([#1002]).
- all: Add full support for Node.js 18 and run all CI tests with it ([#1240]).
- @cosmjs/tendermint-rpc: Remove unused `index` field from `RpcTxEvent` and
`TxEvent`. This is unset starting with Tendermint 0.34.
- @cosmjs/crypto: The pbkdf2 implementation for old Node.js versions
@ -18,6 +19,7 @@ and this project adheres to
[#1002]: https://github.com/cosmos/cosmjs/issues/1002
[#1341]: https://github.com/cosmos/cosmjs/issues/1341
[#1240]: https://github.com/cosmos/cosmjs/pull/1240
## [0.29.5] - 2022-12-07

View File

@ -19,17 +19,11 @@ describe("http", () => {
expect(response).toEqual(jasmine.objectContaining({ jsonrpc: "2.0" }));
});
it("errors for non-open port", async () => {
await expectAsync(
http("POST", `http://localhost:56745`, undefined, createJsonRpcRequest("health")),
).toBeRejectedWithError(/(ECONNREFUSED|Failed to fetch)/i);
});
it("can send custom headers", async () => {
it("can POST to echo server", async () => {
pendingWithoutHttpServer();
// Without custom headers
const response1 = await http("POST", echoUrl, undefined, createJsonRpcRequest("health"));
expect(response1).toEqual({
const response = await http("POST", echoUrl, undefined, createJsonRpcRequest("health"));
expect(response).toEqual({
request_headers: jasmine.objectContaining({
// Basic headers from http client
Accept: jasmine.any(String),
@ -39,15 +33,25 @@ describe("http", () => {
"User-Agent": jasmine.any(String),
}),
});
});
it("errors for non-open port", async () => {
await expectAsync(
http("POST", `http://localhost:56745`, undefined, createJsonRpcRequest("health")),
).toBeRejectedWithError(/(ECONNREFUSED|Failed to fetch)/i);
});
it("can POST to echo server with custom headers", async () => {
pendingWithoutHttpServer();
// With custom headers
const response2 = await http(
const response = await http(
"POST",
echoUrl,
{ foo: "bar123", Authorization: "Basic Z3Vlc3Q6bm9QYXNzMTIz" },
createJsonRpcRequest("health"),
);
expect(response2).toEqual({
expect(response).toEqual({
request_headers: jasmine.objectContaining({
// Basic headers from http client
"Content-Length": jasmine.any(String),

View File

@ -11,6 +11,23 @@ function filterBadStatus(res: any): any {
return res;
}
/**
* Node.js 18 comes with exprimental fetch support (https://nodejs.org/de/blog/announcements/v18-release-announce/).
* This is nice, but the implementation does not yet work wekk for us. We
* can just stick with axios on those systems for now.
*/
// eslint-disable-next-line @typescript-eslint/ban-types
function isExperimental(nodeJsFunc: Function): boolean {
// This works because we get this info in node 18:
//
// > fetch.toString()
// 'async function fetch(input, init = undefined) {\n' +
// " emitExperimentalWarning('The Fetch API');\n" +
// ' return lazyUndici().fetch(input, init);\n' +
// ' }'
return nodeJsFunc.toString().includes("emitExperimentalWarning");
}
/**
* Helper to work around missing CORS support in Tendermint (https://github.com/tendermint/tendermint/pull/2800)
*
@ -23,7 +40,7 @@ export async function http(
headers: Record<string, string> | undefined,
request?: any,
): Promise<any> {
if (typeof fetch !== "undefined") {
if (typeof fetch === "function" && !isExperimental(fetch)) {
const settings = {
method: method,
body: request ? JSON.stringify(request) : undefined,

View File

@ -2403,7 +2403,7 @@ __metadata:
languageName: node
linkType: hard
"bindings@npm:^1.4.0, bindings@npm:^1.5.0":
"bindings@npm:^1.5.0":
version: 1.5.0
resolution: "bindings@npm:1.5.0"
dependencies:
@ -5431,7 +5431,7 @@ __metadata:
languageName: node
linkType: hard
"node-abi@npm:^2.21.0, node-abi@npm:^2.7.0":
"node-abi@npm:^2.21.0":
version: 2.26.0
resolution: "node-abi@npm:2.26.0"
dependencies:
@ -5440,15 +5440,6 @@ __metadata:
languageName: node
linkType: hard
"node-addon-api@npm:3.0.2":
version: 3.0.2
resolution: "node-addon-api@npm:3.0.2"
dependencies:
node-gyp: latest
checksum: cd4ef5ddc17f96fc291cc74880cbf5c1d65ab849098bc3092fa6f15f6e1a4f5ec474e071715bace3fabeb0860599bccb1a3f151063cd269962c0653dc999bf39
languageName: node
linkType: hard
"node-addon-api@npm:^3.0.2":
version: 3.2.0
resolution: "node-addon-api@npm:3.2.0"
@ -5458,6 +5449,26 @@ __metadata:
languageName: node
linkType: hard
"node-addon-api@npm:^4.2.0":
version: 4.3.0
resolution: "node-addon-api@npm:4.3.0"
dependencies:
node-gyp: latest
checksum: 3de396e23cc209f539c704583e8e99c148850226f6e389a641b92e8967953713228109f919765abc1f4355e801e8f41842f96210b8d61c7dcc10a477002dcf00
languageName: node
linkType: hard
"node-gyp-build@npm:^4.3.0":
version: 4.5.0
resolution: "node-gyp-build@npm:4.5.0"
bin:
node-gyp-build: bin.js
node-gyp-build-optional: optional.js
node-gyp-build-test: build-test.js
checksum: d888bae0fb88335f69af1b57a2294a931c5042f36e413d8d364c992c9ebfa0b96ffe773179a5a2c8f04b73856e8634e09cce108dbb9804396d3cc8c5455ff2db
languageName: node
linkType: hard
"node-gyp@npm:latest":
version: 8.0.0
resolution: "node-gyp@npm:8.0.0"
@ -5935,31 +5946,6 @@ __metadata:
languageName: node
linkType: hard
"prebuild-install@npm:^5.3.3":
version: 5.3.6
resolution: "prebuild-install@npm:5.3.6"
dependencies:
detect-libc: ^1.0.3
expand-template: ^2.0.3
github-from-package: 0.0.0
minimist: ^1.2.3
mkdirp-classic: ^0.5.3
napi-build-utils: ^1.0.1
node-abi: ^2.7.0
noop-logger: ^0.1.1
npmlog: ^4.0.1
pump: ^3.0.0
rc: ^1.2.7
simple-get: ^3.0.3
tar-fs: ^2.0.0
tunnel-agent: ^0.6.0
which-pm-runs: ^1.0.0
bin:
prebuild-install: bin.js
checksum: 9b99e5ea2c1db44efbd1bc1f3d04f887e66ae282af8560191ee3005886c8d3fab578ad3e903d0965fec082d3c0779e6337a63152dc9d0f847f1bc95317356ea1
languageName: node
linkType: hard
"prebuild-install@npm:^6.0.0":
version: 6.1.2
resolution: "prebuild-install@npm:6.1.2"
@ -7293,14 +7279,13 @@ __metadata:
linkType: hard
"usb@npm:^1.7.0":
version: 1.7.1
resolution: "usb@npm:1.7.1"
version: 1.9.2
resolution: "usb@npm:1.9.2"
dependencies:
bindings: ^1.4.0
node-addon-api: 3.0.2
node-addon-api: ^4.2.0
node-gyp: latest
prebuild-install: ^5.3.3
checksum: 7d20ffef8bc0052d0510387968bcedf70e071639eec46985ee17648d26cba6595ef0fbee3837b6701235dded52eb30cf1c51be423ab877c704569914ec3323fa
node-gyp-build: ^4.3.0
checksum: 7aaf6669f02c6f4bebe571de1c364447ca44be4dc8c60fc3261f38660e04015099ebed3943935ad64755afccd11213245d697ea05571a2f142d912bb801bb54f
languageName: node
linkType: hard
@ -7492,13 +7477,6 @@ __metadata:
languageName: node
linkType: hard
"which-pm-runs@npm:^1.0.0":
version: 1.0.0
resolution: "which-pm-runs@npm:1.0.0"
checksum: 30cf7aee31f264558070e92414316c169367bb2b84a0a32777d30392fea0892fcf9955b81c3fe7f52165ae5a33f0acfd3bc0916416cb07e6d414c90255c228ca
languageName: node
linkType: hard
"which@npm:^1.2.1":
version: 1.3.1
resolution: "which@npm:1.3.1"