Update to latest Metadata, e2e tests cleanups (sr25519) (#783)

* Update to latest Metadata

* Test expansion

* Update tests

* Bump deps

* Package versions
This commit is contained in:
Jaco Greeff
2019-03-18 15:56:07 +01:00
committed by GitHub
parent 87791eab8f
commit 712c15a329
12 changed files with 120 additions and 87 deletions
+1 -1
View File
@@ -36,6 +36,6 @@
"@polkadot/rpc-rx": "^0.48.0-beta.2",
"@polkadot/storage": "^0.48.0-beta.2",
"@polkadot/types": "^0.48.0-beta.2",
"@polkadot/util-crypto": "^0.38.0-beta.4"
"@polkadot/util-crypto": "^0.38.0-beta.5"
}
}
+3 -5
View File
@@ -2,10 +2,9 @@
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import Keyring from '@polkadot/keyring';
import testingPairs from '@polkadot/keyring/testingPairs';
import createPair from '@polkadot/keyring/pair';
import { randomAsHex } from '@polkadot/util-crypto';
import { stringToU8a } from '@polkadot/util';
import Api from '../../src/promise';
import WsProvider from '../../../rpc-provider/src/ws';
@@ -159,9 +158,8 @@ describe.skip('e2e transactions', () => {
expect(hash.toHex()).toHaveLength(66);
});
// skipped (needs sr25519 enabled on chain)
it.skip('makes a transfer, swaps types and then another one', async (done) => {
const pair = createPair('sr25519', { seed: stringToU8a('testing123'.padEnd(32)) });
it('makes a transfer, and uses new balance to transfers to new', async (done) => {
const pair = new Keyring().addFromUri('testing123', {}, 'ed25519');
function doOne (cb) {
return api.tx.balances
+1 -1
View File
@@ -33,6 +33,6 @@
"@polkadot/jsonrpc": "^0.48.0-beta.2",
"@polkadot/rpc-provider": "^0.48.0-beta.2",
"@polkadot/types": "^0.48.0-beta.2",
"@polkadot/util": "^0.38.0-beta.4"
"@polkadot/util": "^0.38.0-beta.5"
}
}
+3 -3
View File
@@ -30,10 +30,10 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
"dependencies": {
"@babel/runtime": "^7.3.4",
"@polkadot/keyring": "^0.38.0-beta.4",
"@polkadot/keyring": "^0.38.0-beta.5",
"@polkadot/storage": "^0.48.0-beta.2",
"@polkadot/util": "^0.38.0-beta.4",
"@polkadot/util-crypto": "^0.38.0-beta.4",
"@polkadot/util": "^0.38.0-beta.5",
"@polkadot/util-crypto": "^0.38.0-beta.5",
"@types/nock": "^9.3.1",
"eventemitter3": "^3.1.0",
"isomorphic-fetch": "^2.2.1",
+1 -1
View File
@@ -12,6 +12,6 @@
"dependencies": {
"@babel/runtime": "^7.3.4",
"@polkadot/types": "^0.48.0-beta.2",
"@polkadot/util": "^0.38.0-beta.4"
"@polkadot/util": "^0.38.0-beta.5"
}
}
+3 -3
View File
@@ -30,9 +30,9 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-storage#readme",
"dependencies": {
"@babel/runtime": "^7.3.4",
"@polkadot/keyring": "^0.38.0-beta.4",
"@polkadot/keyring": "^0.38.0-beta.5",
"@polkadot/types": "^0.48.0-beta.2",
"@polkadot/util": "^0.38.0-beta.4",
"@polkadot/util-crypto": "^0.38.0-beta.4"
"@polkadot/util": "^0.38.0-beta.5",
"@polkadot/util-crypto": "^0.38.0-beta.5"
}
}
+2 -2
View File
@@ -30,8 +30,8 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
"dependencies": {
"@babel/runtime": "^7.3.4",
"@polkadot/keyring": "^0.38.0-beta.4",
"@polkadot/util": "^0.38.0-beta.4",
"@polkadot/keyring": "^0.38.0-beta.5",
"@polkadot/util": "^0.38.0-beta.5",
"core-js": "^2.6.5"
}
}
@@ -193,12 +193,12 @@
"docs": [
" Set the current time.",
"",
" Extrinsic with this call should be placed at the specific position in the each block",
" (specified by the Trait::TIMESTAMP_SET_POSITION) typically at the start of the each block.",
" This call should be invoked exactly once per block. It will panic at the finalization phase,",
" if this call hasn't been invoked by that time.",
"",
" The timestamp should be greater than the previous one by the amount specified by `block_period`."
" The timestamp should be greater than the previous one by the amount specified by `block_period`.",
" ",
" The dispatch origin for this call must be `Inherent`."
]
}
],
@@ -844,7 +844,7 @@
"fallback": "0x0c00",
"docs": [
" The set of keys are all controllers that want to validate.",
" ",
"",
" The values are the preferences that a validator has."
]
},
@@ -860,7 +860,7 @@
"fallback": "0x00",
"docs": [
" The set of keys are all controllers that want to nominate.",
" ",
"",
" The value are the nominations."
]
},
@@ -1029,9 +1029,9 @@
"docs": [
" Add some extra amount that have appeared in the stash `free_balance` into the balance up for",
" staking.",
" ",
"",
" Use this if there are additional funds in your stash account that you wish to bond.",
" ",
"",
" NOTE: This call must be made by the controller, not the stash."
]
},
@@ -1045,15 +1045,15 @@
],
"docs": [
" Schedule a portion of the stash to be unlocked ready for transfer out after the bond",
" period ends. If this leaves an amount actively bonded less than ",
" period ends. If this leaves an amount actively bonded less than",
" T::Currency::existential_deposit(), then it is increased to the full amount.",
" ",
"",
" Once the unlock period is done, you can call `withdraw_unbonded` to actually move",
" the funds out of management ready for transfer. ",
" ",
" the funds out of management ready for transfer.",
"",
" NOTE: This call must be made by the controller, not the stash.",
" ",
" See also `withdraw_unbonded`."
"",
" See also [`Call::withdraw_unbonded`]."
]
},
{
@@ -1061,13 +1061,13 @@
"args": [],
"docs": [
" Remove any unlocked chunks from the `unlocking` queue from our management.",
" ",
"",
" This essentially frees up that balance to be used by the stash account to do",
" whatever it wants.",
" ",
"",
" NOTE: This call must be made by the controller, not the stash.",
" ",
" See also `unbond`."
"",
" See also [`Call::unbond`]."
]
},
{
@@ -1082,7 +1082,7 @@
" Declare the desire to validate for the origin controller.",
"",
" Effects will be felt at the beginning of the next era.",
" ",
"",
" NOTE: This call must be made by the controller, not the stash."
]
},
@@ -1098,7 +1098,7 @@
" Declare the desire to nominate `targets` for the origin controller.",
"",
" Effects will be felt at the beginning of the next era.",
" ",
"",
" NOTE: This call must be made by the controller, not the stash."
]
},
@@ -1109,7 +1109,7 @@
" Declare no desire to either validate or nominate.",
"",
" Effects will be felt at the beginning of the next era.",
" ",
"",
" NOTE: This call must be made by the controller, not the stash."
]
},
@@ -1125,7 +1125,7 @@
" (Re-)set the payment target for a controller.",
"",
" Effects will be felt at the beginning of the next era.",
" ",
"",
" NOTE: This call must be made by the controller, not the stash."
]
},
File diff suppressed because one or more lines are too long
@@ -0,0 +1,16 @@
{
"jsonrpc": "2.0",
"method": "state_storage",
"params": {
"result": {
"block": "0xa7f1ac9f18dded8e5825205d3e5260cf53ba01f629d9ebc1b80601b45ed8c358",
"changes": [
[
"0xcc956bdb7605e3547539f321ac2bc95c",
"0x140000000000000000010000000203306721211d5404bd9da88e0204360a1a9ab8b87c66c1bc2fcdd37f3c2222cc204a83f1c09be797bc3d9adce29818368b276a84e6b545ced492c25c948978d7f83930000000000000000000000000000000000000000000000000000000000000000100000000000103006400000000000000010d000100000001000000000000000000000000000000"
]
]
},
"subscription": 19
}
}
+47 -28
View File
@@ -6,43 +6,62 @@ import createType from '../codec/createType';
import Vector from '../codec/Vector';
import json1 from '../json/EventRecord.001.json';
import json2 from '../json/EventRecord.002.json';
import json3 from '../json/EventRecord.003.json';
import AccountId from './AccountId';
import Event from './Event';
import EventRecord from './EventRecord';
import Metadata from '../Metadata';
import metadataRpc from '../Metadata/v0/static';
import metadataV0 from '../Metadata/v0/static';
import metadataV1 from '../Metadata/static';
describe('EventRecord', () => {
beforeEach(() => {
Event.injectMetadata(
new Metadata(metadataRpc).asV0
);
describe('v0', () => {
beforeEach(() => {
Event.injectMetadata(
new Metadata(metadataV0).asV0
);
});
it('decodes correctly', () => {
const records: Vector<EventRecord> = createType('Vec<EventRecord>', json1.params.result.changes[0][1]) as any;
const er = records[0];
expect(er.phase.type).toEqual('ApplyExtrinsic');
});
// FIXME skipping this one, need an actual updated sample for the actual new types
it.skip('decodes more complex events', () => {
const records: Vector<EventRecord> = createType('Vec<EventRecord>', json2.params.result.changes[0][1]) as any;
expect(records).toHaveLength(4);
const er = records[2];
expect(
er.event.data.toArray().map((v) => v.toString())
).toEqual(
[
new AccountId('0xd2de7394ae047a5502ad9adb9cc69ff6fe484033bfce874d775da947487cd832').toString(),
new AccountId('0x37e027d776cd005c12bcf6722421374a9037167a0ceaf918f341c4ad68d54e59').toString(),
'1000',
'0'
]
);
});
});
it('decodes correctly', () => {
const records: Vector<EventRecord> = createType('Vec<EventRecord>', json1.params.result.changes[0][1]) as any;
const er = records[0];
describe.skip('v1', () => {
beforeEach(() => {
Event.injectMetadata(
new Metadata(metadataV1).asV0
);
});
expect(er.phase.type).toEqual('ApplyExtrinsic');
});
it('decodes correctly', () => {
const records: Vector<EventRecord> = createType('Vec<EventRecord>', json3.params.result.changes[0][1]) as any;
const er = records[0];
// FIXME skipping this one, need an actual updated sample for the actual new types
it.skip('decodes more complex events', () => {
const records: Vector<EventRecord> = createType('Vec<EventRecord>', json2.params.result.changes[0][1]) as any;
expect(records).toHaveLength(4);
const er = records[2];
expect(
er.event.data.toArray().map((v) => v.toString())
).toEqual(
[
new AccountId('0xd2de7394ae047a5502ad9adb9cc69ff6fe484033bfce874d775da947487cd832').toString(),
new AccountId('0x37e027d776cd005c12bcf6722421374a9037167a0ceaf918f341c4ad68d54e59').toString(),
'1000',
'0'
]
);
expect(er.phase.type).toEqual('ApplyExtrinsic');
});
});
});
+21 -21
View File
@@ -1429,35 +1429,30 @@
typescript "^3.3.3333"
vuepress "^1.0.0-alpha.40"
"@polkadot/keyring@^0.38.0-beta.4":
version "0.38.0-beta.4"
resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-0.38.0-beta.4.tgz#18e89f234fb60764c973f9f992b225105f03aaf4"
integrity sha512-xm5tRsXISF6jWCbL/8pq8yqAsvVp3yFnYlyAd/u+Oj/XEQR5Vij26y7eQUXyX6pFYRtFda/RSaNLWkKDHoUJbQ==
"@polkadot/keyring@^0.38.0-beta.5":
version "0.38.0-beta.5"
resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-0.38.0-beta.5.tgz#e2b5def21f3d792452164d1123357d0395d37a4c"
integrity sha512-FQ1cNo1rRRKssxwLTFpsM9qqMnKFCmJCJzs9F1lKxgRYaI5189bDP5jYFATjYSvj5ctjRqGb2dClz2/zpaTNsA==
dependencies:
"@babel/runtime" "^7.3.4"
"@polkadot/util" "^0.38.0-beta.4"
"@polkadot/util-crypto" "^0.38.0-beta.4"
"@polkadot/util" "^0.38.0-beta.5"
"@polkadot/util-crypto" "^0.38.0-beta.5"
"@types/bs58" "^4.0.0"
bs58 "^4.0.1"
"@polkadot/schnorrkel-js@^0.2.0-12":
version "0.2.0-12"
resolved "https://registry.yarnpkg.com/@polkadot/schnorrkel-js/-/schnorrkel-js-0.2.0-12.tgz#fd70f3b79d2c7a97874c26ae41bf331ef8763b77"
integrity sha512-S/tbdME58VDzP5nXE4kWseZnrWGkaMFFmEdW43KlwGlWvxNMREpgncUdDfTFip6lDahcKNSU98n+QJJlkaSB+A==
"@polkadot/ts@^0.1.56":
version "0.1.56"
resolved "https://registry.yarnpkg.com/@polkadot/ts/-/ts-0.1.56.tgz#ffd6e9c95704a7fb90b918193b9dc5c440114b27"
integrity sha512-wnt4zXxZXyz6WaubTO/I+nUElwV2DogFzdl6CrKfVn2PTWp8uHN06W9s40FH57ORtmQfDr9rLRP8Nq+oIyElbg==
"@polkadot/util-crypto@^0.38.0-beta.4":
version "0.38.0-beta.4"
resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-0.38.0-beta.4.tgz#a26bc2409baef56d5d8213a08bf91a92322ecbc8"
integrity sha512-fTxrv7CipaMrmjFi4Dy+r3BqhC8WIOfRAUCRXCkaHBDd2cRyrDrHRrONVAbUhv36B/ZNogaVRd3Aq2uF1TSpzw==
"@polkadot/util-crypto@^0.38.0-beta.5":
version "0.38.0-beta.5"
resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-0.38.0-beta.5.tgz#cda6bbab234db17c38f51862c679d9f4e7efc18a"
integrity sha512-/bl3lRk8pBtwAz/mMlhVfYcWjB5wnX0VaXnl3UwG0Czb4H+pSBf8PzbLc5X6mzpxbEZ6UuB4Tz9McUPFF/BxaA==
dependencies:
"@babel/runtime" "^7.3.4"
"@polkadot/schnorrkel-js" "^0.2.0-12"
"@polkadot/util" "^0.38.0-beta.4"
"@polkadot/util" "^0.38.0-beta.5"
"@polkadot/wasm-schnorrkel" "^0.1.1"
"@types/bip39" "^2.4.2"
"@types/pbkdf2" "^3.0.0"
"@types/secp256k1" "^3.5.0"
@@ -1470,10 +1465,10 @@
tweetnacl "^1.0.1"
xxhashjs "^0.2.2"
"@polkadot/util@^0.38.0-beta.4":
version "0.38.0-beta.4"
resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.38.0-beta.4.tgz#ae791b53feed18240f1335db47de1ef05ba4be15"
integrity sha512-Aq1Ul1JEQDdZSUhQPztbWrZHqFGkWMMK3bg47xtoxrWdtqYhS52a89i+LANSNqli65Z2KhVSTsBakj/tCMBxNQ==
"@polkadot/util@^0.38.0-beta.5":
version "0.38.0-beta.5"
resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.38.0-beta.5.tgz#550698b15b96c729efee8c75df25ff6b8cf52435"
integrity sha512-Xpxc6ntFM4IXlXgkP4nXKzqbKApWk3NIrHmdcIgbFLC6FMrmqxZMfIxEAFZkAR9Lfi+WuRN0cRs0/egii5TpbQ==
dependencies:
"@babel/runtime" "^7.3.4"
"@types/bn.js" "^4.11.4"
@@ -1487,6 +1482,11 @@
ip-regex "^4.0.0"
moment "^2.24.0"
"@polkadot/wasm-schnorrkel@^0.1.1":
version "0.1.1"
resolved "https://registry.yarnpkg.com/@polkadot/wasm-schnorrkel/-/wasm-schnorrkel-0.1.1.tgz#3864d0e1393dcea571c80f2ea795d5f667fe90f8"
integrity sha512-5BnRq6kHS1d8PH9NSDql+x1boVY/51lrsC9EvbMFSRpSc67p3h+LjG0/BiJVgMOD7P/HZYy2oACJU0Khrwq2gA==
"@types/base-x@*":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@types/base-x/-/base-x-3.0.0.tgz#a1365259d1d3fa3ff973ab543192a6bdd4cb2f90"