fix: add stake unit tests

This commit is contained in:
Tyera Eulberg
2019-12-23 16:50:27 -07:00
committed by Michael Vines
parent 6ebd47fbac
commit 07c0670f65
3 changed files with 240 additions and 5 deletions

View File

@@ -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,
});