dcou: BorrowedAccount::set_data() (#32424)

* dcou: BorrowedAccount::set_data()

* Properly depend on dev-context-only-utils
This commit is contained in:
Ryo Onodera 2023-07-13 22:44:08 +09:00 committed by GitHub
parent 40249cdc9e
commit d80745cfaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 9 additions and 4 deletions

View File

@ -33,6 +33,7 @@ thiserror = { workspace = true }
[dev-dependencies]
libsecp256k1 = { workspace = true }
solana-logger = { workspace = true }
solana-sdk = { workspace = true, features = ["dev-context-only-utils"] }
[lib]
crate-type = ["lib"]

View File

@ -24,6 +24,7 @@ thiserror = { workspace = true }
[dev-dependencies]
memoffset = { workspace = true }
solana-sdk = { workspace = true, features = ["dev-context-only-utils"] }
[lib]
crate-type = ["lib"]

View File

@ -64,7 +64,7 @@ where
return Err(InstructionError::InvalidAccountData);
}
proof_context_account.set_data(context_state_data)?;
proof_context_account.set_data_from_slice(&context_state_data)?;
}
Ok(())

View File

@ -85,6 +85,7 @@ libsecp256k1 = { workspace = true }
memoffset = { workspace = true }
rand_chacha = { workspace = true }
solana-logger = { workspace = true }
solana-sdk = { workspace = true, features = ["dev-context-only-utils"] }
static_assertions = { workspace = true }
test-case = { workspace = true }

View File

@ -35,6 +35,7 @@ full = [
"sha3",
"digest",
]
dev-context-only-utils = []
[dependencies]
assert_matches = { workspace = true, optional = true }

View File

@ -886,9 +886,10 @@ impl<'a> BorrowedAccount<'a> {
/// You should always prefer set_data_from_slice(). Calling this method is
/// currently safe but requires some special casing during CPI when direct
/// account mapping is enabled.
///
/// Currently only used by tests and the program-test crate.
#[cfg(not(target_os = "solana"))]
#[cfg(all(
not(target_os = "solana"),
any(test, feature = "dev-context-only-utils")
))]
pub fn set_data(&mut self, data: Vec<u8>) -> Result<(), InstructionError> {
self.can_data_be_resized(data.len())?;
self.can_data_be_changed()?;