Skip to content

Commit

Permalink
Bumping shank version and fixing tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
blockiosaurus committed Feb 29, 2024
1 parent 2598ac4 commit 1cd96f7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 58 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 1 addition & 47 deletions clients/rust/tests/create.rs
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);
}
4 changes: 2 additions & 2 deletions idls/mpl_core.json
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,7 @@
"metadata": {
"origin": "shank",
"address": "CoREzp6dAdLVRKf3EM5tWrsXM2jQwRFeu5uhzsAyjYXL",
"binaryVersion": "0.4.1",
"libVersion": "0.4.1"
"binaryVersion": "0.4.2",
"libVersion": "0.4.2"
}
}
2 changes: 1 addition & 1 deletion programs/mpl-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ crate-type = ["cdylib", "lib"]

[dependencies]
borsh = "^0.10"
shank = "0.4.1"
shank = "0.4.2"
num-derive = "^0.3"
num-traits = "^0.2"
solana-program = "^1.16"
Expand Down

0 comments on commit 1cd96f7

Please sign in to comment.