Skip to content

Commit 1e4cd1e

Browse files
committed
fix tests
1 parent 1fed1a9 commit 1e4cd1e

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

program-libs/account-checks/src/account_info/test_account_info.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
#[cfg(feature = "pinocchio")]
44
pub mod pinocchio {
5+
extern crate std;
6+
use std::vec::Vec;
7+
58
use pinocchio::{account_info::AccountInfo, instruction::Account, pubkey::Pubkey};
69
use rand::{prelude::Rng, thread_rng};
710

program-libs/compressed-account/src/address.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ pub fn derive_address_legacy(
77
seed: &[u8; 32],
88
) -> Result<[u8; 32], CompressedAccountError> {
99
let slices = [merkle_tree_pubkey.as_ref(), seed.as_ref()];
10-
let hash = hashv_to_bn254_field_size_be_const_array::<3>(&slices)
11-
.expect("hashv_to_bn254_field_size_be_const_array::<3> should be infallible for Keccak");
10+
let hash = hashv_to_bn254_field_size_be_const_array::<3>(&slices)?;
1211
Ok(hash)
1312
}
1413

@@ -22,5 +21,6 @@ pub fn derive_address(
2221
merkle_tree_pubkey.as_slice(),
2322
program_id_bytes.as_slice(),
2423
];
25-
hashv_to_bn254_field_size_be_const_array::<4>(&slices).unwrap()
24+
hashv_to_bn254_field_size_be_const_array::<4>(&slices)
25+
.expect("hashv_to_bn254_field_size_be_const_array::<4> should be infallible for Keccak")
2626
}

sdk-libs/sdk-types/src/address.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ pub mod v1 {
4848
}
4949

5050
fn hashv_to_bn254_field_size_be_legacy(bytes: &[&[u8]]) -> [u8; 32] {
51-
let mut hashed_value: [u8; 32] = Keccak::hashv(bytes).unwrap();
51+
let mut hashed_value: [u8; 32] = Keccak::hashv(bytes)
52+
.expect("Keccak::hashv should be infallible when keccak feature is enabled");
5253
// Truncates to 31 bytes so that value is less than bn254 Fr modulo
5354
// field size.
5455
hashed_value[0] = 0;

sdk-libs/sdk-types/src/instruction/account_info.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ use std::vec::Vec;
66
#[cfg(feature = "alloc")]
77
use light_compressed_account::compressed_account::PackedCompressedAccountWithMerkleContext;
88
use light_compressed_account::{
9-
compressed_account::{CompressedAccount, CompressedAccountData, PackedMerkleContext},
10-
instruction_data::{
11-
data::OutputCompressedAccountWithPackedContext,
12-
with_account_info::{CompressedAccountInfo, InAccountInfo},
13-
},
9+
compressed_account::PackedMerkleContext,
10+
instruction_data::with_account_info::{CompressedAccountInfo, InAccountInfo},
11+
};
12+
#[cfg(feature = "alloc")]
13+
use light_compressed_account::{
14+
compressed_account::{CompressedAccount, CompressedAccountData},
15+
instruction_data::data::OutputCompressedAccountWithPackedContext,
1416
Pubkey,
1517
};
1618

sdk-libs/sdk/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,5 @@ light-zero-copy = { workspace = true }
5050
[dev-dependencies]
5151
num-bigint = { workspace = true }
5252
light-compressed-account = { workspace = true, features = ["new-unique"] }
53+
light-hasher = { workspace = true, features = ["keccak"] }
5354
anchor-lang = { workspace = true }

0 commit comments

Comments
 (0)