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');
});
});
});