Expand/align promise/rx tx e2e tests (#356)
* Expand/align promise/rx tx examples * Remove autocomplete being over the top :) * Update docs/examples/promises/07 deps
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -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();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user