fix: add stake unit tests
This commit is contained in:
committed by
Michael Vines
parent
6ebd47fbac
commit
07c0670f65
@@ -6,7 +6,14 @@ export {CONFIG_PROGRAM_ID} from './config-program';
|
||||
export {Connection} from './connection';
|
||||
export {Loader} from './loader';
|
||||
export {PublicKey} from './publickey';
|
||||
export {StakeInstruction, StakeProgram} from './stake-program';
|
||||
export {
|
||||
Authorized,
|
||||
Lockup,
|
||||
StakeAuthorizationLayout,
|
||||
StakeInstruction,
|
||||
StakeInstructionLayout,
|
||||
StakeProgram,
|
||||
} from './stake-program';
|
||||
export {SystemInstruction, SystemProgram} from './system-program';
|
||||
export {Transaction, TransactionInstruction} from './transaction';
|
||||
export {VALIDATOR_INFO_KEY, ValidatorInfo} from './validator-info';
|
||||
|
@@ -97,7 +97,7 @@ export class StakeInstruction extends TransactionInstruction {
|
||||
/**
|
||||
* An enumeration of valid StakeInstructionTypes
|
||||
*/
|
||||
const StakeInstructionLayout = Object.freeze({
|
||||
export const StakeInstructionLayout = Object.freeze({
|
||||
Initialize: {
|
||||
index: 0,
|
||||
layout: BufferLayout.struct([
|
||||
@@ -210,8 +210,14 @@ export class StakeProgram {
|
||||
): TransactionInstruction {
|
||||
const type = StakeInstructionLayout.Initialize;
|
||||
const data = encodeData(type, {
|
||||
authorized,
|
||||
lockup,
|
||||
authorized: {
|
||||
staker: authorized.staker.toBuffer(),
|
||||
withdrawer: authorized.withdrawer.toBuffer(),
|
||||
},
|
||||
lockup: {
|
||||
epoch: lockup.epoch,
|
||||
custodian: lockup.custodian.toBuffer(),
|
||||
},
|
||||
});
|
||||
const instructionData = {
|
||||
keys: [
|
||||
@@ -307,7 +313,7 @@ export class StakeProgram {
|
||||
): Transaction {
|
||||
const type = StakeInstructionLayout.Authorize;
|
||||
const data = encodeData(type, {
|
||||
newAuthorized,
|
||||
newAuthorized: newAuthorized.toBuffer(),
|
||||
stakeAuthorizationType: stakeAuthorizationType.index,
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user