This repository has been archived by the owner on Oct 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update stake authorization to take validator array (#167)
- Loading branch information
Showing
5 changed files
with
85 additions
and
35 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { createStakeAuthorization } from './stake' | ||
import { StakeAuthorization } from '../../proto/cosmos/staking/authz' | ||
import { denom, val, val2 } from '../../proto/tests/utils' | ||
import { JSONOptions } from '../../proto/tests/common' | ||
|
||
const validateStakeAuthorization = (validators: string | string[]) => { | ||
const authorization = 1 | ||
const amount = '100000' | ||
|
||
const msg = createStakeAuthorization(validators, denom, amount, authorization) | ||
|
||
const expValidators = Array.isArray(validators) ? validators : [validators] | ||
|
||
expect(msg.message.toJson(JSONOptions)).toStrictEqual({ | ||
allow_list: { | ||
address: expValidators, | ||
}, | ||
authorization_type: authorization, | ||
max_tokens: { | ||
denom, | ||
amount, | ||
}, | ||
}) | ||
expect(msg.path).toStrictEqual(StakeAuthorization.typeName) | ||
} | ||
|
||
describe('test authz staking messages', () => { | ||
it('encodes single validator addresses', () => { | ||
validateStakeAuthorization(val) | ||
}) | ||
|
||
it('encodes multiple validator addresses', () => { | ||
const validators = [val, val2] | ||
validateStakeAuthorization(validators) | ||
}) | ||
}) |
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