Files
common/packages/util-rlp/test/getTests.ts
T
Jaco Greeff 80db504a3b Swap to using eslint (#435)
* WIP

* ... and more

* yet more...

* and examples (more-or-less) fixed

* Only problematic promisify left...

* Last batch

* rm config header

* Update

* Use Record

* Bumps
2019-07-14 11:12:46 +02:00

31 lines
830 B
TypeScript

// Copyright 2017-2019 @polkadot/util-rlp authors & contributors
// This software may be modified and distributed under the terms
// of the MPL-2.0 license. See the LICENSE file for details.
import BN from 'bn.js';
import { getSingleFile } from 'ethereumjs-testing';
import bnToU8a from '@polkadot/util/bn/toU8a';
interface Test {
name: string;
input: string | Uint8Array;
output?: string;
root: string;
}
export default function getTests (file: string): Test[] {
const tests = getSingleFile(file);
return Object.keys(tests).map((name): Test => ({
name,
input: tests[name].in[0] !== '#'
? tests[name].in
: bnToU8a(new BN(tests[name].in.slice(1)), { isLe: false }),
output: tests[name].out
? `0x${tests[name].out.toLowerCase()}`
: undefined,
root: tests[name].root
}));
}