Skip to content

Conversation

@gleb-urvanov
Copy link
Contributor

@gleb-urvanov gleb-urvanov commented May 7, 2020

@gleb-urvanov gleb-urvanov requested a review from mnaamani May 7, 2020 13:59
},
"dependencies": {
"@joystream/types": "^0.7.0",
"@joystream/types": "../joystream-apps/packages/joy-types",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"@joystream/types": "../joystream-apps/packages/joy-types",
"@joystream/types": "^0.9.1",

Final constantinople release

Copy link
Member

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 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@gleb-urvanov gleb-urvanov marked this pull request as draft May 19, 2020 15:19
@gleb-urvanov gleb-urvanov marked this pull request as ready for review May 20, 2020 09:48
Lezek123 pushed a commit to Lezek123/substrate-runtime-joystream that referenced this pull request May 21, 2020
Copy link
Member

@mnaamani mnaamani left a 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.

#!/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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sed -i 's/"runtimeUpgradeProposalGracePeriod":.*/"runtimeUpgradeProposalGracePeriod": 0,/' ./chainspec.json
sed -i 's/"runtimeUpgradeProposalGracePeriod":.*/"runtimeUpgradeProposalGracePeriod": 0,/' chainspec.json

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sed -i 's/"setElectionParametersProposalGracePeriod":.*/"setElectionParametersProposalGracePeriod": 0,/' ./chainspec.json
sed -i 's/"setElectionParametersProposalGracePeriod":.*/"setElectionParametersProposalGracePeriod": 0,/' chainspec.json

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -0,0 +1,13 @@
#!/bin/bash
cargo run --release -p joystream-node build-spec --chain dev > chainspec.json
Copy link
Member

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.

Copy link
Contributor Author

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');
Copy link
Member

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;
Copy link
Member

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.

Copy link
Contributor Author

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!;
Copy link
Member

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.

Copy link
Contributor Author

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);
Copy link
Member

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?

Copy link
Contributor Author

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),
Copy link
Member

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))

Copy link
Contributor Author

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);
Copy link
Member

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.

@mnaamani
Copy link
Member

mnaamani commented May 22, 2020

 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.

I realize now, the reason it failed is because the Migrated event would not have been raised because I didn't prepare one with a higher spec version than runtime of the test chain before updating it.

@gleb-urvanov gleb-urvanov marked this pull request as draft May 27, 2020 16:08
@gleb-urvanov gleb-urvanov marked this pull request as ready for review May 28, 2020 12:57
@mnaamani mnaamani merged commit 8cca867 into Joystream:development Jun 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants