Skip to content

Commit

Permalink
[transactional-tests] Publish correct framework based on protocol ver…
Browse files Browse the repository at this point in the history
…sion in the transactional test runner (MystenLabs#12867)
  • Loading branch information
tzakian authored Jul 7, 2023
1 parent 78ca0b2 commit 55c3137
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/sui-transactional-test-runner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ sui-types = { workspace = true, features = ["test-utils"]}
workspace-hack = { version = "0.1", path = "../workspace-hack" }
sui-json-rpc-types.workspace = true
sui-json-rpc.workspace = true
sui-framework-snapshot.workspace = true

[target.'cfg(msim)'.dependencies]
msim.workspace = true
19 changes: 13 additions & 6 deletions crates/sui-transactional-test-runner/src/test_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use sui_json_rpc::api::QUERY_MAX_RESULT_LIMIT;
use sui_json_rpc_types::{
DevInspectResults, EventFilter, SuiExecutionStatus, SuiTransactionBlockEffectsAPI,
};
use sui_protocol_config::{Chain, ProtocolConfig};
use sui_protocol_config::{Chain, ProtocolConfig, ProtocolVersion};
use sui_types::transaction::Command;
use sui_types::transaction::ProgrammableTransaction;
use sui_types::DEEPBOOK_PACKAGE_ID;
Expand Down Expand Up @@ -156,14 +156,21 @@ pub fn clone_genesis_compiled_modules() -> Vec<Vec<CompiledModule>> {
GENESIS.modules.clone()
}

pub fn clone_genesis_packages() -> Vec<Object> {
GENESIS.packages.clone()
}

pub fn clone_genesis_objects() -> Vec<Object> {
GENESIS.objects.clone()
}

fn genesis_module_objects_for_protocol_version(protocol_version: ProtocolVersion) -> Vec<Object> {
if protocol_version == ProtocolVersion::max() {
return GENESIS.packages.clone();
}
sui_framework_snapshot::load_bytecode_snapshot(protocol_version.as_u64())
.expect("Unable to load bytecode snapshot")
.into_iter()
.map(|pkg| pkg.genesis_object())
.collect()
}

/// Create and return objects wrapping the genesis modules for sui
fn create_genesis_module_objects() -> Genesis {
Genesis {
Expand Down Expand Up @@ -270,7 +277,7 @@ impl<'a> MoveTestAdapter<'a> for SuiTestAdapter<'a> {

let mut named_address_mapping = NAMED_ADDRESSES.clone();

let mut objects = clone_genesis_packages();
let mut objects = genesis_module_objects_for_protocol_version(protocol_config.version);
objects.extend(clone_genesis_objects());
let mut account_objects = BTreeMap::new();
let mut accounts = BTreeMap::new();
Expand Down

0 comments on commit 55c3137

Please sign in to comment.