Expand e2e (#178)

* Expand e2e

* Add toJSON method for StorageFunction
This commit is contained in:
Jaco Greeff
2018-10-01 15:18:56 +02:00
committed by GitHub
parent 3f997a1cda
commit 4fc0eedbe8
3 changed files with 19 additions and 1 deletions
+1
View File
@@ -14,6 +14,7 @@ import { StorageFunctionMetadata } from './Metadata';
export interface StorageFunction { export interface StorageFunction {
(arg?: any): Uint8Array; (arg?: any): Uint8Array;
meta: StorageFunctionMetadata; meta: StorageFunctionMetadata;
toJSON: () => any;
} }
// A representation of a storage key (typically hashed) in the system. It can be constructed // A representation of a storage key (typically hashed) in the system. It can be constructed
@@ -22,11 +22,27 @@ describe.skip('e2e subscriptions', () => {
api.state api.state
.storage([[storage.timestamp.now]]) .storage([[storage.timestamp.now]])
.subscribe((data) => { .subscribe((data) => {
console.error('subscribe', data); console.error('timestamp.now', data);
if (++count === 4) { if (++count === 4) {
done(); done();
} }
}); });
}); });
it('retrieves multiple values', (done) => {
api.state
.storage([
[storage.timestamp.now],
[storage.session.sessionLength],
[storage.staking.sessionsPerEra]
])
.subscribe((data) => {
console.error('multiples', data);
if (data !== undefined && data.filter((item) => item).length === 3) {
done();
}
});
});
}); });
@@ -65,6 +65,7 @@ export default function createFunction (
} }
storageFn.meta = meta; storageFn.meta = meta;
storageFn.toJSON = meta.toJSON;
return storageFn as StorageFunction; return storageFn as StorageFunction;
} }