diff --git a/Makefile b/Makefile index d5feec56..32d99e71 100644 --- a/Makefile +++ b/Makefile @@ -33,6 +33,8 @@ setup-test: build-contract mkdir -p tests/wasm/1_0_0; curl -L https://github.com/casper-ecosystem/cep-78-enhanced-nft/releases/download/v1.0.0/cep-78-wasm.tar.gz | tar zxv -C tests/wasm/1_0_0/ mkdir -p tests/wasm/1_1_0; curl -L https://github.com/casper-ecosystem/cep-78-enhanced-nft/releases/download/v1.1.0/cep-78-wasm.tar.gz | tar zxv -C tests/wasm/1_1_0/ mkdir -p tests/wasm/1_2_0; curl -L https://github.com/casper-ecosystem/cep-78-enhanced-nft/releases/download/v1.2.0/cep-78-wasm.tar.gz | tar zxv -C tests/wasm/1_2_0/ + mkdir -p tests/wasm/1_3_0; curl -L https://github.com/casper-ecosystem/cep-78-enhanced-nft/releases/download/v1.3.0/cep-78-wasm.tar.gz | tar zxv -C tests/wasm/1_3_0/ + cp contract/target/wasm32-unknown-unknown/release/contract.wasm tests/wasm cp client/mint_session/target/wasm32-unknown-unknown/release/mint_call.wasm tests/wasm cp client/balance_of_session/target/wasm32-unknown-unknown/release/balance_of_call.wasm tests/wasm diff --git a/tests/src/upgrade.rs b/tests/src/upgrade.rs index 888926de..64ca52a6 100644 --- a/tests/src/upgrade.rs +++ b/tests/src/upgrade.rs @@ -20,9 +20,9 @@ use crate::utility::{ constants::{ ACCOUNT_USER_1, ARG_IS_HASH_IDENTIFIER_MODE, ARG_NFT_CONTRACT_HASH, ARG_NFT_CONTRACT_PACKAGE_HASH, CONTRACT_1_0_0_WASM, CONTRACT_1_1_0_WASM, - CONTRACT_1_2_0_WASM, MANGLE_NAMED_KEYS, MINT_1_0_0_WASM, MINT_SESSION_WASM, - NFT_CONTRACT_WASM, NFT_TEST_COLLECTION, NFT_TEST_SYMBOL, PAGE_SIZE, TRANSFER_SESSION_WASM, - UPDATED_RECEIPTS_WASM, + CONTRACT_1_2_0_WASM, CONTRACT_1_3_0_WASM, MANGLE_NAMED_KEYS, MINT_1_0_0_WASM, + MINT_SESSION_WASM, NFT_CONTRACT_WASM, NFT_TEST_COLLECTION, NFT_TEST_SYMBOL, PAGE_SIZE, + TRANSFER_SESSION_WASM, UPDATED_RECEIPTS_WASM, }, installer_request_builder::{ InstallerRequestBuilder, MetadataMutability, NFTIdentifierMode, NFTMetadataKind, @@ -698,7 +698,9 @@ fn should_not_upgrade_with_larger_total_token_supply() { ); } -fn should_safely_upgrade_from_1_2_0_to_current_version_with_reporting_mode( +fn should_safely_upgrade_from_old_version_to_new_version_with_reporting_mode( + old_version: &str, + new_version: &str, reporting_mode: OwnerReverseLookupMode, expected_total_token_supply_post_upgrade: u64, ) { @@ -707,7 +709,7 @@ fn should_safely_upgrade_from_1_2_0_to_current_version_with_reporting_mode( .run_genesis(&PRODUCTION_RUN_GENESIS_REQUEST) .commit(); - let install_request = InstallerRequestBuilder::new(*DEFAULT_ACCOUNT_ADDR, CONTRACT_1_2_0_WASM) + let install_request = InstallerRequestBuilder::new(*DEFAULT_ACCOUNT_ADDR, old_version) .with_collection_name(NFT_TEST_COLLECTION.to_string()) .with_collection_symbol(NFT_TEST_SYMBOL.to_string()) .with_total_token_supply(100u64) @@ -721,8 +723,8 @@ fn should_safely_upgrade_from_1_2_0_to_current_version_with_reporting_mode( builder.exec(install_request).expect_success().commit(); - let nft_contract_hash_1_2_0: ContractHash = support::get_nft_contract_hash(&builder); - let nft_contract_key_1_2_0: Key = nft_contract_hash_1_2_0.into(); + let nft_contract_hash: ContractHash = support::get_nft_contract_hash(&builder); + let nft_contract_key: Key = nft_contract_hash.into(); let number_of_tokens_pre_migration = 3usize; @@ -730,7 +732,7 @@ fn should_safely_upgrade_from_1_2_0_to_current_version_with_reporting_mode( for _i in 0..number_of_tokens_pre_migration { let register_request = ExecuteRequestBuilder::contract_call_by_hash( *DEFAULT_ACCOUNT_ADDR, - nft_contract_hash_1_2_0, + nft_contract_hash, ENTRY_POINT_REGISTER_OWNER, runtime_args! { ARG_TOKEN_OWNER => Key::Account(*DEFAULT_ACCOUNT_ADDR), @@ -741,7 +743,7 @@ fn should_safely_upgrade_from_1_2_0_to_current_version_with_reporting_mode( builder.exec(register_request).expect_success().commit(); let mint_request = ExecuteRequestBuilder::contract_call_by_hash( *DEFAULT_ACCOUNT_ADDR, - nft_contract_hash_1_2_0, + nft_contract_hash, ENTRY_POINT_MINT, runtime_args! { ARG_TOKEN_OWNER => Key::Account(*DEFAULT_ACCOUNT_ADDR), @@ -755,9 +757,9 @@ fn should_safely_upgrade_from_1_2_0_to_current_version_with_reporting_mode( let upgrade_request = ExecuteRequestBuilder::standard( *DEFAULT_ACCOUNT_ADDR, - NFT_CONTRACT_WASM, + new_version, runtime_args! { - ARG_NFT_CONTRACT_HASH => nft_contract_key_1_2_0, + ARG_NFT_CONTRACT_HASH => nft_contract_key, ARG_COLLECTION_NAME => NFT_TEST_COLLECTION.to_string(), ARG_NAMED_KEY_CONVENTION => NamedKeyConventionMode::V1_0Custom as u8, ARG_ACCESS_KEY_NAME_1_0_0 => format!("{PREFIX_ACCESS_KEY_NAME}_{NFT_TEST_COLLECTION}"), @@ -811,16 +813,38 @@ fn should_safely_upgrade_from_1_2_0_to_current_version_with_reporting_mode( } #[test] +fn should_safely_upgrade_from_1_2_0_to_1_3_0() { + //* starting total_token_supply 100u64 + let expected_total_token_supply_post_upgrade = 10; + should_safely_upgrade_from_old_version_to_new_version_with_reporting_mode( + CONTRACT_1_2_0_WASM, + CONTRACT_1_3_0_WASM, + OwnerReverseLookupMode::NoLookUp, + expected_total_token_supply_post_upgrade, + ); + let expected_total_token_supply_post_upgrade = 100; + should_safely_upgrade_from_old_version_to_new_version_with_reporting_mode( + CONTRACT_1_2_0_WASM, + CONTRACT_1_3_0_WASM, + OwnerReverseLookupMode::Complete, + expected_total_token_supply_post_upgrade, + ); +} -fn should_safely_upgrade_from_1_2_0_to_current_version() { +#[test] +fn should_safely_upgrade_from_1_3_0_to_current_version() { //* starting total_token_supply 100u64 let expected_total_token_supply_post_upgrade = 10; - should_safely_upgrade_from_1_2_0_to_current_version_with_reporting_mode( + should_safely_upgrade_from_old_version_to_new_version_with_reporting_mode( + CONTRACT_1_3_0_WASM, + NFT_CONTRACT_WASM, OwnerReverseLookupMode::NoLookUp, expected_total_token_supply_post_upgrade, ); let expected_total_token_supply_post_upgrade = 100; - should_safely_upgrade_from_1_2_0_to_current_version_with_reporting_mode( + should_safely_upgrade_from_old_version_to_new_version_with_reporting_mode( + CONTRACT_1_3_0_WASM, + NFT_CONTRACT_WASM, OwnerReverseLookupMode::Complete, expected_total_token_supply_post_upgrade, ); diff --git a/tests/src/utility/constants.rs b/tests/src/utility/constants.rs index fc137feb..4e284749 100644 --- a/tests/src/utility/constants.rs +++ b/tests/src/utility/constants.rs @@ -2,6 +2,7 @@ pub const BALANCE_OF_SESSION_WASM: &str = "balance_of_call.wasm"; pub const CONTRACT_1_0_0_WASM: &str = "1_0_0/contract.wasm"; pub const CONTRACT_1_1_0_WASM: &str = "1_1_0/contract.wasm"; pub const CONTRACT_1_2_0_WASM: &str = "1_2_0/contract.wasm"; +pub const CONTRACT_1_3_0_WASM: &str = "1_3_0/contract.wasm"; pub const GET_APPROVED_WASM: &str = "get_approved_call.wasm"; pub const IS_APPROVED_FOR_ALL_WASM: &str = "is_approved_for_all_call.wasm"; pub const MANGLE_NAMED_KEYS: &str = "mangle_named_keys.wasm";