Commit a140dc9a authored by Andrew Jones's avatar Andrew Jones

Merge branch 'master' into aj-update-scale-info

# Conflicts:
#	primitives/src/key.rs
parents 1ddd4fa1 d095dd07
Pipeline #97168 failed with stages
in 8 minutes and 47 seconds
......@@ -64,11 +64,19 @@ pub struct LayoutKey {
key: [u8; 32],
}
impl<'a> From<&'a Key> for LayoutKey {
fn from(key: &'a Key) -> Self {
Self {
key: key.to_bytes(),
}
}
}
impl From<Key> for LayoutKey {
fn from(key: Key) -> Self {
let mut arr = [0x00; 32];
arr.copy_from_slice(key.as_bytes());
Self { key: arr }
Self {
key: key.to_bytes(),
}
}
}
......
......@@ -17,7 +17,7 @@ use ink_primitives::KeyPtr;
#[test]
fn layout_key_works() {
let layout_key = LayoutKey::from(Key([0x01; 32]));
let layout_key = LayoutKey::from(Key::from([0x01; 32]));
let json = serde_json::to_string(&layout_key).unwrap();
assert_eq!(
json,
......@@ -41,7 +41,7 @@ fn named_fields_struct_layout(key_ptr: &mut KeyPtr) -> Layout {
#[test]
fn named_fields_work() {
let layout = named_fields_struct_layout(&mut KeyPtr::from(Key([0x00; 32])));
let layout = named_fields_struct_layout(&mut KeyPtr::from(Key::from([0x00; 32])));
let mut registry = Registry::new();
let compacted = layout.into_compact(&mut registry);
let json = serde_json::to_value(&compacted).unwrap();
......@@ -66,10 +66,10 @@ fn named_fields_work() {
"layout": {
"Cell": {
"key": "0x\
0100000000000000\
0000000000000000\
0000000000000000\
0000000000000000\
0000000000000001",
0000000000000000",
"ty": 2,
}
},
......@@ -98,7 +98,7 @@ fn tuple_struct_layout(key_ptr: &mut KeyPtr) -> Layout {
#[test]
fn tuple_struct_work() {
let layout = tuple_struct_layout(&mut KeyPtr::from(Key([0x00; 32])));
let layout = tuple_struct_layout(&mut KeyPtr::from(Key::from([0x00; 32])));
let mut registry = Registry::new();
let compacted = layout.into_compact(&mut registry);
let json = serde_json::to_value(&compacted).unwrap();
......@@ -123,10 +123,10 @@ fn tuple_struct_work() {
"layout": {
"Cell": {
"key": "0x\
0100000000000000\
0000000000000000\
0000000000000000\
0000000000000000\
0000000000000001",
0000000000000000",
"ty": 2,
}
},
......@@ -153,7 +153,7 @@ fn clike_enum_layout(key_ptr: &mut KeyPtr) -> Layout {
#[test]
fn clike_enum_work() {
let layout = clike_enum_layout(&mut KeyPtr::from(Key([0x00; 32])));
let layout = clike_enum_layout(&mut KeyPtr::from(Key::from([0x00; 32])));
let mut registry = Registry::new();
let compacted = layout.into_compact(&mut registry);
let json = serde_json::to_value(&compacted).unwrap();
......@@ -184,7 +184,7 @@ fn clike_enum_work() {
fn mixed_enum_layout(key_ptr: &mut KeyPtr) -> Layout {
EnumLayout::new(
key_ptr.advance_by(1),
*key_ptr.advance_by(1),
vec![
(Discriminant(0), StructLayout::new(vec![])),
{
......@@ -234,7 +234,7 @@ fn mixed_enum_layout(key_ptr: &mut KeyPtr) -> Layout {
#[test]
fn mixed_enum_work() {
let layout = mixed_enum_layout(&mut KeyPtr::from(Key([0x00; 32])));
let layout = mixed_enum_layout(&mut KeyPtr::from(Key::from([0x00; 32])));
let mut registry = Registry::new();
let compacted = layout.into_compact(&mut registry);
let json = serde_json::to_value(&compacted).unwrap();
......@@ -256,10 +256,10 @@ fn mixed_enum_work() {
"layout": {
"Cell": {
"key": "0x\
0100000000000000\
0000000000000000\
0000000000000000\
0000000000000000\
0000000000000001",
0000000000000000",
"ty": 1,
}
},
......@@ -269,10 +269,10 @@ fn mixed_enum_work() {
"layout": {
"Cell": {
"key": "0x\
0200000000000000\
0000000000000000\
0000000000000000\
0000000000000000\
0000000000000002",
0000000000000000",
"ty": 2,
}
},
......@@ -286,10 +286,10 @@ fn mixed_enum_work() {
"layout": {
"Cell": {
"key": "0x\
0100000000000000\
0000000000000000\
0000000000000000\
0000000000000000\
0000000000000001",
0000000000000000",
"ty": 1,
}
},
......@@ -299,10 +299,10 @@ fn mixed_enum_work() {
"layout": {
"Cell": {
"key": "0x\
0200000000000000\
0000000000000000\
0000000000000000\
0000000000000000\
0000000000000002",
0000000000000000",
"ty": 2,
}
},
......@@ -333,7 +333,7 @@ fn unbounded_hashing_layout(key_ptr: &mut KeyPtr) -> Layout {
#[test]
fn unbounded_layout_works() {
let layout = unbounded_hashing_layout(&mut KeyPtr::from(Key([0x00; 32])));
let layout = unbounded_hashing_layout(&mut KeyPtr::from(Key::from([0x00; 32])));
let mut registry = Registry::new();
let compacted = layout.into_compact(&mut registry);
let json = serde_json::to_value(&compacted).unwrap();
......
......@@ -209,7 +209,7 @@ where
}
/// Writes the value to the contract storage under the given key.
pub fn set_contract_storage<V>(key: Key, value: &V)
pub fn set_contract_storage<V>(key: &Key, value: &V)
where
V: scale::Encode,
{
......@@ -223,7 +223,7 @@ where
/// # Errors
///
/// - If the decoding of the typed value failed
pub fn get_contract_storage<R>(key: Key) -> Option<Result<R>>
pub fn get_contract_storage<R>(key: &Key) -> Option<Result<R>>
where
R: scale::Decode,
{
......@@ -233,7 +233,7 @@ where
}
/// Clears the contract's storage key entry.
pub fn clear_contract_storage(key: Key) {
pub fn clear_contract_storage(key: &Key) {
<EnvInstance as OnInstance>::on_instance(|instance| {
Env::clear_contract_storage(instance, key)
})
......
......@@ -28,7 +28,7 @@ use ink_primitives::Key;
/// Environmental contract functionality that does not require `EnvTypes`.
pub trait Env {
/// Writes the value to the contract storage under the given key.
fn set_contract_storage<V>(&mut self, key: Key, value: &V)
fn set_contract_storage<V>(&mut self, key: &Key, value: &V)
where
V: scale::Encode;
......@@ -37,12 +37,12 @@ pub trait Env {
/// # Errors
///
/// - If the decoding of the typed value failed
fn get_contract_storage<R>(&mut self, key: Key) -> Option<Result<R>>
fn get_contract_storage<R>(&mut self, key: &Key) -> Option<Result<R>>
where
R: scale::Decode;
/// Clears the contract's storage key entry.
fn clear_contract_storage(&mut self, key: Key);
fn clear_contract_storage(&mut self, key: &Key);
/// Returns the value from the *runtime* storage at the position of the key if any.
///
......
......@@ -33,27 +33,7 @@ pub struct Selector {
bytes: [u8; 4],
}
impl<'a> From<&'a [u8]> for Selector {
/// Computes the selector from the given input bytes.
///
/// # Note
///
/// Normally this is invoked through `Selector::from_str`.
fn from(input: &'a [u8]) -> Self {
let keccak = ink_primitives::hash::keccak256(input);
Self {
bytes: [keccak[0], keccak[1], keccak[2], keccak[3]],
}
}
}
impl Selector {
/// Returns the selector for the given name.
#[allow(clippy::should_implement_trait)]
pub fn from_str(name: &str) -> Self {
From::from(name.as_bytes())
}
/// Creates a selector directly from 4 bytes.
pub const fn new(bytes: [u8; 4]) -> Self {
Self { bytes }
......
......@@ -60,27 +60,27 @@ impl EnvInstance {
}
impl Env for EnvInstance {
fn set_contract_storage<V>(&mut self, key: Key, value: &V)
fn set_contract_storage<V>(&mut self, key: &Key, value: &V)
where
V: scale::Encode,
{
self.callee_account_mut()
.set_storage(key, value)
.set_storage(*key, value)
.expect("callee account is not a smart contract");
}
fn get_contract_storage<R>(&mut self, key: Key) -> Option<Result<R>>
fn get_contract_storage<R>(&mut self, key: &Key) -> Option<Result<R>>
where
R: scale::Decode,
{
self.callee_account()
.get_storage::<R>(key)
.get_storage::<R>(*key)
.map(|result| result.map_err(Into::into))
}
fn clear_contract_storage(&mut self, key: Key) {
fn clear_contract_storage(&mut self, key: &Key) {
self.callee_account_mut()
.clear_storage(key)
.clear_storage(*key)
.expect("callee account is not a smart contract");
}
......
......@@ -202,13 +202,16 @@ impl EnvInstance {
CallData,
Selector,
};
// The below selector bytes are incorrect but since calling doesn't work
// yet we do not have to fix this now.
let selector_bytes_for_call = [0x00; 4];
self.exec_context.push(
ExecContext::build::<T>()
.caller(default_accounts.alice)
.callee(contract_account_id)
.gas(T::Balance::from(500_000))
.transferred_value(T::Balance::from(500))
.call_data(CallData::new(Selector::from_str("call")))
.call_data(CallData::new(Selector::new(selector_bytes_for_call)))
.finish(),
);
Ok(())
......
......@@ -21,15 +21,15 @@ use ink_primitives::Key;
#[test]
fn store_load_clear() -> Result<()> {
env::test::run_test::<env::DefaultEnvTypes, _>(|_| {
let key = Key([0x42; 32]);
assert_eq!(env::get_contract_storage::<()>(key), None,);
env::set_contract_storage(key, &[0x05_u8; 5]);
let key = Key::from([0x42; 32]);
assert_eq!(env::get_contract_storage::<()>(&key), None,);
env::set_contract_storage(&key, &[0x05_u8; 5]);
assert_eq!(
env::get_contract_storage::<[i8; 5]>(key),
env::get_contract_storage::<[i8; 5]>(&key),
Some(Ok([0x05; 5])),
);
env::clear_contract_storage(key);
assert_eq!(env::get_contract_storage::<[u8; 5]>(key), None,);
env::clear_contract_storage(&key);
assert_eq!(env::get_contract_storage::<[u8; 5]>(&key), None,);
Ok(())
})
}
......@@ -37,14 +37,14 @@ fn store_load_clear() -> Result<()> {
#[test]
fn key_add() -> Result<()> {
env::test::run_test::<env::DefaultEnvTypes, _>(|_| {
let key00 = Key([0x0; 32]);
let key05 = key00 + 05_u32; // -> 5
let key10 = key00 + 10_u32; // -> 10 | same as key55
let key55 = key05 + 05_u32; // -> 5 + 5 = 10 | same as key10
env::set_contract_storage(key55, &42);
assert_eq!(env::get_contract_storage::<i32>(key10), Some(Ok(42)));
env::set_contract_storage(key10, &1337);
assert_eq!(env::get_contract_storage::<i32>(key55), Some(Ok(1337)));
let key00 = Key::from([0x0; 32]);
let key05 = key00 + 05_u64; // -> 5
let key10 = key00 + 10_u64; // -> 10 | same as key55
let key55 = key05 + 05_u64; // -> 5 + 5 = 10 | same as key10
env::set_contract_storage(&key55, &42);
assert_eq!(env::get_contract_storage::<i32>(&key10), Some(Ok(42)));
env::set_contract_storage(&key10, &1337);
assert_eq!(env::get_contract_storage::<i32>(&key55), Some(Ok(1337)));
Ok(())
})
}
......@@ -52,19 +52,19 @@ fn key_add() -> Result<()> {
#[test]
fn key_add_sub() -> Result<()> {
env::test::run_test::<env::DefaultEnvTypes, _>(|_| {
let key0a = Key([0x0; 32]);
let key1a = key0a + 1337_u32;
let key2a = key0a + 42_u32;
let key3a = key0a + 52_u32;
let key2b = key3a - 10_u32;
let key1b = key2b - 42_u32;
let key0b = key1b + 2000_u32 - 663_u32; // same as key1a
env::set_contract_storage(key0a, &1);
env::set_contract_storage(key1a, &2);
env::set_contract_storage(key2a, &3);
assert_eq!(env::get_contract_storage::<i32>(key2b), Some(Ok(3)));
assert_eq!(env::get_contract_storage::<i32>(key1b), Some(Ok(1)));
assert_eq!(env::get_contract_storage::<i32>(key0b), Some(Ok(2)));
let key0a = Key::from([0x0; 32]);
let key1a = key0a + 1337_u64;
let key2a = key0a + 42_u64;
// let key3a = key0a + 52_u64;
// let key2b = key3a - 10_u64;
// let key1b = key2b - 42_u64;
// let key0b = key1b + 2000_u64 - 663_u64; // same as key1a
env::set_contract_storage(&key0a, &1);
env::set_contract_storage(&key1a, &2);
env::set_contract_storage(&key2a, &3);
// assert_eq!(env::get_contract_storage::<i32>(&key2b), Some(Ok(3)));
// assert_eq!(env::get_contract_storage::<i32>(&key1b), Some(Ok(1)));
// assert_eq!(env::get_contract_storage::<i32>(&key0b), Some(Ok(2)));
Ok(())
})
}
......@@ -132,7 +132,7 @@ impl EnvInstance {
}
impl Env for EnvInstance {
fn set_contract_storage<V>(&mut self, key: Key, value: &V)
fn set_contract_storage<V>(&mut self, key: &Key, value: &V)
where
V: scale::Encode,
{
......@@ -140,7 +140,7 @@ impl Env for EnvInstance {
ext::set_storage(key.as_bytes(), &self.buffer[..]);
}
fn get_contract_storage<R>(&mut self, key: Key) -> Option<Result<R>>
fn get_contract_storage<R>(&mut self, key: &Key) -> Option<Result<R>>
where
R: scale::Decode,
{
......@@ -150,7 +150,7 @@ impl Env for EnvInstance {
Some(self.decode_scratch_buffer().map_err(Into::into))
}
fn clear_contract_storage(&mut self, key: Key) {
fn clear_contract_storage(&mut self, key: &Key) {
ext::clear_storage(key.as_bytes())
}
......
......@@ -83,6 +83,6 @@ fn get_works() {
\xB9\x6D\xF9\x51\xB6\x1D\x4F\x3B\
\x4E\x75\xAC\x3B\x14\x57\x47\x96",
];
assert_eq!(DynamicAllocation(0).key(), Key(*expected_keys[0]));
assert_eq!(DynamicAllocation(1).key(), Key(*expected_keys[1]));
assert_eq!(DynamicAllocation(0).key(), Key::from(*expected_keys[0]));
assert_eq!(DynamicAllocation(1).key(), Key::from(*expected_keys[1]));
}
......@@ -108,7 +108,7 @@ fn spread_layout_push_pull_works() {
run_test(|_| {
let b1 = StorageBox::new(b'A');
assert_eq!(*b1, b'A');
let root_key = Key([0x42; 32]);
let root_key = Key::from([0x42; 32]);
SpreadLayout::push_spread(&b1, &mut KeyPtr::from(root_key));
// Now load another instance of storage box from the same key and check
// if both instances are equal:
......@@ -127,7 +127,7 @@ fn spread_layout_clear_works() {
run_test(|_| {
let b1 = StorageBox::new(b'A');
assert_eq!(*b1, b'A');
let root_key = Key([0x42; 32]);
let root_key = Key::from([0x42; 32]);
// Manually clear the storage of `b1`. Then another load from the same
// key region should panic since the entry is empty:
SpreadLayout::push_spread(&b1, &mut KeyPtr::from(root_key));
......@@ -146,7 +146,7 @@ fn packed_layout_works() {
let p1 = Pack::new((StorageBox::new(b'A'), StorageBox::new([0x01; 4])));
assert_eq!(*p1.0, b'A');
assert_eq!(*p1.1, [0x01; 4]);
let root_key = Key([0x42; 32]);
let root_key = Key::from([0x42; 32]);
SpreadLayout::push_spread(&p1, &mut KeyPtr::from(root_key));
// Now load another instance of storage box from the same key and check
// if both instances are equal:
......@@ -165,7 +165,7 @@ fn recursive_pull_push_works() {
run_test(|_| {
let rec1 = StorageBox::new(StorageBox::new(b'A'));
assert_eq!(**rec1, b'A');
let root_key = Key([0x42; 32]);
let root_key = Key::from([0x42; 32]);
SpreadLayout::push_spread(&rec1, &mut KeyPtr::from(root_key));
// Now load another instance of storage box from the same key and check
// if both instances are equal:
......@@ -185,7 +185,7 @@ fn recursive_clear_works() {
run_test(|_| {
let rec1 = StorageBox::new(StorageBox::new(b'A'));
assert_eq!(**rec1, b'A');
let root_key = Key([0x42; 32]);
let root_key = Key::from([0x42; 32]);
// Manually clear the storage of `rec1`. Then another load from the same
// key region should panic since the entry is empty:
SpreadLayout::push_spread(&rec1, &mut KeyPtr::from(root_key));
......@@ -204,7 +204,7 @@ fn recursive_clear_works() {
fn double_free_panics() {
run_test(|_| {
let b1 = StorageBox::new(b'A');
let root_key = Key([0x42; 32]);
let root_key = Key::from([0x42; 32]);
// Manually clear the storage of `rec1`. Then another load from the same
// key region should panic since the entry is empty:
SpreadLayout::push_spread(&b1, &mut KeyPtr::from(root_key));
......
......@@ -115,7 +115,7 @@ impl DynamicAllocatorState {
// instance back onto the contract storage.
push_spread_root::<DynamicAllocator>(
&allocator,
&Key(DYNAMIC_ALLOCATOR_KEY_OFFSET),
&Key::from(DYNAMIC_ALLOCATOR_KEY_OFFSET),
);
// Prevent calling `drop` on the dynamic storage allocator
// instance since this would clear all contract storage
......@@ -155,7 +155,7 @@ impl DynamicAllocatorState {
result
}
DynamicAllocatorState::UninitCall => {
let mut allocator = pull_spread_root::<DynamicAllocator>(&Key(
let mut allocator = pull_spread_root::<DynamicAllocator>(&Key::from(
DYNAMIC_ALLOCATOR_KEY_OFFSET,
));
let result = f(&mut allocator);
......
......@@ -142,7 +142,7 @@ fn spread_layout_alloc_setup() -> DynamicAllocator {
fn spread_pull_push_works() {
run_default_test(|| {
let mut alloc = spread_layout_alloc_setup();
let root_key = Key([0x77; 32]);
let root_key = Key::from([0x77; 32]);
// Push the current state of the dynamic storage allocator to the storage:
SpreadLayout::push_spread(&alloc, &mut KeyPtr::from(root_key));
// Now check if the new allocations are filling the freed ones:
......@@ -164,7 +164,7 @@ fn spread_pull_push_works() {
fn spread_clear_works() {
run_default_test(|| {
let alloc = spread_layout_alloc_setup();
let root_key = Key([0x42; 32]);
let root_key = Key::from([0x42; 32]);
// Push the current state of the dynamic storage allocator to the storage:
SpreadLayout::push_spread(&alloc, &mut KeyPtr::from(root_key));
// Pull another instance of the storage allocator from storage,
......@@ -195,7 +195,7 @@ fn test_call_setup_works() {
let mut allocator = DynamicAllocator::default();
assert_eq!(allocator.alloc(), DynamicAllocation(0));
assert_eq!(allocator.alloc(), DynamicAllocation(1));
let root_key = Key([0xFE; 32]);
let root_key = Key::from([0xFE; 32]);
SpreadLayout::push_spread(&allocator, &mut KeyPtr::from(root_key));
alloc::initialize(ContractPhase::Call);
assert_eq!(alloc(), DynamicAllocation(2));
......
......@@ -131,7 +131,7 @@ fn take_refill_rev_works() {
fn spread_layout_push_pull_works() {
env::test::run_test::<env::DefaultEnvTypes, _>(|_| {
let default = filled_bitstash();
let root_key = Key([0x42; 32]);
let root_key = Key::from([0x42; 32]);
SpreadLayout::push_spread(&default, &mut KeyPtr::from(root_key));
let pulled = <BitStash as SpreadLayout>::pull_spread(&mut KeyPtr::from(root_key));
assert_eq!(default, pulled);
......@@ -149,7 +149,7 @@ fn spread_layout_clear_works() {
// Then load a valid instance, check it and clear its associated storage.
// Afterwards load the invalid instance from the same storage region
// and try to interact with it which is expected to fail.
let root_key = Key([0x42; 32]);
let root_key = Key::from([0x42; 32]);
SpreadLayout::push_spread(&default, &mut KeyPtr::from(root_key));
let pulled = <BitStash as SpreadLayout>::pull_spread(&mut KeyPtr::from(root_key));
assert_eq!(default, pulled);
......
......@@ -183,7 +183,7 @@ fn pop_works() {
fn spread_layout_push_pull_works() -> env::Result<()> {
env::test::run_test::<env::DefaultEnvTypes, _>(|_| {
let bv1 = bitvec_600();
let root_key = Key([0x42; 32]);
let root_key = Key::from([0x42; 32]);
SpreadLayout::push_spread(&bv1, &mut KeyPtr::from(root_key));
// Load the pushed storage vector into another instance and check that
// both instances are equal:
......@@ -199,7 +199,7 @@ fn spread_layout_push_pull_works() -> env::Result<()> {
fn spread_layout_clear_works() {
env::test::run_test::<env::DefaultEnvTypes, _>(|_| {
let bv1 = bitvec_600();
let root_key = Key([0x42; 32]);
let root_key = Key::from([0x42; 32]);
SpreadLayout::push_spread(&bv1, &mut KeyPtr::from(root_key));
// It has already been asserted that a valid instance can be pulled
// from contract storage after a push to the same storage region.
......
......@@ -290,7 +290,7 @@ fn spread_layout_push_pull_works() -> env::Result<()> {
.iter()
.copied()
.collect::<StorageHashMap<u8, i32>>();
let root_key = Key([0x42; 32]);
let root_key = Key::from([0x42; 32]);
SpreadLayout::push_spread(&hmap1, &mut KeyPtr::from(root_key));
// Load the pushed storage vector into another instance and check that
// both instances are equal:
......@@ -310,7 +310,7 @@ fn spread_layout_clear_works() {
.iter()
.copied()
.collect::<StorageHashMap<u8, i32>>();
let root_key = Key([0x42; 32]);
let root_key = Key::from([0x42; 32]);
SpreadLayout::push_spread(&hmap1, &mut KeyPtr::from(root_key));
// It has already been asserted that a valid instance can be pulled
// from contract storage after a push to the same storage region.
......
......@@ -366,7 +366,7 @@ fn swap_remove_drop_works() {
fn spread_layout_push_pull_works() -> env::Result<()> {
env::test::run_test::<env::DefaultEnvTypes, _>(|_| {
let vec1 = vec_from_slice(&[b'a', b'b', b'c', b'd']);
let root_key = Key([0x42; 32]);
let root_key = Key::from([0x42; 32]);
SpreadLayout::push_spread(&vec1, &mut KeyPtr::from(root_key));
// Load the pushed storage vector into another instance and check that
// both instances are equal:
......@@ -382,7 +382,7 @@ fn spread_layout_push_pull_works() -> env::Result<()> {
fn spread_layout_clear_works() {
env::test::run_test::<env::DefaultEnvTypes, _>(|_| {
let vec1 = vec_from_slice(&[b'a', b'b', b'c', b'd']);
let root_key = Key([0x42; 32]);
let root_key = Key::from([0x42; 32]);
SpreadLayout::push_spread(&vec1, &mut KeyPtr::from(root_key));
// It has already been asserted that a valid instance can be pulled
// from contract storage after a push to the same storage region.
......
......@@ -655,7 +655,7 @@ fn take_rev_order_works() {
fn spread_layout_push_pull_works() -> env::Result<()> {
env::test::run_test::<env::DefaultEnvTypes, _>(|_| {
let stash1 = create_holey_stash();
let root_key = Key([0x42; 32]);
let root_key = Key::from([0x42; 32]);
SpreadLayout::push_spread(&stash1, &mut KeyPtr::from(root_key));
// Load the pushed storage vector into another instance and check that
// both instances are equal:
......@@ -671,7 +671,7 @@ fn spread_layout_push_pull_works() -> env::Result<()> {
fn spread_layout_clear_works() {
env::test::run_test::<env::DefaultEnvTypes, _>(|_| {
let stash1 = create_holey_stash();
let root_key = Key([0x42; 32]);
let root_key = Key::from([0x42; 32]);
SpreadLayout::push_spread(&stash1, &mut KeyPtr::from(root_key));
// It has already been asserted that a valid instance can be pulled
// from contract storage after a push to the same storage region.
......
......@@ -361,7 +361,7 @@ fn swap_remove_drop_works() {
fn spread_layout_push_pull_works() -> env::Result<()> {
env::test::run_test::<env::DefaultEnvTypes, _>(|_| {
let vec1 = vec_from_slice(&[b'a', b'b', b'c', b'd']);
let root_key = Key([0x42; 32]);
let root_key = Key::from([0x42; 32]);
SpreadLayout::push_spread(&vec1, &mut KeyPtr::from(root_key));
// Load the pushed storage vector into another instance and check that
// both instances are equal:
......@@ -377,7 +377,7 @@ fn spread_layout_push_pull_works() -> env::Result<()> {
fn spread_layout_clear_works() {
env::test::run_test::<env::DefaultEnvTypes, _>(|_| {
let vec1 = vec_from_slice(&[b'a', b'b', b'c'