Skip to content

Commit

Permalink
fix: easy to use test.
Browse files Browse the repository at this point in the history
  • Loading branch information
l-monninger committed Nov 26, 2024
1 parent 8199219 commit 0f1ad51
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 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 networks/movement/movement-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ mcr-settlement-client = { workspace = true }
movement-config = { workspace = true }
dot-movement = { workspace = true }
aptos-protos = { workspace = true }
tracing-test = { workspace = true }

[lints]
workspace = true
45 changes: 45 additions & 0 deletions networks/movement/movement-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,48 @@ pub use aptos_sdk::*;
pub use movement_da_light_node_client::*;
pub use movement_da_light_node_proto::*;
pub use movement_types;

#[cfg(test)]
pub mod test {

use tracing::info;

use super::{
move_types::identifier::Identifier,
move_types::language_storage::ModuleId,
transaction_builder::TransactionBuilder,
types::account_address::AccountAddress,
types::chain_id::ChainId,
types::transaction::{EntryFunction, TransactionPayload},
types::LocalAccount,
};
use std::time::{SystemTime, UNIX_EPOCH};

#[tokio::test]
#[tracing_test::traced_test]
pub async fn test_transaction_size() -> Result<(), anyhow::Error> {
let mut alice = LocalAccount::generate(&mut rand::rngs::OsRng);
let transaction_builder = TransactionBuilder::new(
TransactionPayload::EntryFunction(EntryFunction::new(
ModuleId::new(AccountAddress::from_str_strict("0x1")?, Identifier::new("coin")?),
Identifier::new("transfer")?,
vec![],
vec![],
)),
SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs() + 20,
ChainId::new(1),
)
.sender(alice.address())
.sequence_number(alice.sequence_number())
.max_gas_amount(5_000)
.gas_unit_price(100);

// create the blob write
let signed_transaction = alice.sign_with_transaction_builder(transaction_builder);
let txn_hash = signed_transaction.committed_hash();
let serialized_aptos_transaction = bcs::to_bytes(&signed_transaction)?;
info!("transaction size {}", serialized_aptos_transaction.len());

Ok(())
}
}

0 comments on commit 0f1ad51

Please sign in to comment.