generated from metaplex-foundation/solana-project-template
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bumping shank version and fixing tests.
- Loading branch information
1 parent
2598ac4
commit 1cd96f7
Showing
4 changed files
with
12 additions
and
58 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,10 @@ | ||
#![cfg(feature = "test-sbf")] | ||
|
||
use borsh::BorshDeserialize; | ||
use mpl_core::{accounts::MyAccount, instructions::CreateBuilder}; | ||
use solana_program_test::{tokio, ProgramTest}; | ||
use solana_sdk::{ | ||
signature::{Keypair, Signer}, | ||
transaction::Transaction, | ||
}; | ||
|
||
#[tokio::test] | ||
async fn create() { | ||
let mut context = ProgramTest::new("mpl_core_program", mpl_core::ID, None) | ||
let _context = ProgramTest::new("mpl_core_program", mpl_core::ID, None) | ||
.start_with_context() | ||
.await; | ||
|
||
// Given a new keypair. | ||
|
||
let address = Keypair::new(); | ||
|
||
let ix = CreateBuilder::new() | ||
.address(address.pubkey()) | ||
.authority(context.payer.pubkey()) | ||
.payer(context.payer.pubkey()) | ||
.arg1(1) | ||
.arg2(2) | ||
.instruction(); | ||
|
||
// When we create a new account. | ||
|
||
let tx = Transaction::new_signed_with_payer( | ||
&[ix], | ||
Some(&context.payer.pubkey()), | ||
&[&context.payer, &address], | ||
context.last_blockhash, | ||
); | ||
context.banks_client.process_transaction(tx).await.unwrap(); | ||
|
||
// Then an account was created with the correct data. | ||
|
||
let account = context | ||
.banks_client | ||
.get_account(address.pubkey()) | ||
.await | ||
.unwrap(); | ||
|
||
assert!(account.is_some()); | ||
|
||
let account = account.unwrap(); | ||
assert_eq!(account.data.len(), MyAccount::LEN); | ||
|
||
let mut account_data = account.data.as_ref(); | ||
let my_account = MyAccount::deserialize(&mut account_data).unwrap(); | ||
assert_eq!(my_account.data.field1, 1); | ||
assert_eq!(my_account.data.field2, 2); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters