Skip to content

Commit

Permalink
scrypto 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasz2891 committed Nov 28, 2024
1 parent 76c76b8 commit 296ce7d
Show file tree
Hide file tree
Showing 18 changed files with 77 additions and 76 deletions.
16 changes: 8 additions & 8 deletions src/core/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,14 @@ fn make_value_signer_matrix(config: &Config, data_packages: Vec<DataPackage>) ->
#[cfg(feature = "helpers")]
#[cfg(test)]
mod aggregate_matrix_tests {
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[cfg(not(target_arch = "wasm32"))]
use test as test;
use crate::{
core::{aggregator::aggregate_matrix, config::Config},
helpers::iter_into::{IterInto, IterIntoOpt, OptIterIntoOpt},
};
#[cfg(not(target_arch = "wasm32"))]
use test;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;

#[test]
fn test_aggregate_matrix() {
Expand Down Expand Up @@ -147,10 +147,6 @@ mod aggregate_matrix_tests {
#[cfg(feature = "helpers")]
#[cfg(test)]
mod make_value_signer_matrix {
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[cfg(not(target_arch = "wasm32"))]
use test as test;
use crate::{
core::{
aggregator::{make_value_signer_matrix, Matrix},
Expand All @@ -161,6 +157,10 @@ mod make_value_signer_matrix {
network::specific::U256,
protocol::data_package::DataPackage,
};
#[cfg(not(target_arch = "wasm32"))]
use test;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;

#[test]
fn test_make_value_signer_matrix_empty() {
Expand Down
8 changes: 4 additions & 4 deletions src/core/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ fn make_processor_result(config: Config, payload: Payload) -> ProcessorResult {
#[cfg(feature = "helpers")]
#[cfg(test)]
mod tests {
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[cfg(not(target_arch = "wasm32"))]
use test as test;
use crate::{
core::{
config::Config,
Expand All @@ -62,6 +58,10 @@ mod tests {
helpers::iter_into::IterInto,
protocol::{data_package::DataPackage, payload::Payload},
};
#[cfg(not(target_arch = "wasm32"))]
use test;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;

#[test]
fn test_make_processor_result() {
Expand Down
8 changes: 4 additions & 4 deletions src/core/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,6 @@ impl Validator for Config {
#[cfg(feature = "helpers")]
#[cfg(test)]
mod tests {
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[cfg(not(target_arch = "wasm32"))]
use test as test;
use crate::{
core::{
config::Config,
Expand All @@ -138,6 +134,10 @@ mod tests {
protocol::constants::{MAX_TIMESTAMP_AHEAD_MS, MAX_TIMESTAMP_DELAY_MS},
};
use itertools::Itertools;
#[cfg(not(target_arch = "wasm32"))]
use test;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;

#[test]
fn test_feed_index() {
Expand Down
6 changes: 3 additions & 3 deletions src/crypto/keccak256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ pub fn keccak256(data: &[u8]) -> Keccak256Hash {
#[cfg(feature = "helpers")]
#[cfg(test)]
mod tests {
use crate::{crypto::keccak256::keccak256, helpers::hex::hex_to_bytes};
#[cfg(not(target_arch = "wasm32"))]
use test;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[cfg(not(target_arch = "wasm32"))]
use test as test;
use crate::{crypto::keccak256::keccak256, helpers::hex::hex_to_bytes};

const MESSAGE: &str = "415641580000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d394303d018d79bf0ba000000020000001";
const MESSAGE_HASH: &str = "f0805644755393876d0e917e553f0c206f8bc68b7ebfe73a79d2a9e7f5a4cea6";
Expand Down
8 changes: 4 additions & 4 deletions src/crypto/recover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,14 @@ pub(crate) mod crypto256 {
#[cfg(feature = "helpers")]
#[cfg(test)]
mod tests {
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[cfg(not(target_arch = "wasm32"))]
use test as test;
use crate::{
crypto::recover::{crypto256::recover_public_key, recover_address},
helpers::hex::hex_to_bytes,
};
#[cfg(not(target_arch = "wasm32"))]
use test;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;

const MESSAGE: &str = "415641580000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000d394303d018d79bf0ba000000020000001";
const MESSAGE_HASH: &str = "f0805644755393876d0e917e553f0c206f8bc68b7ebfe73a79d2a9e7f5a4cea6";
Expand Down
8 changes: 4 additions & 4 deletions src/helpers/iter_into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ impl<U: Copy, T: Copy + Into<U>> IterIntoOpt<Vec<Option<U>>> for Vec<T> {

#[cfg(test)]
mod iter_into_tests {
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[cfg(not(target_arch = "wasm32"))]
use test as test;
use crate::{
helpers::iter_into::{IterInto, IterIntoOpt, OptIterIntoOpt},
network::specific::U256,
};
#[cfg(not(target_arch = "wasm32"))]
use test;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;

#[test]
fn test_iter_into() {
Expand Down
8 changes: 4 additions & 4 deletions src/network/as_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ impl AsAsciiStr for U256 {

#[cfg(test)]
mod tests {
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[cfg(not(target_arch = "wasm32"))]
use test as test;
use crate::network::{
as_str::{AsAsciiStr, AsHexStr},
specific::U256,
};
#[cfg(not(target_arch = "wasm32"))]
use test;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;

const ETH: u32 = 4543560u32;

Expand Down
14 changes: 7 additions & 7 deletions src/network/assert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ where

#[cfg(test)]
mod assert_or_revert_tests {
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[cfg(not(target_arch = "wasm32"))]
use test as test;
use crate::network::{
assert::{assert_or_revert_bool_with, Assert},
error::Error,
};
#[cfg(not(target_arch = "wasm32"))]
use test;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;

#[test]
fn test_assert_or_revert_bool_with_true() {
Expand All @@ -110,11 +110,11 @@ mod assert_or_revert_tests {

#[cfg(test)]
mod unwrap_or_revert_tests {
use crate::network::{assert::Unwrap, error::Error};
#[cfg(not(target_arch = "wasm32"))]
use test;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[cfg(not(target_arch = "wasm32"))]
use test as test;
use crate::network::{assert::Unwrap, error::Error};

#[test]
fn test_unwrap_or_revert_some() {
Expand Down
6 changes: 3 additions & 3 deletions src/network/flattened.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ impl Flattened<Bytes> for Vec<Bytes> {

#[cfg(test)]
mod tests {
use crate::network::{flattened::Flattened, specific::Bytes};
#[cfg(not(target_arch = "wasm32"))]
use test;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[cfg(not(target_arch = "wasm32"))]
use test as test;
use crate::network::{flattened::Flattened, specific::Bytes};

#[test]
fn test_bytes_flattened() {
Expand Down
8 changes: 4 additions & 4 deletions src/network/from_bytes_repr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ impl Sanitized for Vec<u8> {

#[cfg(test)]
mod tests {
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[cfg(not(target_arch = "wasm32"))]
use test as test;
use crate::network::{
from_bytes_repr::FromBytesRepr,
specific::{U256, VALUE_SIZE},
};
#[cfg(not(target_arch = "wasm32"))]
use test;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;

#[cfg(feature = "network_radix")]
use crate::network::radix::u256_ext::U256Ext;
Expand Down
8 changes: 4 additions & 4 deletions src/protocol/data_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ impl Debug for DataPackage {
#[cfg(feature = "helpers")]
#[cfg(test)]
mod tests {
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[cfg(not(target_arch = "wasm32"))]
use test as test;
use crate::{
helpers::hex::hex_to_bytes,
network::{from_bytes_repr::FromBytesRepr, specific::U256},
Expand All @@ -85,6 +81,10 @@ mod tests {
data_point::DataPoint,
},
};
#[cfg(not(target_arch = "wasm32"))]
use test;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;

const DATA_PACKAGE_BYTES_1: &str = "4554480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000360cafc94e018d79bf0ba00000002000000151afa8c5c3caf6004b42c0fb17723e524f993b9ecbad3b9bce5ec74930fa436a3660e8edef10e96ee5f222de7ef5787c02ca467c0ec18daa2907b43ac20c63c11c";
const DATA_PACKAGE_BYTES_2: &str = "4554480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000360cdd851e018d79bf0ba000000020000001473fd9dc72e6814a7de719b403cf4c9eba08934a643fd0666c433b806b31e69904f2226ffd3c8ef75861b11b5e32a1fda4b1458e0da4605a772dfba2a812f3ee1b";
Expand Down
8 changes: 4 additions & 4 deletions src/protocol/data_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ impl Debug for DataPoint {
#[cfg(feature = "helpers")]
#[cfg(test)]
mod tests {
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[cfg(not(target_arch = "wasm32"))]
use test as test;
use crate::{
helpers::hex::hex_to_bytes,
network::{
Expand All @@ -75,6 +71,10 @@ mod tests {
},
};
use std::ops::Shr;
#[cfg(not(target_arch = "wasm32"))]
use test;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;

const DATA_POINT_BYTES_TAIL: &str = "4554480000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000360cafc94e";
const VALUE: u128 = 232141080910;
Expand Down
8 changes: 4 additions & 4 deletions src/protocol/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ pub fn trim_redstone_marker(payload: &mut Vec<u8>) {
#[cfg(feature = "helpers")]
#[cfg(test)]
mod tests {
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[cfg(not(target_arch = "wasm32"))]
use test as test;
use crate::{
helpers::hex::hex_to_bytes,
protocol::{constants::REDSTONE_MARKER_BS, marker::trim_redstone_marker},
};
#[cfg(not(target_arch = "wasm32"))]
use test;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;

const PAYLOAD_TAIL: &str = "1c000f000000000002ed57011e0000";

Expand Down
8 changes: 4 additions & 4 deletions src/protocol/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ fn trim_metadata(payload: &mut Vec<u8>) -> usize {
#[cfg(feature = "helpers")]
#[cfg(test)]
mod tests {
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[cfg(not(target_arch = "wasm32"))]
use test as test;
use crate::{
helpers::hex::{hex_to_bytes, read_payload_bytes, read_payload_hex},
protocol::{
constants::REDSTONE_MARKER_BS,
payload::{trim_metadata, trim_payload, Payload},
},
};
#[cfg(not(target_arch = "wasm32"))]
use test;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;

const PAYLOAD_METADATA_BYTES: &str = "000f000000";
const PAYLOAD_METADATA_WITH_UNSIGNED_BYTE: &str = "000f55000001";
Expand Down
6 changes: 3 additions & 3 deletions src/utils/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ impl<T: Copy> FilterSome<Vec<T>> for [Option<T>] {

#[cfg(test)]
mod filter_some_tests {
use crate::utils::filter::FilterSome;
#[cfg(not(target_arch = "wasm32"))]
use test;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[cfg(not(target_arch = "wasm32"))]
use test as test;
use crate::utils::filter::FilterSome;

#[test]
fn test_filter_some() {
Expand Down
8 changes: 4 additions & 4 deletions src/utils/median.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ where

#[cfg(test)]
mod tests {
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[cfg(not(target_arch = "wasm32"))]
use test as test;
use super::{Avg, Median};
use crate::network::specific::U256;
use itertools::Itertools;
use std::fmt::Debug;
#[cfg(not(target_arch = "wasm32"))]
use test;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;

#[cfg(feature = "network_radix")]
use crate::network::radix::u256_ext::U256Ext;
Expand Down
11 changes: 6 additions & 5 deletions src/utils/trim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ impl Trim<u64> for Vec<u8> {

#[cfg(test)]
mod tests {
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[cfg(not(target_arch = "wasm32"))]
use test as test;
use crate::{
network::specific::U256,
protocol::constants::{REDSTONE_MARKER, REDSTONE_MARKER_BS},
utils::trim::Trim,
};
#[cfg(not(target_arch = "wasm32"))]
use test;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;

const MARKER_DECIMAL: u64 = 823907890102272;

Expand Down Expand Up @@ -108,7 +108,8 @@ mod tests {
let (_, result): (_, u64) = test_trim_end(size);
assert_eq!(result, MARKER_DECIMAL);

#[cfg(not(target_arch = "wasm32"))] {
#[cfg(not(target_arch = "wasm32"))]
{
let (_, result): (_, usize) = test_trim_end(size);
assert_eq!(result, 823907890102272usize);
}
Expand Down
6 changes: 3 additions & 3 deletions src/utils/trim_zeros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ impl TrimZeros for Vec<u8> {

#[cfg(test)]
mod tests {
use crate::{protocol::constants::REDSTONE_MARKER, utils::trim_zeros::TrimZeros};
#[cfg(not(target_arch = "wasm32"))]
use test;
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::wasm_bindgen_test as test;
#[cfg(not(target_arch = "wasm32"))]
use test as test;
use crate::{protocol::constants::REDSTONE_MARKER, utils::trim_zeros::TrimZeros};

fn redstone_marker_bytes() -> Vec<u8> {
REDSTONE_MARKER.as_slice().into()
Expand Down

0 comments on commit 296ce7d

Please sign in to comment.