diff --git a/docs/examples/promise/07_transfer_dots/package.json b/docs/examples/promise/07_transfer_dots/package.json index c4b3165d29..3bb8370072 100644 --- a/docs/examples/promise/07_transfer_dots/package.json +++ b/docs/examples/promise/07_transfer_dots/package.json @@ -10,7 +10,7 @@ "start": "node index.js" }, "dependencies": { - "@polkadot/api": "^0.31.18" + "@polkadot/api": "^0.31.82" }, "devDependencies": { "rimraf": "2.6.2" diff --git a/packages/api/test/e2e/promise-tx.spec.js b/packages/api/test/e2e/promise-tx.spec.js index 9f3a579599..dac92e7310 100644 --- a/packages/api/test/e2e/promise-tx.spec.js +++ b/packages/api/test/e2e/promise-tx.spec.js @@ -8,27 +8,38 @@ import Api from '../../src/promise'; const keyring = testingPairs(); -describe.skip('e2e transfer', () => { +describe.skip('e2e transactions', () => { let api; let nonce; beforeEach(async () => { api = await Api.create(); - nonce = await api.query.system.accountNonce(keyring.alice.address()); + jest.setTimeout(30000); }); - it('makes a transfer', async () => { - const hash = await api.tx.balances + afterEach(() => { + jest.setTimeout(5000); + }); + + it('makes a transfer', async (done) => { + const nonce = await api.query.system.accountNonce(keyring.alice.address()); + + await api.tx.balances .transfer(keyring.bob.address(), 12345) .sign(keyring.alice, nonce) - .send(); + .send((status) => { + expect( + status.type.toString() + ).toEqual('Finalised'); - expect( - hash.toString() - ).not.toEqual('0x'); + done(); + }); }); it('makes a proposal', async () => { + const nonce = await api.query.system.accountNonce(keyring.alice.address()); + + // don't wait for status, just get hash const hash = await api.tx.democracy .propose(api.tx.consensus.setCode('0xdeadbeef'), 10000) .sign(keyring.alice, nonce) diff --git a/packages/api/test/e2e/rx-transfer.spec.js b/packages/api/test/e2e/rx-transfer.spec.js deleted file mode 100644 index 6e7cebab84..0000000000 --- a/packages/api/test/e2e/rx-transfer.spec.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2017-2018 @polkadot/api authors & contributors -// This software may be modified and distributed under the terms -// of the ISC license. See the LICENSE file for details. - -import { switchMap } from 'rxjs/operators'; -import testingPairs from '@polkadot/keyring/testingPairs'; - -import Api from '../../src/rx'; - -const keyring = testingPairs(); - -describe.skip('e2e transfer', () => { - let api; - - beforeEach(async () => { - api = await Api.create().toPromise(); - }); - - it('makes a transfer', (done) => { - api.query.system - .accountNonce(keyring.alice.address()) - .pipe( - switchMap((nonce) => - api.tx.balances - .transfer(keyring.bob.address(), 12345) - .sign(keyring.alice, nonce) - .send() - ) - ) - .subscribe((hash) => { - expect( - hash.toString() - ).not.toEqual('0x'); - - done(); - }); - }); -}); diff --git a/packages/api/test/e2e/rx-tx.spec.js b/packages/api/test/e2e/rx-tx.spec.js new file mode 100644 index 0000000000..6b6d66d77e --- /dev/null +++ b/packages/api/test/e2e/rx-tx.spec.js @@ -0,0 +1,61 @@ +// Copyright 2017-2018 @polkadot/api authors & contributors +// This software may be modified and distributed under the terms +// of the ISC license. See the LICENSE file for details. + +import { first, switchMap } from 'rxjs/operators'; +import testingPairs from '@polkadot/keyring/testingPairs'; + +import Api from '../../src/rx'; + +const keyring = testingPairs(); + +describe.skip('e2e transactions', () => { + let api; + + beforeEach(async () => { + api = await Api.create().toPromise(); + jest.setTimeout(30000); + }); + + afterEach(() => { + jest.setTimeout(5000); + }); + + it('makes a transfer', (done) => { + api.query.system + .accountNonce(keyring.alice.address()) + .pipe( + first(), + switchMap((nonce) => + api.tx.balances + .transfer(keyring.bob.address(), 12345) + .sign(keyring.alice, nonce) + .send() + ) + ) + .subscribe((status) => { + if (status && status.type.toString() === 'Finalised') { + done(); + } + }); + }); + + it('makes a proposal', (done) => { + api.query.system + .accountNonce(keyring.alice.address()) + .pipe( + first(), + switchMap((nonce) => + api.tx.democracy + .propose(api.tx.consensus.setCode('0xdeadbeef'), 10000) + .sign(keyring.alice, nonce) + .send() + ) + ) + .subscribe((status) => { + if (status && status.type.toString() === 'Finalised') { + done(); + } + }); + }); +});