From cd684577a6dfc620f0bbad27b43d11a6aac30eb1 Mon Sep 17 00:00:00 2001 From: Greg Fitzgerald Date: Wed, 9 Sep 2020 17:32:50 -0600 Subject: [PATCH] chore: add integration test (#12143) --- web3.js/test/stake-program.test.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/web3.js/test/stake-program.test.js b/web3.js/test/stake-program.test.js index 6c14577d33..be29f24104 100644 --- a/web3.js/test/stake-program.test.js +++ b/web3.js/test/stake-program.test.js @@ -441,4 +441,30 @@ test('live staking actions', async () => { expect(balance).toEqual(minimumAmount + 2); const recipientBalance = await connection.getBalance(recipient.publicKey); expect(recipientBalance).toEqual(minimumAmount + 20); + + // Authorize a derived address + authorize = StakeProgram.authorize({ + stakePubkey: newAccountPubkey, + authorizedPubkey: newAuthorized.publicKey, + newAuthorizedPubkey: newAccountPubkey, + stakeAuthorizationType: StakeAuthorizationLayout.Withdrawer, + }); + await sendAndConfirmTransaction(connection, authorize, [newAuthorized], { + commitment: 'single', + skipPreflight: true, + }); + + // Restore the previous authority using a dervied address + authorize = StakeProgram.authorizeWithSeed({ + stakePubkey: newAccountPubkey, + authorityBase: from.publicKey, + authoritySeed: seed, + authorityOwner: StakeProgram.programId, + newAuthorizedPubkey: newAuthorized.publicKey, + stakeAuthorizationType: StakeAuthorizationLayout.Withdrawer, + }); + await sendAndConfirmTransaction(connection, authorize, [from], { + commitment: 'single', + skipPreflight: true, + }); });