Adding test for generating signatures in correct order even addresses are checksumed
This commit is contained in:
parent
e6a2d53bdd
commit
317c990993
|
@ -6,7 +6,7 @@ const generateSignatureFrom = (account: string) =>
|
||||||
|
|
||||||
export const buildSignaturesFrom = (ownersWhoHasSigned: List<string>, sender: string) => {
|
export const buildSignaturesFrom = (ownersWhoHasSigned: List<string>, sender: string) => {
|
||||||
const signatures = ownersWhoHasSigned.push(sender)
|
const signatures = ownersWhoHasSigned.push(sender)
|
||||||
const orderedSignatures = signatures.sortBy(signature => signature)
|
const orderedSignatures = signatures.sort() // JS by default sorts in a non case-senstive way
|
||||||
|
|
||||||
let sigs = '0x'
|
let sigs = '0x'
|
||||||
orderedSignatures.forEach((owner: string) => {
|
orderedSignatures.forEach((owner: string) => {
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { buildMathPropsFrom } from '~/test/utils/buildReactRouterProps'
|
||||||
import { safeSelector } from '~/routes/safe/store/selectors/index'
|
import { safeSelector } from '~/routes/safe/store/selectors/index'
|
||||||
import { aMinedSafe } from '~/test/builder/safe.redux.builder'
|
import { aMinedSafe } from '~/test/builder/safe.redux.builder'
|
||||||
|
|
||||||
describe('Safe Blockchain Test', () => {
|
describe('DailyLimit Blockchain Test', () => {
|
||||||
let store
|
let store
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
store = aNewStore()
|
store = aNewStore()
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
// @flow
|
||||||
|
import { List } from 'immutable'
|
||||||
|
import { buildSignaturesFrom } from '~/logic/safe/safeTxSigner'
|
||||||
|
|
||||||
|
describe('Signatures Blockchain Test', () => {
|
||||||
|
it('generates signatures in natural order even checksumed', async () => {
|
||||||
|
// GIVEN
|
||||||
|
const userA = 'baR'
|
||||||
|
const userB = 'baz'
|
||||||
|
const userC = 'foZa'
|
||||||
|
const sender = 'foZ'
|
||||||
|
|
||||||
|
// WHEN
|
||||||
|
const result = '0x' +
|
||||||
|
// eslint-disable-next-line
|
||||||
|
'000000000000000000000000' + 'baR' + '000000000000000000000000000000000000000000000000000000000000000001' +
|
||||||
|
// eslint-disable-next-line
|
||||||
|
'000000000000000000000000' + 'baz' + '000000000000000000000000000000000000000000000000000000000000000001' +
|
||||||
|
// eslint-disable-next-line
|
||||||
|
'000000000000000000000000' + 'foZ' + '000000000000000000000000000000000000000000000000000000000000000001' +
|
||||||
|
// eslint-disable-next-line
|
||||||
|
'000000000000000000000000' + 'foZa' + '000000000000000000000000000000000000000000000000000000000000000001'
|
||||||
|
|
||||||
|
// THEN
|
||||||
|
expect(buildSignaturesFrom(List([userA, userB, userC]), sender)).toEqual(result)
|
||||||
|
expect(buildSignaturesFrom(List([userB, userA, userC]), sender)).toEqual(result)
|
||||||
|
expect(buildSignaturesFrom(List([userA, sender, userC]), userB)).toEqual(result)
|
||||||
|
expect(buildSignaturesFrom(List([sender, userA, userC]), userB)).toEqual(result)
|
||||||
|
expect(buildSignaturesFrom(List([userB, sender, userC]), userA)).toEqual(result)
|
||||||
|
expect(buildSignaturesFrom(List([sender, userB, userC]), userA)).toEqual(result)
|
||||||
|
expect(buildSignaturesFrom(List([userA, userB, sender]), userC)).toEqual(result)
|
||||||
|
expect(buildSignaturesFrom(List([userB, userA, sender]), userC)).toEqual(result)
|
||||||
|
expect(buildSignaturesFrom(List([userA, sender, userB]), userC)).toEqual(result)
|
||||||
|
expect(buildSignaturesFrom(List([sender, userA, userB]), userC)).toEqual(result)
|
||||||
|
expect(buildSignaturesFrom(List([userB, sender, userA]), userC)).toEqual(result)
|
||||||
|
expect(buildSignaturesFrom(List([sender, userB, userA]), userC)).toEqual(result)
|
||||||
|
})
|
||||||
|
})
|
Loading…
Reference in New Issue