Ensure apiAt.<section>.<method>.key(...) passes through the correct arguments (#5283)

This commit is contained in:
Jaco
2022-10-21 10:23:54 +03:00
committed by GitHub
parent b66d62548a
commit be95356999
4 changed files with 12 additions and 10 deletions
@@ -46,6 +46,11 @@ export const NO_RAW_ARGS: RawArgs = {
keys: []
};
/** @internal */
function filterDefined (a: unknown): boolean {
return !isUndefined(a);
}
/** @internal */
function assertArgs ({ method, section }: CreateItemFn, { args, keys }: RawArgs): void {
if (!Array.isArray(args)) {
@@ -112,11 +117,6 @@ export function createKeyRaw (registry: Registry, itemFn: CreateItemBase, args:
);
}
/** @internal */
function filterDefined (a: unknown): boolean {
return !isUndefined(a);
}
/** @internal */
function createKey (registry: Registry, itemFn: CreateItemFn, args: RawArgs): Uint8Array {
assertArgs(itemFn, args);
@@ -36,6 +36,10 @@ describe('decorateStorage', (): void => {
expect(() => query.timestamp.now()).not.toThrow();
});
it('should return a value if the storage function has the correct arguments', (): void => {
expect(() => query.staking.erasStakers(1, keyring.alice.address)).not.toThrow();
});
it('should return the correct length-prefixed storage key', (): void => {
expect(
u8aToHex(query.system.account(keyring.alice.address))