update signature of doublemap storage function, add e2e test cases (#957)

* update signature of doublemap storage function

* add test cases

* update doublemap implementation

* update implementation

* remove duplicate test case

* update test cases
This commit is contained in:
Alex Wang
2019-05-29 16:14:42 +02:00
committed by Jaco Greeff
parent e1a54f2b42
commit a7f16064a9
7 changed files with 241 additions and 44 deletions
@@ -232,4 +232,18 @@ describe('createType', () => {
createType('{"_enum": {"A": null, "B": "u32", "C": null} }', 1).toJSON()
).toEqual({ B: 0 });
});
it('throw error when create base is a StorageData with null value and isPedantic is true' , () => {
const base = createType('StorageData', null);
expect(
() => createType('DoubleMap<Vec<(BlockNumber,EventIndex)>>', base, true)
).toThrow(/Encoding for input doesn't match output, created 0x00 from 0x/);
});
it('throw error when create base is a StorageData with null value and isPedantic is true' , () => {
const base = createType('StorageData', null);
expect(
() => createType('Vec<(BlockNumber,EventIndex)>', base, true)
).toThrow(/Encoding for input doesn't match output, created 0x00 from 0x/);
});
});
@@ -4,7 +4,6 @@
import { assert, isFunction, isString, isU8a } from '@polkadot/util';
import U8a from '../codec/U8a';
import { StorageFunctionMetadata as MetaV4 } from '../Metadata/v4/Storage';
import { AnyU8a } from '../types';
import Bytes from './Bytes';
@@ -70,14 +69,6 @@ export default class StorageKey extends Bytes {
assert(isFunction(fn), 'Expected function input for key construction');
if (fn.meta && fn.meta.type.isDoubleMap) {
return {
key: new U8a(fn(...arg)), // skip compact length check in decodeBytes
method: fn.method,
section: fn.section
};
}
return {
key: fn(...arg),
method: fn.method,