Skip to content

Commit

Permalink
oops, missing files
Browse files Browse the repository at this point in the history
  • Loading branch information
bchocho committed Nov 10, 2022
1 parent 2776b11 commit b039a07
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
25 changes: 25 additions & 0 deletions state-sync/inter-component/test-helpers/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "inter-component-test-helpers"
description = "Aptos executor test helpers"
version = "0.1.0"

# Workspace inherited keys
authors = { workspace = true }
edition = { workspace = true }
homepage = { workspace = true }
license = { workspace = true }
publish = { workspace = true }
repository = { workspace = true }
rust-version = { workspace = true }

[dependencies]
claims = "0.7"

aptos-infallible = { path = "../../../crates/aptos-infallible" }
aptos-temppath = { path = "../../../crates/aptos-temppath" }
aptos-types = { path = "../../../types" }
aptos-vm = { path = "../../../aptos-move/aptos-vm" }
aptosdb = { path = "../../../storage/aptosdb" }
executor-test-helpers = { path = "../../../execution/executor-test-helpers" }
storage-interface = { path = "../../../storage/storage-interface" }
vm-genesis = { path = "../../../aptos-move/vm-genesis" }
27 changes: 27 additions & 0 deletions state-sync/inter-component/test-helpers/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) Aptos
// SPDX-License-Identifier: Apache-2.0

use aptos_infallible::RwLock;
use aptos_types::transaction::{Transaction, WriteSetPayload};
use aptos_vm::AptosVM;
use aptosdb::AptosDB;
use claims::assert_ok;
use executor_test_helpers::bootstrap_genesis;
use std::sync::Arc;
use storage_interface::DbReaderWriter;

pub fn create_database() -> Arc<RwLock<DbReaderWriter>> {
// Generate a genesis change set
let (genesis, _) = vm_genesis::test_genesis_change_set_and_validators(Some(1));

// Create test aptos database
let db_path = aptos_temppath::TempPath::new();
assert_ok!(db_path.create_as_dir());
let (_, db_rw) = DbReaderWriter::wrap(AptosDB::new_for_test(db_path.path()));

// Bootstrap the genesis transaction
let genesis_txn = Transaction::GenesisTransaction(WriteSetPayload::Direct(genesis));
assert_ok!(bootstrap_genesis::<AptosVM>(&db_rw, &genesis_txn));

Arc::new(RwLock::new(db_rw))
}

0 comments on commit b039a07

Please sign in to comment.