-
We're creating a
PDAusing create_user.rs instruction.#[account( init, seeds=[User::PREFIX.as_bytes(), user.key().as_ref()], payer=user, space=User::SIZE, bump )] pub user_account: Box<Account<'info, User>>,
-
We're closing it using destroy_user.rs instruction, which uses
AnchorAccoutClosetrait.user_account.close(user.to_account_info())?;
-
In our test destroy-an-account.ts we're using
fetchNullablesince we expect the account to benullprior to creation and after closing.const userAccountBefore = await program.account.user.fetchNullable(userAccountAddress, "processed"); assert.equal(userAccountBefore, null); ... ... const userAccountAfter = await program.account.user.fetchNullable(userAccountAddress, "processed"); assert.notEqual(userAccountAfter, null);
anchor
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||