advanceNonceAccount.test.ts 919 B

1234567891011121314151617181920212223
  1. import { generateSigner } from '@metaplex-foundation/umi';
  2. import test from 'ava';
  3. import { advanceNonceAccount, fetchNonce } from '../src/index.js';
  4. import { createNonceAccount, createUmi } from './_setup.js';
  5. test('it advances the nonce account', async (t) => {
  6. // Given an existing nonce account.
  7. const umi = await createUmi();
  8. const nonce = generateSigner(umi);
  9. const authority = generateSigner(umi);
  10. await createNonceAccount(umi, nonce, authority);
  11. const originalNonceAccount = await fetchNonce(umi, nonce.publicKey);
  12. // When the authority advances the nonce account.
  13. await advanceNonceAccount(umi, {
  14. nonceAccount: nonce.publicKey,
  15. nonceAuthority: authority,
  16. }).sendAndConfirm(umi);
  17. // Then we expect the blockhash to have been updated.
  18. const updatedNonceAccount = await fetchNonce(umi, nonce.publicKey);
  19. t.not(originalNonceAccount.blockhash, updatedNonceAccount.blockhash);
  20. });