From c09d28ac884a561e2cb90d7abec7397c2f416caf Mon Sep 17 00:00:00 2001 From: Sammy <41593264+stegaBOB@users.noreply.github.com> Date: Tue, 3 Jan 2023 00:42:48 -0600 Subject: [PATCH] add tests --- name-service/program/tests/functional.rs | 42 ++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/name-service/program/tests/functional.rs b/name-service/program/tests/functional.rs index 5da207af493..6b7e658813a 100644 --- a/name-service/program/tests/functional.rs +++ b/name-service/program/tests/functional.rs @@ -10,6 +10,7 @@ use solana_sdk::{ transaction::Transaction, transport::TransportError, }; +use spl_name_service::instruction::realloc; use spl_name_service::{ instruction::{create, delete, transfer, update, NameRegistryInstruction}, processor::Processor, @@ -175,6 +176,47 @@ async fn test_name_service() { .unwrap(); println!("Name Record Header: {:?}", name_record_header); + let data = "hello".as_bytes().to_vec(); + let update_instruction = update( + program_id, + space as u32, + data, + name_account_key, + sol_subdomains_class.pubkey(), + Some(name_record_header.parent_name), + ) + .unwrap(); + + sign_send_instruction( + &mut ctx, + update_instruction.clone(), + vec![&sol_subdomains_class], + ) + .await + .unwrap_err(); + + let new_space = space * 2; + let realloc_instruction = realloc( + ctx.payer.pubkey(), + program_id, + name_account_key, + ctx.payer.pubkey(), + new_space as u32, + ) + .unwrap(); + sign_send_instruction(&mut ctx, realloc_instruction, vec![]) + .await + .unwrap(); + + // warping slot to resend update ix without dropping duplicate txn + let new_slot = ctx.banks_client.get_root_slot().await.unwrap() + 32; + ctx.warp_to_slot(new_slot).expect("warp failed"); + + // resend update ix. Should succeed this time. + sign_send_instruction(&mut ctx, update_instruction, vec![&sol_subdomains_class]) + .await + .unwrap(); + let delete_instruction = delete( program_id, name_account_key,