Adjust test expectations (#5490)

This commit is contained in:
Jaco
2023-02-16 21:10:17 +02:00
committed by GitHub
parent 5cbe80066d
commit b8233fb7b8
10 changed files with 30 additions and 22 deletions
@@ -284,7 +284,7 @@ describe('ScProvider', () => {
await provider.connect(undefined, mockedHealthChecker.healthChecker);
expect(() => provider.clone()).toThrowError();
expect(() => provider.clone()).toThrow();
});
});
@@ -306,7 +306,7 @@ describe('ScProvider', () => {
setChainSyncyingStatus(false);
await expect(provider.connect(undefined, mockedHealthChecker.healthChecker)).rejects.toThrowError(
await expect(provider.connect(undefined, mockedHealthChecker.healthChecker)).rejects.toThrow(
'Already connected!'
);
});
@@ -402,7 +402,7 @@ describe('ScProvider', () => {
throw new Error('boom!');
});
await expect(provider.send('getData', ['foo'])).rejects.toThrowError(
await expect(provider.send('getData', ['foo'])).rejects.toThrow(
'Disconnected'
);
expect(provider.isConnected).toBe(false);
@@ -565,7 +565,7 @@ describe('ScProvider', () => {
await expect(
provider.subscribe('foo', 'bar', ['baz'], () => {})
).rejects.toThrowError('Unsupported subscribe method: bar');
).rejects.toThrow('Unsupported subscribe method: bar');
});
});
@@ -577,7 +577,7 @@ describe('ScProvider', () => {
setChainSyncyingStatus(false);
await expect(provider.unsubscribe('', '', '')).rejects.toThrowError(
await expect(provider.unsubscribe('', '', '')).rejects.toThrow(
'Unable to find active subscription=::'
);
});
+3 -3
View File
@@ -58,7 +58,7 @@ describe('Endpoint Parsing', (): void => {
it('Throws when WsProvider endpoint is an invalid string', () => {
expect(
() => new WsProvider('http://127.0.0.1:9955', 0)
).toThrowError(/^Endpoint should start with /);
).toThrow(/^Endpoint should start with /);
});
it('Succeeds when WsProvider endpoint is a valid array', () => {
@@ -73,7 +73,7 @@ describe('Endpoint Parsing', (): void => {
expect(
() => new WsProvider(endpoints, 0)
).toThrowError('WsProvider requires at least one Endpoint');
).toThrow('WsProvider requires at least one Endpoint');
});
it('Throws when WsProvider endpoint is an invalid array', () => {
@@ -81,6 +81,6 @@ describe('Endpoint Parsing', (): void => {
expect(
() => new WsProvider(endpoints, 0)
).toThrowError(/^Endpoint should start with /);
).toThrow(/^Endpoint should start with /);
});
});
@@ -81,7 +81,7 @@ describe('BTreeMap', (): void => {
(): BTreeMap<Text, U32> => new (
BTreeMap.with(Text, U32)
)(registry, 'ABC')
).toThrowError(/Map: cannot decode type/);
).toThrow(/Map: cannot decode type/);
});
it('correctly encodes length', (): void => {
@@ -123,7 +123,7 @@ describe('BTreeSet', (): void => {
(): BTreeSet<U32> => new (
BTreeSet.with(U32)
)(registry, 'ABC')
).toThrowError(/BTreeSet: cannot decode type/);
).toThrow(/BTreeSet: cannot decode type/);
});
describe('enocodedLength & initialU8aLength', (): void => {
@@ -134,7 +134,7 @@ describe('Struct', (): void => {
u32: U32
})
)(registry, 'ABC')
).toThrowError(/Cannot decode value/);
).toThrow(/Cannot decode value/);
});
it('throws a sensical error on incorrect array values passed to structs', (): void => {
+5 -5
View File
@@ -42,14 +42,14 @@ ${formatFixed(micro).padStart(NUM_PAD + PRE_PAD + 1)} μs/op`;
}
export function perf (name: string, count: number, inputs: unknown[][], exec: ExecFn): void {
if (process.env.GITHUB_REPOSITORY) {
return;
}
const test = process.env.GITHUB_REPOSITORY
? it.skip
: it;
it(`performance: ${name}`, (): void => {
test(`performance: ${name}`, (): void => {
const [time] = loop(count, inputs, exec);
console.log(`
console.error(`
performance run for ${name} completed with ${formatNumber(count)} iterations.
${`${name}:`.padStart(PRE_PAD)} ${time.toFixed(2).padStart(NUM_PAD)} ms${formatOps(count, time)}
@@ -13,8 +13,15 @@ describe('SystemInherentData', (): void => {
it('can decode Kilt', (): void => {
const value = registry.createType('SystemInherentData', KILT);
console.log(JSON.stringify(value.toHuman(), null, 2));
// console.log(JSON.stringify(value.toHuman(), null, 2));
expect(value).toBeTruthy();
expect(value.toHuman()).toMatchObject({
validationData: {
maxPovSize: '0',
parentHead: '0xd51627af4cb8414b6ad454e7204424e7e8489738c5fabe20cee3256bd69b7534d12b2798b04e574d05fb8a4b163745b1e610fb75de59399271bd57e49738506a7a93ee0038dd6a1b3bfbb58f747a7b2052058620839a8e2d03f5a43b48ca6000c66a00',
relayParentNumber: '38,441',
relayParentStorageRoot: '0x4412f5d19eed1a0cbafadd3b050b6e87fbcdff0a4b2ab0dce498d2180f7d7fe4'
}
});
});
});
@@ -55,7 +55,7 @@ describe('extrinsics', (): void => {
describe('decorateExtrinsics', (): void => {
it('should throw if an incorrect number of args is supplied', (): void => {
expect(() => extrinsics.balances.setBalance()).toThrowError(/expects 3 arguments/);
expect(() => extrinsics.balances.setBalance()).toThrow(/expects 3 arguments/);
});
it('should return a value if the storage function does not expect an argument', (): void => {
@@ -21,15 +21,15 @@ describe('decorateStorage', (): void => {
const query = decorateStorage(registry, metadata.asLatest, metadata.version);
it('should throw if the storage function expects an argument', (): void => {
expect(() => query.balances.account()).toThrowError('Call to balances.account needs 1 arguments, found []');
expect(() => query.balances.account()).toThrow('Call to balances.account needs 1 arguments, found []');
});
it('should throw if the storage function expects multiple arguments', (): void => {
expect(() => query.staking.erasStakers([1])).toThrowError('Call to staking.erasStakers needs 2 arguments, found [1]');
expect(() => query.staking.erasStakers([1])).toThrow('Call to staking.erasStakers needs 2 arguments, found [1]');
});
it('should throw if the storage function expects tuple arguments', (): void => {
expect(() => query.staking.erasStakers(1)).toThrowError('Call to staking.erasStakers needs 2 arguments');
expect(() => query.staking.erasStakers(1)).toThrow('Call to staking.erasStakers needs 2 arguments, found [1]');
});
it('should return a value if the storage function does not expect an argument', (): void => {