testingPairs for inetrnal testing (#118)

This commit is contained in:
Jaco Greeff
2018-04-19 12:24:43 +02:00
committed by GitHub
parent 37bea69e58
commit 24dffb710e
17 changed files with 75 additions and 51 deletions
+9 -17
View File
@@ -3,11 +3,7 @@
// of the ISC license. See the LICENSE file for details.
// @flow
import type { KeyringPair } from './types';
type TestKeyring = {
[string]: KeyringPair
};
import type { KeyringInstance } from './types';
const hexToU8a = require('@polkadot/util/hex/toU8a');
const u8aFromString = require('@polkadot/util/u8a/fromString');
@@ -15,11 +11,7 @@ const u8aFromString = require('@polkadot/util/u8a/fromString');
const createKeyring = require('./index');
function padSeed (seed: string): Uint8Array {
while (seed.length < 32) {
seed += ' ';
}
return u8aFromString(seed);
return u8aFromString(seed.padEnd(32, ' '));
}
const SEEDS = {
@@ -41,14 +33,14 @@ const SEEDS = {
hexToU8a('0x9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60')
};
module.exports = function testKeyring (): TestKeyring {
module.exports = function testKeyring (): KeyringInstance {
const keyring = createKeyring();
return Object
.keys(SEEDS)
.reduce((result, key) => {
result[key] = keyring.addFromSeed(SEEDS[key]);
Object.keys(SEEDS).forEach((name) => {
keyring
.addFromSeed(SEEDS[name])
.setMeta({ name });
});
return result;
}, {});
return keyring;
};