Skip to content

Commit

Permalink
rebase and make changes to publish_packages
Browse files Browse the repository at this point in the history
  • Loading branch information
angieyth committed Feb 10, 2023
1 parent a8b8a3d commit 015261e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
10 changes: 2 additions & 8 deletions api/src/tests/resource_groups.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@
// SPDX-License-Identifier: Apache-2.0

use super::new_test_context;
<<<<<<< HEAD
use aptos_api_test_context::{current_function_name, TestContext};
use aptos_sdk::types::LocalAccount;
use aptos_types::{account_address::AccountAddress, transaction::TransactionPayload};
=======
use aptos_api_test_context::current_function_name;
>>>>>>> 6e88da1ea7 (address comments and further refactoring)
use serde_json::json;
use std::path::PathBuf;

Expand Down Expand Up @@ -43,15 +37,15 @@ async fn test_read_resource_group() {
let txn = futures::executor::block_on(async move {
let path = PathBuf::from(std::env!("CARGO_MANIFEST_DIR"))
.join("../aptos-move/move-examples/resource_groups/primary");
context.build_package(path, named_addresses_clone)
TestContext::build_package(path, named_addresses_clone)
});
context.publish_package(&mut admin0, txn).await;

let named_addresses_clone = named_addresses.clone();
let txn = futures::executor::block_on(async move {
let path = PathBuf::from(std::env!("CARGO_MANIFEST_DIR"))
.join("../aptos-move/move-examples/resource_groups/secondary");
context.build_package(path, named_addresses_clone)
TestContext::build_package(path, named_addresses_clone)
});
context.publish_package(&mut admin1, txn).await;

Expand Down
4 changes: 2 additions & 2 deletions api/src/tests/transactions_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -830,9 +830,9 @@ async fn test_get_txn_execute_failed_by_entry_function_execution_failure() {
let txn = futures::executor::block_on(async move {
let path = PathBuf::from(std::env!("CARGO_MANIFEST_DIR"))
.join("test-context/move");
context.build_package(path, named_addresses_clone)
TestContext::build_package(path, named_addresses_clone)
});
context.publish_package(&mut admin0, txn).await;
let txn = context.publish_package(&mut admin, txn).await;

let resp = context
.get(
Expand Down
19 changes: 8 additions & 11 deletions api/test-context/src/test_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,10 @@ use aptos_executor::{block_executor::BlockExecutor, db_bootstrapper};
use aptos_executor_types::BlockExecutorTrait;
use aptos_mempool::mocks::MockSharedMempool;
use aptos_mempool_notifications::MempoolNotificationSender;
use aptos_sdk::{
transaction_builder::TransactionFactory,
types::{
account_config::aptos_test_root_address, transaction::SignedTransaction, AccountKey,
LocalAccount,
},
};
use aptos_sdk::{bcs, transaction_builder::TransactionFactory, types::{
account_config::aptos_test_root_address, transaction::SignedTransaction, AccountKey,
LocalAccount,
}};
use aptos_storage_interface::{state_view::DbStateView, DbReaderWriter};
use aptos_temppath::TempPath;
use aptos_types::{
Expand Down Expand Up @@ -427,8 +424,7 @@ impl TestContext {
let mut build_options = aptos_framework::BuildOptions::default();
let _ = named_addresses
.into_iter()
.map(|(name, address)| build_options.named_addresses.insert(name, address))
.collect::<Vec<_>>();
.for_each(|(name, address)| { build_options.named_addresses.insert(name, address); });

let package = BuiltPackage::build(path, build_options).unwrap();
let code = package.extract_code();
Expand All @@ -441,14 +437,15 @@ impl TestContext {
&mut self,
publisher: &mut LocalAccount,
payload: TransactionPayload,
) {
) -> SignedTransaction {
let txn =
publisher.sign_with_transaction_builder(context.transaction_factory().payload(payload));
publisher.sign_with_transaction_builder(self.transaction_factory().payload(payload));
let bcs_txn = bcs::to_bytes(&txn).unwrap();
self.expect_status_code(202)
.post_bcs_txn("/transactions", bcs_txn)
.await;
self.commit_mempool_txns(1).await;
txn
}

pub async fn commit_mempool_txns(&mut self, size: u64) {
Expand Down

0 comments on commit 015261e

Please sign in to comment.