-
Notifications
You must be signed in to change notification settings - Fork 116
Feature/proposals test coverage #399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 19 commits
2cd4010
d125bb2
96bdcec
5527844
20ff033
5ac4c2a
3c35b7d
3e0d381
9328be9
8ba80f2
ad1b0be
52e2dd0
239c80c
d2b986d
7138f79
387b981
644ea80
ff42ae6
f0795a4
2d44c1d
0d95545
03a16a2
114145f
b3f42a6
28e10a1
25b8097
d95bde2
2bb49e6
2f11cb8
d4dbc31
1109153
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,13 @@ | ||||||
| #!/bin/bash | ||||||
| cargo run --release -p joystream-node build-spec --chain dev > chainspec.json | ||||||
| sed -i 's/"setValidatorCountProposalGracePeriod":.*/"setValidatorCountProposalGracePeriod": 0,/' chainspec.json | ||||||
| sed -i 's/"runtimeUpgradeProposalGracePeriod":.*/"runtimeUpgradeProposalGracePeriod": 0,/' ./chainspec.json | ||||||
|
||||||
| sed -i 's/"runtimeUpgradeProposalGracePeriod":.*/"runtimeUpgradeProposalGracePeriod": 0,/' ./chainspec.json | |
| sed -i 's/"runtimeUpgradeProposalGracePeriod":.*/"runtimeUpgradeProposalGracePeriod": 0,/' chainspec.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| sed -i 's/"setElectionParametersProposalGracePeriod":.*/"setElectionParametersProposalGracePeriod": 0,/' ./chainspec.json | |
| sed -i 's/"setElectionParametersProposalGracePeriod":.*/"setElectionParametersProposalGracePeriod": 0,/' chainspec.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
gleb-urvanov marked this conversation as resolved.
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,16 +4,16 @@ | |
| "license": "GPL-3.0-only", | ||
| "scripts": { | ||
| "build": "tsc --build tsconfig.json", | ||
| "test": "mocha -r ts-node/register src/tests/constantinople/*", | ||
| "test-migration": "mocha -r ts-node/register src/tests/rome/* && mocha -r ts-node/register src/tests/constantinople/*", | ||
| "test": "tap --files ts-node/register src/constantinople/tests/proposals/*Test.ts", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't seem to have a way to control the order of tests, as far as I can see they are run in alphabetic order of the file names (not different than mocha). Given that the test scenarios should be independent, (currently they are all executed one after the other with the same chain so they aren't exactly isolated) the order is not important, but it would still be valuable to control. The plan of course is to have a better way to setup a network before running the test scenarios, so this is probably the task of the orchestrator/task runner/ |
||
| "test-migration": "tap --files src/rome/tests/romeRuntimeUpgradeTest.ts --files src/constantinople/tests/electingCouncilTest.ts", | ||
| "lint": "tslint --project tsconfig.json", | ||
| "prettier": "prettier --write ./src" | ||
| }, | ||
| "dependencies": { | ||
| "@joystream/types": "", | ||
| "@rome/types@npm:@joystream/types": "^0.7.0", | ||
| "@constantinople/types@npm:@joystream/types": "^0.9.1", | ||
| "@polkadot/api": "^0.96.1", | ||
| "@polkadot/keyring": "^1.7.0-beta.5", | ||
| "@rome/types@npm:@joystream/types": "^0.7.0", | ||
| "@types/bn.js": "^4.11.5", | ||
| "bn.js": "^4.11.8", | ||
| "dotenv": "^8.2.0", | ||
|
|
@@ -23,11 +23,11 @@ | |
| "devDependencies": { | ||
| "@polkadot/ts": "^0.3.14", | ||
| "@types/chai": "^4.2.11", | ||
| "@types/mocha": "^7.0.2", | ||
| "@types/tap": "^14.10.0", | ||
| "@types/uuid": "^7.0.2", | ||
| "chai": "^4.2.0", | ||
| "mocha": "^7.1.1", | ||
| "prettier": "2.0.2", | ||
| "tap": "^14.10.7", | ||
| "ts-node": "^8.8.1", | ||
| "tslint": "^6.1.0", | ||
| "typescript": "^3.8.3" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { KeyringPair } from '@polkadot/keyring/types'; | ||
| import { membershipTest } from './impl/membershipCreation'; | ||
| import { councilTest } from './impl/electingCouncil'; | ||
|
|
||
| const m1KeyPairs: KeyringPair[] = new Array(); | ||
| const m2KeyPairs: KeyringPair[] = new Array(); | ||
|
|
||
| membershipTest(m1KeyPairs); | ||
| membershipTest(m2KeyPairs); | ||
| councilTest(m1KeyPairs, m2KeyPairs); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,13 @@ | ||
| import { membershipTest } from './membershipCreationTest'; | ||
| import { KeyringPair } from '@polkadot/keyring/types'; | ||
| import { ApiWrapper } from './utils/apiWrapper'; | ||
| import { ApiWrapper } from '../../utils/apiWrapper'; | ||
| import { WsProvider, Keyring } from '@polkadot/api'; | ||
| import { initConfig } from './utils/config'; | ||
| import BN = require('bn.js'); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm surprised this syntax ever worked in the first place! :) |
||
| import { registerJoystreamTypes, Seat } from '@joystream/types'; | ||
| import { initConfig } from '../../utils/config'; | ||
| import BN from 'bn.js'; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've often had typescript linter complain that |
||
| import { registerJoystreamTypes, Seat } from '@constantinople/types'; | ||
| import { assert } from 'chai'; | ||
| import { v4 as uuid } from 'uuid'; | ||
| import { Utils } from './utils/utils'; | ||
| import { Utils } from '../../utils/utils'; | ||
| import tap from 'tap'; | ||
|
|
||
| export function councilTest(m1KeyPairs: KeyringPair[], m2KeyPairs: KeyringPair[]) { | ||
| initConfig(); | ||
|
|
@@ -17,18 +17,19 @@ export function councilTest(m1KeyPairs: KeyringPair[], m2KeyPairs: KeyringPair[] | |
| const K: number = +process.env.COUNCIL_ELECTION_K!; | ||
| const greaterStake: BN = new BN(+process.env.COUNCIL_STAKE_GREATER_AMOUNT!); | ||
| const lesserStake: BN = new BN(+process.env.COUNCIL_STAKE_LESSER_AMOUNT!); | ||
| const defaultTimeout: number = 120000; | ||
| const defaultTimeout: number = 300000; | ||
|
||
| let sudo: KeyringPair; | ||
| let apiWrapper: ApiWrapper; | ||
|
|
||
| before(async function () { | ||
| this.timeout(defaultTimeout); | ||
| tap.setTimeout(defaultTimeout); | ||
|
|
||
| tap.test('Electing council test setup', async () => { | ||
| registerJoystreamTypes(); | ||
| const provider = new WsProvider(nodeUrl); | ||
| apiWrapper = await ApiWrapper.create(provider); | ||
| }); | ||
|
|
||
| it('Electing a council test', async () => { | ||
| tap.test('Electing a council test', async () => { | ||
| // Setup goes here because M keypairs are generated after before() function | ||
| sudo = keyring.addFromUri(sudoUri); | ||
| let now = await apiWrapper.getBestBlock(); | ||
|
|
@@ -111,17 +112,9 @@ export function councilTest(m1KeyPairs: KeyringPair[], m2KeyPairs: KeyringPair[] | |
| `Member ${seat.member} has unexpected stake ${Utils.getTotalStake(seat)}` | ||
| ) | ||
| ); | ||
| }).timeout(defaultTimeout); | ||
| }); | ||
|
|
||
| after(() => { | ||
| tap.teardown(() => { | ||
| apiWrapper.close(); | ||
| }); | ||
| } | ||
|
|
||
| describe('Council integration tests', () => { | ||
| const m1KeyPairs: KeyringPair[] = new Array(); | ||
| const m2KeyPairs: KeyringPair[] = new Array(); | ||
| membershipTest(m1KeyPairs); | ||
| membershipTest(m2KeyPairs); | ||
| councilTest(m1KeyPairs, m2KeyPairs); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,13 @@ | ||
| import { WsProvider } from '@polkadot/api'; | ||
| import { registerJoystreamTypes } from '@joystream/types'; | ||
| import { registerJoystreamTypes } from '@constantinople/types'; | ||
| import { Keyring } from '@polkadot/keyring'; | ||
| import { assert } from 'chai'; | ||
| import { KeyringPair } from '@polkadot/keyring/types'; | ||
| import BN = require('bn.js'); | ||
| import { ApiWrapper } from './utils/apiWrapper'; | ||
| import { initConfig } from './utils/config'; | ||
| import BN from 'bn.js'; | ||
| import { ApiWrapper } from '../../utils/apiWrapper'; | ||
| import { initConfig } from '../../utils/config'; | ||
| import { v4 as uuid } from 'uuid'; | ||
| import tap from 'tap'; | ||
|
|
||
| export function membershipTest(nKeyPairs: KeyringPair[]) { | ||
| initConfig(); | ||
|
|
@@ -15,15 +16,16 @@ export function membershipTest(nKeyPairs: KeyringPair[]) { | |
| const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!; | ||
|
||
| const nodeUrl: string = process.env.NODE_URL!; | ||
| const sudoUri: string = process.env.SUDO_ACCOUNT_URI!; | ||
| const defaultTimeout: number = 30000; | ||
| const defaultTimeout: number = 75000; | ||
| let apiWrapper: ApiWrapper; | ||
| let sudo: KeyringPair; | ||
| let aKeyPair: KeyringPair; | ||
| let membershipFee: BN; | ||
| let membershipTransactionFee: BN; | ||
|
|
||
| before(async function () { | ||
| this.timeout(defaultTimeout); | ||
| tap.setTimeout(defaultTimeout); | ||
|
|
||
| tap.test('Membership creation test setup', async () => { | ||
| registerJoystreamTypes(); | ||
| const provider = new WsProvider(nodeUrl); | ||
| apiWrapper = await ApiWrapper.create(provider); | ||
|
|
@@ -42,7 +44,7 @@ export function membershipTest(nKeyPairs: KeyringPair[]) { | |
| await apiWrapper.transferBalance(sudo, aKeyPair.address, membershipTransactionFee); | ||
| }); | ||
|
|
||
| it('Buy membeship is accepted with sufficient funds', async () => { | ||
| tap.test('Buy membeship is accepted with sufficient funds', async () => { | ||
| await Promise.all( | ||
| nKeyPairs.map(async (keyPair, index) => { | ||
| await apiWrapper.buyMembership(keyPair, paidTerms, `new_member_${index}${keyPair.address.substring(0, 8)}`); | ||
|
|
@@ -53,9 +55,9 @@ export function membershipTest(nKeyPairs: KeyringPair[]) { | |
| .getMemberIds(keyPair.address) | ||
| .then(membership => assert(membership.length > 0, `Account ${keyPair.address} is not a member`)) | ||
| ); | ||
| }).timeout(defaultTimeout); | ||
| }); | ||
|
|
||
| it('Account A can not buy the membership with insufficient funds', async () => { | ||
| tap.test('Account A can not buy the membership with insufficient funds', async () => { | ||
| await apiWrapper | ||
| .getBalance(aKeyPair.address) | ||
| .then(balance => | ||
|
|
@@ -68,9 +70,9 @@ export function membershipTest(nKeyPairs: KeyringPair[]) { | |
| apiWrapper | ||
| .getMemberIds(aKeyPair.address) | ||
| .then(membership => assert(membership.length === 0, 'Account A is a member')); | ||
| }).timeout(defaultTimeout); | ||
| }); | ||
|
|
||
| it('Account A was able to buy the membership with sufficient funds', async () => { | ||
| tap.test('Account A was able to buy the membership with sufficient funds', async () => { | ||
| await apiWrapper.transferBalance(sudo, aKeyPair.address, membershipFee.add(membershipTransactionFee)); | ||
| apiWrapper | ||
| .getBalance(aKeyPair.address) | ||
|
|
@@ -81,14 +83,9 @@ export function membershipTest(nKeyPairs: KeyringPair[]) { | |
| apiWrapper | ||
| .getMemberIds(aKeyPair.address) | ||
| .then(membership => assert(membership.length > 0, 'Account A is a not member')); | ||
| }).timeout(defaultTimeout); | ||
| }); | ||
|
|
||
| after(() => { | ||
| tap.teardown(() => { | ||
| apiWrapper.close(); | ||
| }); | ||
| } | ||
|
|
||
| describe.skip('Membership integration tests', () => { | ||
| const nKeyPairs: KeyringPair[] = new Array(); | ||
| membershipTest(nKeyPairs); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| import { KeyringPair } from '@polkadot/keyring/types'; | ||
| import { membershipTest } from './impl/membershipCreation'; | ||
|
|
||
| const nKeyPairs: KeyringPair[] = new Array(); | ||
|
|
||
| membershipTest(nKeyPairs); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { KeyringPair } from '@polkadot/keyring/types'; | ||
| import { membershipTest } from '../impl/membershipCreation'; | ||
| import { councilTest } from '../impl/electingCouncil'; | ||
| import { electionParametersProposalTest } from './impl/electionParametersProposal'; | ||
|
|
||
| const m1Keys: KeyringPair[] = new Array(); | ||
| const m2Keys: KeyringPair[] = new Array(); | ||
|
|
||
| membershipTest(m1Keys); | ||
| membershipTest(m2Keys); | ||
| councilTest(m1Keys, m2Keys); | ||
| electionParametersProposalTest(m1Keys, m2Keys); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import { KeyringPair } from '@polkadot/keyring/types'; | ||
| import { membershipTest } from '../impl/membershipCreation'; | ||
| import { councilTest } from '../impl/electingCouncil'; | ||
| import { evictStorageProviderTest } from './impl/evictStoraveProvider'; | ||
|
|
||
| const m1Keys: KeyringPair[] = new Array(); | ||
| const m2Keys: KeyringPair[] = new Array(); | ||
|
|
||
| membershipTest(m1Keys); | ||
| membershipTest(m2Keys); | ||
| councilTest(m1Keys, m2Keys); | ||
| evictStorageProviderTest(m1Keys, m2Keys); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although this approach is temporary and eventually we will have parameterized build of the runtime, and producing this chainspec file as an artifact of running tests will not be necessary, it should be generated in some temporary location folder, maybe the system temporary path?
This goes for any other temporary artifacts of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done,
.tmpfolder introduced