Skip to content

Fix/4824 verify validator#4868

Closed
chrlschwb wants to merge 79 commits intoJoystream:masterfrom
chrlschwb:fix/4824-VerifyValidator
Closed

Fix/4824 verify validator#4868
chrlschwb wants to merge 79 commits intoJoystream:masterfrom
chrlschwb:fix/4824-VerifyValidator

Conversation

@chrlschwb
Copy link
Copy Markdown
Contributor

Copy link
Copy Markdown
Collaborator

@thesan thesan left a comment

Choose a reason for hiding this comment

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

So far so good!

if (group.name !== 'operationsWorkingGroupBeta') {
return invalidMetadata(`The ${group.name} is incompatible with the remarked moderatePost`)
}
const member = await getMemberById(store, workerId, ['metadata', 'metadata.externalResources'])
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No need for metadata.externalResources

return invalidMetadata(`${actor} is not an HR account`)
}

const member = await getMemberById(store, workerId, ['metadata'])
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

workerId is the memberId of the HR worker not that of the validator.

const {memberId, validatorAccount} = const { postId, rationale } = metadata.verifyValidator

The memberId is string but I need u64 for the getMemberById function. What should I do?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Oh I completely missed that.

You could use:

import { createType } from '@joystream/types'
createType('MemberId', Number(metadata.verifyValidator.memberId))

But getMemberById just converts the id into a string so maybe just change the getMemberById id argument to: MemberId | string.

Copy link
Copy Markdown
Collaborator

@thesan thesan left a comment

Choose a reason for hiding this comment

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

The rest looks good 👍

import { generateParamsFromAccountId } from '../../fixtures/membership/utils'
import { MembershipMetadata } from '@joystream/metadata-protobuf'

export default async function updatingVerifyAccount({ api, query }: FlowProps): Promise<void> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is not the actually testing the validator profile verification. To test this I think you would need to create a fixture like RemarkModeratePostsFixture. But that would be a lot of effort. @zeeshanakram3 in your opinion is this test worth the effort or can we skip it here ?

Comment on lines +36 to +39
moderatePost: {
postId: Long.fromString(String(u.postId)),
rationale: u.rationale,
},
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please revert this change

@zeeshanakram3
Copy link
Copy Markdown
Contributor

zeeshanakram3 commented Sep 20, 2023

This is not the actually testing the validator profile verification. To test this I think you would need to create a fixture like RemarkModeratePostsFixture. But that would be a lot of effort. @zeeshanakram3 in your opinion is this test worth the effort or can we skip it here ?

Yes, so I think the integration-test should be added for this action. Although, there isn't any specific place to add fixture for this specific action, but still I would say that add a new fixture VerifyVealidatorAccountFixture.ts in tests/network-tests/src/fixtures/membership.

After creating the new fixture, add a new flow (say validatorProfile.ts) in tests/network-tests/src/flows/membership, in which you would have to both first create a validator profile (most of the code from the updatingProfile flow will be reused) , and then after that do the validator verification using the VerifyVealidatorAccountFixture.ts fixture.

Last step, add the flow (validatorProfile.ts) to the tests/network-tests/src/scenarios/memberships.ts scenarios file. Make sure that this flow has dependency on the hireLeads job/flow.

cc. @chrlschwb

Copy link
Copy Markdown
Collaborator

@thesan thesan left a comment

Choose a reason for hiding this comment

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

Again the changes to these files are unnecessary:

  • metadata-protobuf/proto/Membership.proto
  • query-node/mappings/src/membership.ts
  • query-node/schemas/membership.graphql
  • tests/network-tests/src/fixtures/membership/GiftMembershipHappyCaseFixture.ts
  • tests/network-tests/src/fixtures/membership/InviteMembersHappyCaseFixture.ts
  • tests/network-tests/src/fixtures/membership/UpdateProfileHappyCaseFixture.ts
  • tests/network-tests/src/fixtures/membership/utils.ts
  • tests/network-tests/src/flows/membership/updatingProfile.ts
  • tests/network-tests/src/graphql/queries/membership.graphql

They just make this PR more complex. Please remove them for now. You can add them back on #4915 later on. If after removing all these schema changes one these fixtures fails please just push the failing code and I'll have a look into it.

Comment on lines +65 to +70
protected assertQueryNodeEventIsValid(qEvent: MemberVerificationStatusUpdatedEventFieldsFragment, i: number): void {
console.log(qEvent, '---------------------------------------------------')

// assert.equal(qEvent.member.id, this.inputs[i % this.inputs.length].asMember.toString())
// assert.equal(qEvent.account, this.inputs[i % this.inputs.length].account.toString())
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

AFAIK this is not necessary:

Suggested change
protected assertQueryNodeEventIsValid(qEvent: MemberVerificationStatusUpdatedEventFieldsFragment, i: number): void {
console.log(qEvent, '---------------------------------------------------')
// assert.equal(qEvent.member.id, this.inputs[i % this.inputs.length].asMember.toString())
// assert.equal(qEvent.account, this.inputs[i % this.inputs.length].account.toString())
}

})
}

private assetVerifyValidatorTest(qMember: MembershipFieldsFragment[] | null): void {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please rename this method to:

Suggested change
private assetVerifyValidatorTest(qMember: MembershipFieldsFragment[] | null): void {
private assertQueriedMembershipAreValid(qMember: MembershipFieldsFragment[] | null): void {

})
}

private assetVerifyValidatorTest(qMember: MembershipFieldsFragment[] | null): void {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

also please remove the commented code and console.log

const verifyAccountFixture = new VerifyValidatorProfileFixture(api, query, VerifyValidator)
const remarkModerateRunner = new FixtureRunner(verifyAccountFixture)
await remarkModerateRunner.run()
await remarkModerateRunner.runQueryNodeChecks()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please address this #4868 (comment)

Comment on lines 15 to 25
memberId: '1',
isVerified: true,
isVerifiedValidator: false,
},
{
memberId: '2',
isVerified: true,
asWorker: 'j4VEC6FcJtBrwYQKhBAoB6Rj83jDeVua6azuHBrri1zoksBkz',
isVerifiedValidator: false,
},
{
memberId: '3',
isVerified: false,
asWorker: 'j4VEC6FcJtBrwYQKhBAoB6Rj83jDeVua6azuHBrri1zoksBkz',
memberId: '27',
isVerifiedValidator: false,
},
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

These 3 inputs are not actually changing the member metadata isVerifiedValidator. isVerifiedValidator should be set to true. If the tests don't pass it probably means that the mappings have a bug.

Also the 3 inputs are basically identical, so there's no point having them all. If you manage to add a membership WG worker and pass their id asWorker then 2 inputs should be enough: one without the asWorker field (so ran as a lead) and another with it. If not just one with { memberId: '1', isVerifiedValidator: false }.

contentDirectoryJob
)
job('updating member verify account', updateValidatorAccount).after(hireLeads)
job('updating member verify profile', updateValidatorAccount).after(hireLeads)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please address #4868 (comment)

}

protected async getExtrinsics(): Promise<SubmittableExtrinsic<'promise'>[]> {
console.log(this.updates, '================+++++++++++++++++++=================')
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please remove this change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants