diff --git a/test/typings.test.js b/test/typings.test.js index df64c5df..e09cff2a 100644 --- a/test/typings.test.js +++ b/test/typings.test.js @@ -3,6 +3,7 @@ * run via 'npm run test:typings' */ const assert = require('assert'); +assert.ok(true); const path = require('path'); const AsyncTestUtil = require('async-test-util'); @@ -44,13 +45,9 @@ describe('typings.test.ts', () => { let x: string = 'foo'; x = 1337; `; - let thrown = false; - try { - await transpileCode(brokenCode); - } catch (err) { - thrown = true; - } - assert.ok(thrown); + await AsyncTestUtil.assertThrows( + () => transpileCode(brokenCode) + ); }); }); describe('statics', () => { @@ -102,5 +99,42 @@ describe('typings.test.ts', () => { await transpileCode(code); }); }); + describe('rawTx', () => { + /** + * @link https://github.com/pubkey/eth-crypto/issues/20 + */ + it('#20 should need a nonce for a RawTx', async () => { + const code = ` + (async()=>{ + const rawTx: EthCryptoAll.RawTx = { + from: '0xfoobar', + to: '0xfoobar', + value: 10, + gasLimit: 10, + gasPrice: 10, + nonce: 20 + }; + })(); + `; + await transpileCode(code); + + const badCodeWithoutNonce = ` + (async()=>{ + const rawTx: EthCryptoAll.RawTx = { + from: '0xfoobar', + to: '0xfoobar', + value: 10, + gasLimit: 10, + gasPrice: 10 + }; + })(); + `; + await AsyncTestUtil.assertThrows( + () => transpileCode(badCodeWithoutNonce), + Error, + 'nonce' + ); + }); + }); }); }); diff --git a/typings/index.d.ts b/typings/index.d.ts index 66b73ac1..ece2e502 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -31,12 +31,13 @@ export type Encrypted = { }; export type RawTx = { - from: string, - to: string, - value: number | string | BigNumber, - gasLimit: number, - gasPrice: number, - code?: string + from: string; + to: string; + value: number | string | BigNumber; + gasLimit: number; + gasPrice: number; + nonce: number; + code?: string; }; type signType = (privateKey: string, message: string) => string;