-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update Polkadot types * Add some more details to the failing tests * Fix the voting commitment related tests * Upgrade `@joystream/js` and `@joystream/metadata-protobuf` * Skip remaining failing tests * Fix formatting * Fix the `@joystream/js` and `@joystream/metadata-protobuf` versions
- Loading branch information
Showing
11 changed files
with
616 additions
and
1,075 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 23 additions & 23 deletions
46
packages/ui/test/council/model/calculateCommitment.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,41 @@ | ||
import { blake2AsHex } from '@polkadot/util-crypto' | ||
|
||
import { createType } from '@/common/model/createType' | ||
import { calculateCommitment } from '@/council/model/calculateCommitment' | ||
|
||
import { accountsMap } from '../../../dev/node-mocks/data/addresses' | ||
|
||
const TEST_SALT = '0x16dfff7ba21922067a0c114de774424abcd5d60fc58658a35341c9181b09e94a' | ||
const ACCOUNT = accountsMap.alice | ||
const OPTION = '0' | ||
const CYCLE = 1 | ||
|
||
describe('Model: calculateCommitment', () => { | ||
const aliceExpectedCommitment = '0x3db26e2bd023ccf2d1167fd42d48cc76b1c1e5c1de9003f61e63ec6a337b91a2' | ||
const bobExpectedCommitment = '0xf94e151db1bbcd27018ee12400b05b8d5ad495dc8d481421fdc366639d42be75' | ||
// These are the commitment and payload expected for: ALICE_ADDRESS, '0', TEST_SALT, 1 | ||
const expectedCommitment = '0x3db26e2bd023ccf2d1167fd42d48cc76b1c1e5c1de9003f61e63ec6a337b91a2' | ||
|
||
const TEST_SALT = '0x16dfff7ba21922067a0c114de774424abcd5d60fc58658a35341c9181b09e94a' | ||
const aliceCommitment = calculateCommitment(accountsMap.alice, '0', TEST_SALT, 1) | ||
const bobCommitment = calculateCommitment(accountsMap.bob, '0', TEST_SALT, 1) | ||
const expectedPayload = new Uint8Array([ | ||
212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214, 130, 44, 133, 88, 133, 76, 205, 227, 154, | ||
86, 132, 231, 165, 109, 162, 125, 0, 0, 0, 0, 0, 0, 0, 0, 128, 22, 223, 255, 123, 162, 25, 34, 6, 122, 12, 17, 77, | ||
231, 116, 66, 74, 188, 213, 214, 15, 197, 134, 88, 163, 83, 65, 201, 24, 27, 9, 233, 74, 1, 0, 0, 0, 0, 0, 0, 0, | ||
]) | ||
|
||
// This is the main test the 2 others are just for debugging in case this is failing | ||
it('calculateCommitment', () => { | ||
expect(aliceCommitment).toBe(aliceExpectedCommitment) | ||
expect(bobCommitment).toBe(bobExpectedCommitment) | ||
expect(calculateCommitment(accountsMap.alice, '0', TEST_SALT, 1)).toBe(expectedCommitment) | ||
}) | ||
|
||
// This is the payload of: ALICE_ADDRESS, '0', TEST_SALT, 1 | ||
const aliceVotePayload = Buffer.from( | ||
new Uint8Array([ | ||
0xd4, 0x35, 0x93, 0xc7, 0x15, 0xfd, 0xd3, 0x1c, 0x61, 0x14, 0x1a, 0xbd, 0x4, 0xa9, 0x9f, 0xd6, 0x82, 0x2c, 0x85, | ||
0x58, 0x85, 0x4c, 0xcd, 0xe3, 0x9a, 0x56, 0x84, 0xe7, 0xa5, 0x6d, 0xa2, 0x7d, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, | ||
0x0, 0x80, 0x16, 0xdf, 0xff, 0x7b, 0xa2, 0x19, 0x22, 0x6, 0x7a, 0xc, 0x11, 0x4d, 0xe7, 0x74, 0x42, 0x4a, 0xbc, | ||
0xd5, 0xd6, 0xf, 0xc5, 0x86, 0x58, 0xa3, 0x53, 0x41, 0xc9, 0x18, 0x1b, 0x9, 0xe9, 0x4a, 0x1, 0x0, 0x0, 0x0, 0x0, | ||
0x0, 0x0, 0x0, | ||
]) | ||
) | ||
|
||
// If this fails => something is wrong with the payload generation | ||
it('payload', () => { | ||
expect(blake2AsHex(aliceVotePayload)).toBe(aliceCommitment) | ||
const accountPayload = createType('AccountId', ACCOUNT).toU8a() | ||
const optionPayload = createType('MemberId', Number.parseInt(OPTION)).toU8a() | ||
const saltPayload = createType('Bytes', TEST_SALT).toU8a() | ||
const cyclePayload = createType('u64', CYCLE).toU8a() | ||
|
||
const payload = Buffer.concat([accountPayload, optionPayload, saltPayload, cyclePayload]) | ||
expect(new Uint8Array(payload)).toStrictEqual(expectedPayload) | ||
}) | ||
|
||
// If this fails => something is wrong with the blake2AsHex function | ||
// Verify that if given the correct payload blake2AsHex returned the correct commitment | ||
it('blake2AsHex', () => { | ||
expect(blake2AsHex(aliceVotePayload)).toBe(aliceExpectedCommitment) | ||
expect(blake2AsHex(Buffer.from(expectedPayload))).toBe(expectedCommitment) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.