Skip to content

Commit

Permalink
test fix and small error message adjustment
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaicalinluca committed Jun 26, 2024
1 parent ff2644e commit c3813a6
Show file tree
Hide file tree
Showing 12 changed files with 503 additions and 276 deletions.
726 changes: 488 additions & 238 deletions contracts/core/price-aggregator/scenarios/stress_submit_test.scen.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"expect": {
"out": [],
"status": "4",
"message": "str:storage decode error: input too long",
"message": "str:storage decode error (key: opt_addr): input too long",
"logs": "*",
"gas": "*",
"refund": "*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"expect": {
"out": [],
"status": "4",
"message": "str:storage decode error: deliberate top decode error"
"message": "str:storage decode error (key: load_with_value_err): deliberate top decode error"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"expect": {
"out": [],
"status": "*",
"message": "str:storage decode error: argument out of range",
"message": "str:storage decode error (key: i64): argument out of range",
"logs": "*",
"gas": "*",
"refund": "*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"expect": {
"out": [],
"status": "4",
"message": "str:storage decode error: input too long",
"message": "str:storage decode error (key: opt_addr): input too long",
"logs": "*",
"gas": "*",
"refund": "*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"expect": {
"out": [],
"status": "4",
"message": "str:storage decode error: input too long",
"message": "str:storage decode error (key: u64): input too long",
"logs": "*",
"gas": "*",
"refund": "*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"expect": {
"out": [],
"status": "4",
"message": "str:storage decode error: input too long",
"message": "str:storage decode error (key: usize): input too long",
"logs": "*",
"gas": "*",
"refund": "*"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,6 @@
}
}
},
{
"step": "setState",
"accounts": {
"0x00000000000000006c8fc18b8e9f8e20089714856ee233b3902a591d0d5f2925": {
"nonce": "0",
"balance": "0",
"esdt": {
"str:COOL-123456": {
"instances": [
{
"nonce": "0",
"balance": "1000",
"royalties": "0",
"attributes": "0x"
}
]
}
},
"code": "file:../output/rust-testing-framework-tester.wasm",
"codeMetadata": "0x0506",
"developerRewards": "0"
}
}
},
{
"step": "checkState",
"accounts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use core::marker::PhantomData;

use unwrap_infallible::UnwrapInfallible;

use crate::api::HandleConstraints;
use crate::codec::{TopDecode, TopEncode};

use crate::{
Expand Down Expand Up @@ -67,7 +68,7 @@ where

V::top_decode_or_handle_err(
result_buffer,
StorageGetErrorHandler::<A>::new(key.get_raw_handle()),
StorageGetErrorHandler::<A>::new(key.get_handle().get_raw_handle_unchecked()),
)
.unwrap_infallible()
}
Expand Down
3 changes: 2 additions & 1 deletion framework/base/src/err_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ pub const ARG_BAD_LENGTH_32: &str = "argument has wrong length: 32 bytes expecte
pub const ARG_DECODE_ERROR_1: &str = "argument decode error (";
pub const ARG_DECODE_ERROR_2: &str = "): ";
pub const STORAGE_VALUE_OUT_OF_RANGE: &str = "storage value out of range";
pub const STORAGE_DECODE_ERROR: &str = "storage decode error: ";
pub const STORAGE_DECODE_ERROR_1: &str = "storage decode error (key: ";
pub const STORAGE_DECODE_ERROR_2: &str = "): ";
pub const STORAGE_ENCODE_ERROR: &str = "storage encode error: ";
pub const STORAGE_KEY_ENCODE_ERROR: &str = "storage key encode error: ";
pub const STORAGE_VALUE_EXCEEDS_BUFFER: &str = "storage value exceeds buffer";
Expand Down
6 changes: 3 additions & 3 deletions framework/base/src/storage/storage_get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ where

fn handle_error(&self, err: DecodeError) -> Self::HandledErr {
let mut message_buffer =
ManagedBuffer::<M>::new_from_bytes(err_msg::STORAGE_DECODE_ERROR.as_bytes());
message_buffer.append_bytes(err.message_bytes());
message_buffer.append_bytes(b"at key: ");
ManagedBuffer::<M>::new_from_bytes(err_msg::STORAGE_DECODE_ERROR_1.as_bytes());
M::managed_type_impl().mb_append(message_buffer.get_handle(), self.key.into());
message_buffer.append_bytes(err_msg::STORAGE_DECODE_ERROR_2.as_bytes());
message_buffer.append_bytes(err.message_bytes());
M::error_api_impl().signal_error_from_buffer(message_buffer.get_handle())
}
}
5 changes: 2 additions & 3 deletions framework/base/src/storage/storage_get_from_address.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::{
api::{
const_handles, use_raw_handle, ErrorApi, ManagedBufferApiImpl, ManagedTypeApi,
StaticVarApiImpl, StorageReadApi, StorageReadApiImpl,
const_handles, use_raw_handle, ErrorApi, HandleConstraints, ManagedBufferApiImpl, ManagedTypeApi, StaticVarApiImpl, StorageReadApi, StorageReadApiImpl
},
codec::*,
types::{
Expand Down Expand Up @@ -148,7 +147,7 @@ where
T: TopDecode,
A: StorageReadApi + ManagedTypeApi + ErrorApi,
{
let handle = key.get_raw_handle();
let handle = key.get_handle().get_raw_handle_unchecked();
T::top_decode_or_handle_err(
StorageGetFromAddressInput::new(addr, key),
StorageGetErrorHandler::<A>::new(handle),
Expand Down

0 comments on commit c3813a6

Please sign in to comment.