Skip to content

Commit

Permalink
test(aptos_settlement_client): add update_state, state_block_number u…
Browse files Browse the repository at this point in the history
…nit test
  • Loading branch information
Tranduy1dol committed Aug 5, 2024
1 parent 41e1c33 commit feb56fd
Show file tree
Hide file tree
Showing 6 changed files with 246 additions and 53 deletions.
3 changes: 3 additions & 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ itertools = "0.13.0"
mockall = "0.12.1"
testcontainers = "0.18.0"


# Cairo VM
cairo-vm = { git = "https://github.com/lambdaclass/cairo-vm", features = [
"extensive_hints",
Expand Down
3 changes: 3 additions & 0 deletions crates/settlement-clients/aptos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ alloy = { git = "https://github.com/alloy-rs/alloy", rev = "68952c0" }
aptos-sdk = { workspace = true }
async-trait = { workspace = true }
color-eyre = { workspace = true }
dotenvy = { workspace = true }
hex = "0.4.3"
mockall = { workspace = true }
once_cell = "1.19.0"
settlement-client-interface = { workspace = true }
tokio = { workspace = true }
url = "2.5.2"
utils = { workspace = true }
15 changes: 10 additions & 5 deletions crates/settlement-clients/aptos/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
use dotenvy::dotenv;
use settlement_client_interface::SettlementConfig;
use utils::env_utils::get_env_var_or_panic;

pub struct AptosSettlementConfig {
pub node_url: String,
pub private_key: String,
pub account_address: String,
pub module_address: String,
pub chain_id: String,
}

impl SettlementConfig for AptosSettlementConfig {
fn new_from_env() -> Self {
Self {
node_url: get_env_var_or_panic("APTOS_NODE_URL"),
private_key: get_env_var_or_panic("PRIVATE_KEY"),
account_address: get_env_var_or_panic("ADDRESS"),
}
dotenv().expect("Failed to load .env file");
let node_url = get_env_var_or_panic("APTOS_NODE_URL");
let private_key = get_env_var_or_panic("APTOS_PRIVATE_KEY");
let account_address = get_env_var_or_panic("APTOS_ACCOUNT_ADDRESS");
let module_address = get_env_var_or_panic("APTOS_MODULE_ADDRESS");
let chain_id = get_env_var_or_panic("CHAIN_ID");
AptosSettlementConfig { chain_id, node_url, private_key, account_address, module_address }
}
}
4 changes: 0 additions & 4 deletions crates/settlement-clients/aptos/src/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,3 @@ pub(crate) fn slice_from_u8_to_u256(slice: &[u8; 32]) -> MoveValue {
pub(crate) fn slice_from_vec_u8_to_u256(slices: &[[u8; 32]]) -> Vec<MoveValue> {
slices.iter().map(slice_from_u8_to_u256).collect()
}

pub(crate) unsafe fn slice_from_u8_to_string(slice: &[u8; 48]) -> String {
String::from_utf8_unchecked(Vec::from(slice)).to_string()
}
Loading

0 comments on commit feb56fd

Please sign in to comment.