radix_engine/blueprints/test_utils/
package.rs1use crate::errors::ApplicationError;
2use crate::errors::RuntimeError;
3use crate::internal_prelude::*;
4use radix_engine_interface::api::SystemApi;
5use radix_engine_interface::blueprints::package::PackageDefinition;
6use radix_engine_interface::blueprints::test_utils::*;
7
8use super::TestUtilsBlueprint;
9
10pub struct TestUtilsNativePackage;
11
12impl TestUtilsNativePackage {
13 pub fn definition() -> PackageDefinition {
14 PackageDefinition {
15 blueprints: indexmap! {
16 TEST_UTILS_BLUEPRINT.to_owned() => TestUtilsBlueprint::get_definition()
17 },
18 }
19 }
20
21 pub fn invoke_export<Y: SystemApi<RuntimeError>>(
22 export_name: &str,
23 input: &IndexedScryptoValue,
24 api: &mut Y,
25 ) -> Result<IndexedScryptoValue, RuntimeError> {
26 match export_name {
27 TEST_UTILS_PANIC_IDENT => {
28 let TestUtilsPanicInput(input) = input.as_typed().map_err(|e| {
29 RuntimeError::ApplicationError(ApplicationError::InputDecodeError(e))
30 })?;
31 let rtn = TestUtilsBlueprint::panic(input.as_str(), api)?;
32 Ok(IndexedScryptoValue::from_typed(&rtn))
33 }
34 _ => Err(RuntimeError::ApplicationError(
35 ApplicationError::ExportDoesNotExist(export_name.to_string()),
36 )),
37 }
38 }
39}