-
Notifications
You must be signed in to change notification settings - Fork 115
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
Feature/proposals test coverage #399
Conversation
tests/network-tests/package.json
Outdated
| }, | ||
| "dependencies": { | ||
| "@joystream/types": "^0.7.0", | ||
| "@joystream/types": "../joystream-apps/packages/joy-types", |
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.
| "@joystream/types": "../joystream-apps/packages/joy-types", | |
| "@joystream/types": "^0.9.1", |
Final constantinople release
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.
We might as well also use alias @constantinople/types ?
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
Cancellation fee: fetch from rutime
mnaamani
left a comment
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.
So overall I think the setup seems better with tap, but I left a bunch of suggestions and questions too.
I was able to run the test but I had to manually edit the chainspec.json file because the run-test-chain.sh script didn't work.
FAIL src/constantinople/tests/proposals/updateRuntimeTest.ts
✖ timeout!
test: " Upgrading the runtime test"
expired: TAP
FAIL src/constantinople/tests/proposals/updateRuntimeTest.ts 1 failed of 12 15m
✖ timeout!
I couldn't really figure out why it failed.
The test in total took quite a while to run, surely with control of the elections and setting grace periods to 0 this should have been much shorter?
Suites: 1 failed, 8 passed, 9 of 9 completed
Asserts: 1 failed, 107 passed, of 108
Time: 38m
I think the helper methods for awaiting for Event to be emitted by transactions could be improved maybe to wait for a specific amount of time/blocks before throwing so maybe the test can pickup on failure of what event expectation caused the failure.
scripts/run-test-chain.sh
Outdated
| #!/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 |
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/"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
scripts/run-test-chain.sh
Outdated
| 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/"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.
| 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
scripts/run-test-chain.sh
Outdated
| @@ -0,0 +1,13 @@ | |||
| #!/bin/bash | |||
| cargo run --release -p joystream-node build-spec --chain dev > 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.
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, .tmp folder introduced
| import { ApiWrapper } from '../../utils/apiWrapper'; | ||
| import { WsProvider, Keyring } from '@polkadot/api'; | ||
| import { initConfig } from './utils/config'; | ||
| import BN = require('bn.js'); |
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.
I'm surprised this syntax ever worked in the first place! :)
| 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; |
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.
I don't understand why the timeout had to be increased here, and in some other tests also.
Wouldn't it be better if the timeout value for each scenario was derived based on how many finalized blocks the tests should be completed within, and the chain's block interval?
Its also not clear, is this timeout for the entire suite or per .test()? If it is per test then the timeout should be specific to each test, not the max value to accommodate all the tests.
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.
The timeout time now is defined using number of blocks required for the test to pass.
| initConfig(); | ||
| const keyring = new Keyring({ type: 'sr25519' }); | ||
| const N: number = +process.env.MEMBERSHIP_CREATION_N!; | ||
| const paidTerms: number = +process.env.MEMBERSHIP_PAID_TERMS!; |
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.
For all the functions inside the impl folder which are now the reusable unit, it might be better to have these scenario parameters be passed as arguments and the caller would read them from process.env
registerJoystreamTypes() is also called in each test setup, and I think the caller of the test only needs to do that one time, and might as well also create the api instance and pass that as argument as well.
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.
Scenario parameters now read from environment in scenarios and are passed to the implementation as parameters.
Type registration and api instance are still test-specific. I've run into issues while trying move them up to the scenario level. Let me know if we should discuss it.
| const minVotingStake: BN = await apiWrapper.getMinVotingStake(); | ||
|
|
||
| // Proposal stake calculation | ||
| const proposalStake: BN = new BN(200000); |
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.
There are some runtime configured minimum values for stake, we should probably read the value instead of picking a magic number?
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.
There are no way to read the required stake values from API. The definition of the values is here: https://github.com/Joystream/joystream/blob/development/runtime-modules/proposals/codex/src/proposal_types/parameters.rs
| const newMinCouncilStake: BN = await apiWrapper.getMinCouncilStake(); | ||
| const newMinVotingStake: BN = await apiWrapper.getMinVotingStake(); | ||
| assert( | ||
| announcingPeriod.subn(1).eq(newAnnouncingPeriod), |
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.
A better approach here that will also avoid some mistakes and doing the correct assertions:
const proposedAnnouncingPeriod = announcingPeriod.subn(1);
then propose that value, so assertion becomes
assert(newAnnouncingPeriod.eq(proposedAnnouncingPeriod))
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
| assert(await apiWrapper.isStorageProvider(sudo.address), `Account ${sudo.address} is not storage provider`); | ||
|
|
||
| // Proposal stake calculation | ||
| const proposalStake: BN = new BN(25000); |
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.
Again it would be better to use the required stake from runtime.
I realize now, the reason it failed is because the |
As discussed, chainspec is created from dev, so `purge-chain --dev` do the same. Co-authored-by: Mokhtar Naamani <[email protected]>
Depends on:
#284
#322
#386
Require Constantinople joystream types (https://github.com/Joystream/apps/tree/joystream-constantinople)