Skip to content

Commit 750d594

Browse files
mzabaluevnicholasflintwillow
authored andcommitted
ci: fix unit tests (#1069)
1 parent 67d303a commit 750d594

File tree

5 files changed

+26
-39
lines changed

5 files changed

+26
-39
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

protocol-units/da/movement/protocol/util/src/blob/ir/blob.rs

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ pub struct InnerSignedBlobV1<C>
1313
where
1414
C: Curve,
1515
{
16-
pub data: InnerSignedBlobV1Data<C>,
17-
pub signature: Vec<u8>,
18-
pub signer: Vec<u8>,
19-
pub id: Id,
16+
data: InnerSignedBlobV1Data<C>,
17+
signature: Vec<u8>,
18+
signer: Vec<u8>,
19+
id: Id,
2020
}
2121

2222
impl<C> InnerSignedBlobV1<C>
2323
where
2424
C: Curve + Verify<C> + Digester<C>,
2525
{
26-
pub fn new(
26+
pub(crate) fn new(
2727
data: InnerSignedBlobV1Data<C>,
2828
signature: Vec<u8>,
2929
signer: Vec<u8>,
@@ -165,29 +165,6 @@ where
165165
}
166166
}
167167

168-
#[cfg(test)]
169-
pub mod test {
170-
171-
use super::*;
172-
use movement_da_light_node_signer::Signer;
173-
use movement_signer::cryptography::secp256k1::Secp256k1;
174-
use movement_signer_local::signer::LocalSigner;
175-
176-
#[tokio::test]
177-
async fn test_cannot_change_id_and_verify() -> Result<(), anyhow::Error> {
178-
let blob = InnerSignedBlobV1Data::new(vec![1, 2, 3], 123);
179-
let signer = Signer::new(LocalSigner::<Secp256k1>::random());
180-
let signed_blob = blob.try_to_sign(&signer).await?;
181-
182-
let mut changed_blob = signed_blob.clone();
183-
changed_blob.id = Id::new(vec![1, 2, 3, 4]);
184-
185-
assert!(changed_blob.try_verify().is_err());
186-
187-
Ok(())
188-
}
189-
}
190-
191168
pub mod stream_read_response {
192169

193170
use movement_da_light_node_proto::*;

protocol-units/execution/maptos/opt-executor/src/executor/execution.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,14 @@ mod tests {
212212
ed25519::{Ed25519PrivateKey, Ed25519Signature},
213213
HashValue, PrivateKey, Uniform,
214214
};
215-
use aptos_sdk::{transaction_builder::TransactionFactory, types::LocalAccount};
215+
use aptos_sdk::{
216+
transaction_builder::TransactionFactory,
217+
types::{AccountKey, LocalAccount},
218+
};
216219
use aptos_storage_interface::state_view::DbStateViewAtVersion;
217220
use aptos_types::{
218221
account_address::AccountAddress,
219-
account_config::AccountResource,
222+
account_config::{aptos_test_root_address, AccountResource},
220223
block_executor::partitioner::ExecutableTransactions,
221224
block_metadata::BlockMetadata,
222225
chain_id::ChainId,
@@ -295,8 +298,11 @@ mod tests {
295298
.maptos_private_key_signer_identifier
296299
.try_raw_private_key()?;
297300
let private_key = Ed25519PrivateKey::try_from(raw_private_key.as_slice())?;
298-
let root_account =
299-
LocalAccount::from_private_key(private_key.to_encoded_string()?.as_str(), 0)?;
301+
let root_account = LocalAccount::new(
302+
aptos_test_root_address(),
303+
AccountKey::from_private_key(private_key),
304+
0,
305+
);
300306

301307
// Seed for random number generator, used here to generate predictable results in a test environment.
302308
let seed = [3u8; 32];
@@ -403,8 +409,11 @@ mod tests {
403409
.maptos_private_key_signer_identifier
404410
.try_raw_private_key()?;
405411
let private_key = Ed25519PrivateKey::try_from(raw_private_key.as_slice())?;
406-
let root_account =
407-
LocalAccount::from_private_key(private_key.to_encoded_string()?.as_str(), 0)?;
412+
let root_account = LocalAccount::new(
413+
aptos_test_root_address(),
414+
AccountKey::from_private_key(private_key),
415+
0,
416+
);
408417

409418
// Seed for random number generator, used here to generate predictable results in a test environment.
410419
let seed = [3u8; 32];

util/signing/testing/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ async-trait = { workspace = true }
1919
maptos-dof-execution = { workspace = true }
2020
maptos-execution-util = { workspace = true }
2121
movement-signing-aptos = { workspace = true }
22-
movement-signer-loader = { workspace = true }
22+
movement-signer-loader = { workspace = true }
2323
movement-signer-local = { workspace = true }
2424
movement-signer-aws-kms = { workspace = true }
2525
movement-signing-eth = { workspace = true }
@@ -28,6 +28,7 @@ aptos-types = { workspace = true }
2828
anyhow = { workspace = true }
2929
chrono = { workspace = true }
3030
ed25519-dalek = { workspace = true, features = ["rand_core"] }
31+
hex = { workspace = true }
3132
# Workspace is on rand 0.7 due largely to aptos-core
3233
rand = "0.8"
3334
sha3 = "0.10.8"

util/signing/testing/tests/execute.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use aptos_types::transaction::{
1212
};
1313

1414
use anyhow::Context;
15-
use aptos_crypto::ValidCryptoMaterialStringExt;
1615
use movement_signer_loader::identifiers::{local::Local, SignerIdentifier};
1716
use tempfile::TempDir;
1817

@@ -45,9 +44,9 @@ async fn execute_signed_transaction() -> Result<(), anyhow::Error> {
4544
let private_key = Ed25519PrivateKey::generate_for_testing();
4645
let mut config = Config::default();
4746
let signing_key = ed25519_dalek::SigningKey::from_bytes(&private_key.to_bytes());
48-
config.chain.maptos_private_key_signer_identifier = SignerIdentifier::Local(Local {
49-
private_key_hex_bytes: private_key.to_encoded_string()?.to_string(),
50-
});
47+
let private_key_hex_bytes = hex::encode(&private_key.to_bytes());
48+
config.chain.maptos_private_key_signer_identifier =
49+
SignerIdentifier::Local(Local { private_key_hex_bytes });
5150
let signer = TestSigner::new(signing_key);
5251
let (executor, _tempdir) = setup(config)?;
5352
let transaction = create_signed_transaction(&signer).await?;

0 commit comments

Comments
 (0)