test: tweak test to suss out tx message serialization bug

This commit is contained in:
Trent Nelson 2020-07-01 20:25:49 -06:00 committed by Trent Nelson
parent 3e3241125f
commit 40800e257c
1 changed files with 9 additions and 7 deletions

View File

@ -239,18 +239,20 @@ test('serialize unsigned transaction', () => {
expect(expectedTransaction.signatures.length).toBe(1); expect(expectedTransaction.signatures.length).toBe(1);
}); });
test('get sign data for transaction', () => { test('externally signed stake delegate', () => {
const from_keypair = nacl.sign.keyPair.fromSeed( const from_keypair = nacl.sign.keyPair.fromSeed(
Uint8Array.from(Array(32).fill(1)), Uint8Array.from(Array(32).fill(1)),
); );
const from = new Account(Buffer.from(from_keypair.secretKey)); const authority = new Account(Buffer.from(from_keypair.secretKey));
const to = new PublicKey(2); const stake = new PublicKey(2);
const recentBlockhash = new PublicKey(3).toBuffer(); const recentBlockhash = new PublicKey(3).toBuffer();
var tx = SystemProgram.transfer({ const vote = new PublicKey(4);
fromPubkey: from.publicKey, var tx = StakeProgram.delegate({
toPubkey: to, stakePubkey: stake,
lamports: 42, authorizedPubkey: authority.publicKey,
votePubkey: vote,
}); });
const from = authority;
tx.recentBlockhash = bs58.encode(recentBlockhash); tx.recentBlockhash = bs58.encode(recentBlockhash);
const tx_bytes = tx.serializeMessage(); const tx_bytes = tx.serializeMessage();
const signature = nacl.sign.detached(tx_bytes, from.secretKey); const signature = nacl.sign.detached(tx_bytes, from.secretKey);