1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
pub mod abi_json;
pub mod api;
mod async_data;
mod blockchain_mock;
mod contract_map;
mod display_util;
mod execute_mandos;
mod mock_error;
mod tx_context;
pub use async_data::*;
pub use blockchain_mock::*;
pub use contract_map::*;
pub use display_util::*;
pub use execute_mandos::*;
pub use mock_error::*;
pub use tx_context::*;
#[macro_use]
extern crate alloc;
pub use alloc::boxed::Box;
pub use alloc::vec::Vec;
pub use std::collections::HashMap;
#[cfg(test)]
mod elrond_codec_tests {
use crate::api::{RustBigInt, RustBigUint};
use core::fmt::Debug;
use elrond_wasm::elrond_codec::test_util::{check_top_decode, check_top_encode};
use elrond_wasm::elrond_codec::*;
pub fn ser_deser_ok<V>(element: V, expected_bytes: &[u8])
where
V: TopEncode + TopDecode + PartialEq + Debug + 'static,
{
let serialized_bytes = check_top_encode(&element);
assert_eq!(serialized_bytes.as_slice(), expected_bytes);
let deserialized: V = check_top_decode::<V>(&serialized_bytes[..]);
assert_eq!(deserialized, element);
}
#[test]
fn test_big_int_serialization() {
ser_deser_ok(RustBigInt::from(5), &[5u8]);
ser_deser_ok(RustBigInt::from(-5), &[251u8]);
}
#[test]
fn test_big_uint_serialization() {
ser_deser_ok(RustBigUint::from(5u32), &[5u8]);
}
}