Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update metadata tests to use compiled assets #1797

Merged
merged 1 commit into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions radix-engine-tests/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,6 @@ pub mod path_macros {
};
}

#[macro_export]
macro_rules! path_workspace_blueprint {
($package: expr, $name: expr) => {
concat!(
env!("CARGO_MANIFEST_DIR"),
"/../",
$package,
"/assets/blueprints/",
$name
)
};
}

#[macro_export]
macro_rules! path_workspace_transaction_examples {
($name: expr) => {
Expand Down Expand Up @@ -126,7 +113,6 @@ pub mod path_macros {
pub use crate::include_workspace_asset_bytes;
pub use crate::include_workspace_transaction_examples_str;
pub use crate::path_local_blueprint;
pub use crate::path_workspace_blueprint;
pub use crate::path_workspace_transaction_examples;
}

Expand Down
48 changes: 20 additions & 28 deletions radix-engine-tests/tests/system/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,24 @@ use radix_engine_interface::object_modules::metadata::{
use radix_engine_tests::common::*;
use scrypto_test::prelude::*;

fn publish_metadata_package(
ledger: &mut LedgerSimulator<NoExtension, InMemorySubstateDatabase>,
) -> PackageAddress {
let code =
include_workspace_asset_bytes!("radix-transaction-scenarios", "metadata.wasm").to_vec();
let package_def = manifest_decode::<PackageDefinition>(include_workspace_asset_bytes!(
"radix-transaction-scenarios",
"metadata.rpd"
))
.unwrap();
ledger.publish_package_simple((code, package_def))
}

#[test]
fn can_get_from_scrypto() {
// Arrange
let mut ledger = LedgerSimulatorBuilder::new().build();
let package_address = ledger.compile_and_publish(path_workspace_blueprint!(
"radix-transaction-scenarios",
"metadata"
));
let package_address = publish_metadata_package(&mut ledger);

// Act
let manifest = ManifestBuilder::new()
Expand Down Expand Up @@ -48,10 +58,7 @@ fn can_get_from_scrypto() {
fn can_set_from_scrypto() {
// Arrange
let mut ledger = LedgerSimulatorBuilder::new().build();
let package_address = ledger.compile_and_publish(path_workspace_blueprint!(
"radix-transaction-scenarios",
"metadata"
));
let package_address = publish_metadata_package(&mut ledger);
let manifest = ManifestBuilder::new()
.lock_fee_from_faucet()
.call_function(package_address, "MetadataTest", "new", manifest_args!())
Expand All @@ -78,10 +85,7 @@ fn can_set_from_scrypto() {
fn cannot_initialize_metadata_if_key_too_long() {
// Arrange
let mut ledger = LedgerSimulatorBuilder::new().build();
let package_address = ledger.compile_and_publish(path_workspace_blueprint!(
"radix-transaction-scenarios",
"metadata"
));
let package_address = publish_metadata_package(&mut ledger);

// Act
let key = "a".repeat(MAX_METADATA_KEY_STRING_LEN + 1);
Expand Down Expand Up @@ -111,10 +115,7 @@ fn cannot_initialize_metadata_if_key_too_long() {
fn cannot_set_metadata_if_key_too_long() {
// Arrange
let mut ledger = LedgerSimulatorBuilder::new().build();
let package_address = ledger.compile_and_publish(path_workspace_blueprint!(
"radix-transaction-scenarios",
"metadata"
));
let package_address = publish_metadata_package(&mut ledger);
let manifest = ManifestBuilder::new()
.lock_fee_from_faucet()
.call_function(package_address, "MetadataTest", "new", manifest_args!())
Expand Down Expand Up @@ -148,10 +149,7 @@ fn cannot_set_metadata_if_key_too_long() {
fn cannot_initialize_metadata_if_value_too_long() {
// Arrange
let mut ledger = LedgerSimulatorBuilder::new().build();
let package_address = ledger.compile_and_publish(path_workspace_blueprint!(
"radix-transaction-scenarios",
"metadata"
));
let package_address = publish_metadata_package(&mut ledger);

// Act
let value = "a".repeat(MAX_METADATA_VALUE_SBOR_LEN + 1);
Expand Down Expand Up @@ -181,10 +179,7 @@ fn cannot_initialize_metadata_if_value_too_long() {
fn cannot_set_metadata_if_value_too_long() {
// Arrange
let mut ledger = LedgerSimulatorBuilder::new().build();
let package_address = ledger.compile_and_publish(path_workspace_blueprint!(
"radix-transaction-scenarios",
"metadata"
));
let package_address = publish_metadata_package(&mut ledger);
let manifest = ManifestBuilder::new()
.lock_fee_from_faucet()
.call_function(package_address, "MetadataTest", "new", manifest_args!())
Expand Down Expand Up @@ -218,10 +213,7 @@ fn cannot_set_metadata_if_value_too_long() {
fn cannot_set_metadata_if_initialized_empty_locked() {
// Arrange
let mut ledger = LedgerSimulatorBuilder::new().build();
let package_address = ledger.compile_and_publish(path_workspace_blueprint!(
"radix-transaction-scenarios",
"metadata"
));
let package_address = publish_metadata_package(&mut ledger);
let manifest = ManifestBuilder::new()
.lock_fee_from_faucet()
.call_function(package_address, "MetadataTest", "new", manifest_args!())
Expand Down
Loading