Loosen pedantic check for fully-empty compares (#3873)
* Loosen pedantic check for fully-empty compares * Bump dev * Update CHANGELOG * Bump common
This commit is contained in:
@@ -19,10 +19,10 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-contract#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.14.8",
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/api": "5.4.2-5",
|
||||
"@polkadot/types": "5.4.2-5",
|
||||
"@polkadot/util": "^7.1.1",
|
||||
"@polkadot/util": "^7.1.3-3",
|
||||
"rxjs": "^7.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,16 +19,16 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api-derive#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.14.8",
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/api": "5.4.2-5",
|
||||
"@polkadot/rpc-core": "5.4.2-5",
|
||||
"@polkadot/types": "5.4.2-5",
|
||||
"@polkadot/util": "^7.1.1",
|
||||
"@polkadot/util-crypto": "^7.1.1",
|
||||
"@polkadot/util": "^7.1.3-3",
|
||||
"@polkadot/util-crypto": "^7.1.3-3",
|
||||
"rxjs": "^7.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^7.1.1",
|
||||
"@polkadot/keyring": "^7.1.3-3",
|
||||
"@polkadot/rpc-provider": "5.4.2-5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,15 +19,15 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/api#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.14.8",
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/api-derive": "5.4.2-5",
|
||||
"@polkadot/keyring": "^7.1.1",
|
||||
"@polkadot/keyring": "^7.1.3-3",
|
||||
"@polkadot/rpc-core": "5.4.2-5",
|
||||
"@polkadot/rpc-provider": "5.4.2-5",
|
||||
"@polkadot/types": "5.4.2-5",
|
||||
"@polkadot/types-known": "5.4.2-5",
|
||||
"@polkadot/util": "^7.1.1",
|
||||
"@polkadot/util-crypto": "^7.1.1",
|
||||
"@polkadot/util": "^7.1.3-3",
|
||||
"@polkadot/util-crypto": "^7.1.3-3",
|
||||
"eventemitter3": "^4.0.7",
|
||||
"rxjs": "^7.3.0"
|
||||
}
|
||||
|
||||
@@ -19,13 +19,13 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-core#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.14.8",
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/rpc-provider": "5.4.2-5",
|
||||
"@polkadot/types": "5.4.2-5",
|
||||
"@polkadot/util": "^7.1.1",
|
||||
"@polkadot/util": "^7.1.3-3",
|
||||
"rxjs": "^7.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^7.1.1"
|
||||
"@polkadot/keyring": "^7.1.3-3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,17 +19,17 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.14.8",
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/types": "5.4.2-5",
|
||||
"@polkadot/util": "^7.1.1",
|
||||
"@polkadot/util-crypto": "^7.1.1",
|
||||
"@polkadot/x-fetch": "^7.1.1",
|
||||
"@polkadot/x-global": "^7.1.1",
|
||||
"@polkadot/x-ws": "^7.1.1",
|
||||
"@polkadot/util": "^7.1.3-3",
|
||||
"@polkadot/util-crypto": "^7.1.3-3",
|
||||
"@polkadot/x-fetch": "^7.1.3-3",
|
||||
"@polkadot/x-global": "^7.1.3-3",
|
||||
"@polkadot/x-ws": "^7.1.3-3",
|
||||
"eventemitter3": "^4.0.7"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^7.1.1",
|
||||
"@polkadot/keyring": "^7.1.3-3",
|
||||
"@polkadot/types": "5.4.2-5",
|
||||
"mock-socket": "^9.0.3",
|
||||
"nock": "^13.1.1"
|
||||
|
||||
@@ -27,13 +27,13 @@
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/typegen#readme",
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.15.0",
|
||||
"@babel/register": "^7.14.5",
|
||||
"@babel/runtime": "^7.14.8",
|
||||
"@babel/register": "^7.15.3",
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/api": "5.4.2-5",
|
||||
"@polkadot/rpc-provider": "5.4.2-5",
|
||||
"@polkadot/types": "5.4.2-5",
|
||||
"@polkadot/types-support": "5.4.2-5",
|
||||
"@polkadot/util": "^7.1.1",
|
||||
"@polkadot/util": "^7.1.3-3",
|
||||
"handlebars": "^4.7.7",
|
||||
"websocket": "^1.0.34",
|
||||
"yargs": "^17.1.0"
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-known#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.14.8",
|
||||
"@polkadot/networks": "^7.1.1",
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/networks": "^7.1.3-3",
|
||||
"@polkadot/types": "5.4.2-5",
|
||||
"@polkadot/util": "^7.1.1"
|
||||
"@polkadot/util": "^7.1.3-3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types-support#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.14.8",
|
||||
"@polkadot/util": "^7.1.1"
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/util": "^7.1.3-3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,13 +19,13 @@
|
||||
"bugs": "https://github.com/polkadot-js/api/issues",
|
||||
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.14.8",
|
||||
"@polkadot/util": "^7.1.1",
|
||||
"@polkadot/util-crypto": "^7.1.1",
|
||||
"@babel/runtime": "^7.15.3",
|
||||
"@polkadot/util": "^7.1.3-3",
|
||||
"@polkadot/util-crypto": "^7.1.3-3",
|
||||
"rxjs": "^7.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^7.1.1",
|
||||
"@polkadot/keyring": "^7.1.3-3",
|
||||
"@polkadot/types-support": "5.4.2-5",
|
||||
"@types/bn.js": "^4.11.6",
|
||||
"bn.js": "^4.11.9"
|
||||
|
||||
@@ -12,18 +12,25 @@ import { createClass } from './createClass';
|
||||
|
||||
// With isPedantic, actually check that the encoding matches that supplied. This
|
||||
// is much slower, but verifies that we have the correct types defined
|
||||
function checkInstance (created: Codec, value: Uint8Array): void {
|
||||
function checkInstance (created: Codec, matcher: Uint8Array): void {
|
||||
const u8a = created.toU8a();
|
||||
const rawType = created.toRawType();
|
||||
|
||||
assert(
|
||||
u8aEq(value, u8a) || (
|
||||
// when length-prefixed from hex, just check the actual length
|
||||
const isOk = (
|
||||
// full match, all ok
|
||||
u8aEq(u8a, matcher) ||
|
||||
(
|
||||
// on a length-prefixed type, just check the actual length
|
||||
['Bytes', 'Text', 'Type'].includes(rawType) &&
|
||||
value.length === (created as Bytes).length
|
||||
),
|
||||
() => `${rawType}:: Decoded input doesn't match input, received ${u8aToHex(value, 512)} (${value.length} bytes), created ${u8aToHex(u8a, 512)} (${u8a.length} bytes)`
|
||||
matcher.length === (created as Bytes).length
|
||||
) ||
|
||||
(
|
||||
// when the created is empty and matcher is also empty, let it slide...
|
||||
created.isEmpty &&
|
||||
matcher.every((v) => !v)
|
||||
)
|
||||
);
|
||||
|
||||
assert(isOk, () => `${rawType}:: Decoded input doesn't match input, received ${u8aToHex(matcher, 512)} (${matcher.length} bytes), created ${u8aToHex(u8a, 512)} (${u8a.length} bytes)`);
|
||||
}
|
||||
|
||||
function checkPedantic (created: Codec, [value]: unknown[], isPedantic = false): void {
|
||||
|
||||
Reference in New Issue
Block a user