Encode mock results as string (#69)

This commit is contained in:
Jaco Greeff
2018-04-17 14:06:12 +02:00
committed by GitHub
parent 5c8eb6a2ad
commit 9c5b5103a7
6 changed files with 23 additions and 20 deletions
+6 -3
View File
@@ -6,6 +6,7 @@
import type { MockState, MockState$Storage } from './types';
const interfaces = require('@polkadot/api-jsonrpc');
const u8aToHex = require('@polkadot/util/u8a/toHex');
const l = require('@polkadot/util/logger')('api-mock');
const SUBSCRIPTIONS = Array.prototype.concat.apply(
@@ -18,9 +19,11 @@ const SUBSCRIPTIONS = Array.prototype.concat.apply(
);
const REQUESTS = {
'state_getStorage': (storage: MockState$Storage, params: Array<mixed>): Uint8Array => {
// flowlint-next-line unclear-type:off
return storage[((params[0]: any): string)];
'state_getStorage': (storage: MockState$Storage, params: Array<mixed>): string => {
return u8aToHex(
// flowlint-next-line unclear-type:off
storage[((params[0]: any): string)]
);
}
};
+1 -1
View File
@@ -21,7 +21,7 @@ export type MockState$Storage = {
};
export type MockState$Requests = {
[string]: (storage: MockState$Storage, params: Array<mixed>) => mixed
[string]: (storage: MockState$Storage, params: Array<mixed>) => string
};
export type MockState = {