Skip to content

Commit b2f67ef

Browse files
committed
chore: fix naming.
1 parent 05d1775 commit b2f67ef

File tree

7 files changed

+142
-6
lines changed

7 files changed

+142
-6
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,11 @@ mtma-node-test-global-storage-includes-criterion = { path = "checks/node/citeria
188188
mtma-node-test-global-storage-not-empty-criterion = { path = "checks/node/citeria/global-storage-not-empty" }
189189

190190

191-
### e2e
191+
### migrator
192192
mtma-migrator-test-types = { path = "checks/migrator/util/types" }
193193
mtma-migrator-test-accounts-equal-criterion = { path = "checks/migrator/citeria/accounts-equal" }
194+
mtma-migrator-test-balances-equal-criterion = { path = "checks/migrator/citeria/balances-equal" }
195+
194196
## util
195197
bcs-ext = { path = "util/bcs-ext" }
196198
movement-syncing = { path = "util/movement/syncing" }
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[package]
2+
name = "mtma-migrator-balances-equal"
3+
version = { workspace = true }
4+
edition = { workspace = true }
5+
license = { workspace = true }
6+
authors = { workspace = true }
7+
homepage = { workspace = true }
8+
publish = { workspace = true }
9+
rust-version = { workspace = true }
10+
11+
[dependencies]
12+
mtma-types = { workspace = true }
13+
mtma-migrator-types = { workspace = true }
14+
mtma-migrator-test-types = { workspace = true }
15+
anyhow = { workspace = true }
16+
mtma-node-replay-core = { workspace = true }
17+
mtma-node-test-global-storage-injective-criterion = { workspace = true }
18+
mtma-node-test-global-storage-includes-criterion = { workspace = true }
19+
mtma-node-test-global-storage-not-empty-criterion = { workspace = true }
20+
mtma-migrator-test-balances-equal-criterion = { workspace = true }
21+
mtma-node-preludes = { workspace = true }
22+
mtma-node-null-core = { workspace = true }
23+
tokio = { workspace = true }
24+
chrono = { workspace = true }
25+
rand = { workspace = true }
26+
kestrel = { workspace = true }
27+
mtma-node-test-types = { workspace = true }
28+
29+
[dev-dependencies]
30+
tracing-test = { workspace = true }
31+
tracing = { workspace = true }
32+
33+
[lints]
34+
workspace = true
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Migration Executor Checks Sketchpad
2+
A sketchpad for playing around with checks on the testpad.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#[cfg(test)]
2+
pub mod test {
3+
4+
use anyhow::Context;
5+
use mtma_migrator_test_balances_equal_criterion::BalancesEqual;
6+
use mtma_migrator_test_types::check::checked_migration;
7+
use mtma_migrator_types::migrator::{movement_migrator::Overlays, MovementMigrator};
8+
use mtma_node_null_core::config::Config as MtmaNullConfig;
9+
use mtma_node_test_types::prelude::Prelude;
10+
use tracing::info;
11+
12+
#[tokio::test(flavor = "multi_thread")]
13+
#[tracing_test::traced_test]
14+
async fn test_balances_equal() -> Result<(), anyhow::Error> {
15+
// use a scope to ensure everything is dropped
16+
{
17+
// Form the migrator.
18+
let mut movement_migrator = MovementMigrator::try_debug_home()?;
19+
movement_migrator.set_overlays(Overlays::default());
20+
21+
// Start the migrator so that it's running in the background.
22+
// In the future, some migrators may be for already running nodes.
23+
let movement_migrator_for_task = movement_migrator.clone();
24+
let movement_migrator_task = kestrel::task(async move {
25+
movement_migrator_for_task.run().await?;
26+
Ok::<_, anyhow::Error>(())
27+
});
28+
29+
// wait for the rest client to be ready
30+
// once we have this, there should also be a config, so we can then kill off the migrator and proceed
31+
movement_migrator
32+
.wait_for_rest_client_ready(tokio::time::Duration::from_secs(600)) // we wait for up to ten minutes because the nix flake in .vendors/movementcan be a bit slow the first time
33+
.await
34+
.context(
35+
"failed to wait for movement migrator rest client while running accounts equal manual prelude",
36+
)?;
37+
38+
kestrel::end!(movement_migrator_task)?;
39+
40+
// Form the prelude.
41+
// todo: this needs to be updated to use the prelude generator
42+
let prelude = Prelude::new_empty();
43+
44+
// Form the migration.
45+
let migration_config = MtmaNullConfig::default();
46+
let migration = migration_config.build()?;
47+
48+
// Run the checked migration.
49+
let balances_equal = BalancesEqual::new();
50+
info!("Running migration");
51+
match checked_migration(
52+
&mut movement_migrator,
53+
&prelude,
54+
&migration,
55+
vec![balances_equal],
56+
)
57+
.await
58+
{
59+
Ok(()) => {}
60+
Err(e) => {
61+
info!("Migration failed: {:?}", e);
62+
return Err(anyhow::anyhow!("Migration failed: {:?}", e));
63+
}
64+
}
65+
info!("Migration succeeded");
66+
}
67+
68+
// exit the test is fine when you only have one test per crate because when cargo test is run across a workspace, it actually multi-processes the tests by crate
69+
std::process::exit(0);
70+
71+
Ok(())
72+
}
73+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod balances_equal;

checks/migrator/citeria/balances-equal/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ use mtma_migrator_test_types::criterion::{
55
};
66
use tracing::info;
77

8-
pub struct AccountsEqual;
8+
pub struct BalancesEqual;
99

10-
impl AccountsEqual {
10+
impl BalancesEqual {
1111
pub fn new() -> Self {
1212
Self {}
1313
}
@@ -17,7 +17,7 @@ impl AccountsEqual {
1717
}
1818
}
1919

20-
impl Criterionish for AccountsEqual {
20+
impl Criterionish for BalancesEqual {
2121
async fn satisfies(
2222
&self,
2323
movement_migrator: &MovementMigrator,
@@ -70,15 +70,15 @@ impl Criterionish for AccountsEqual {
7070

7171
info!("Getting movement aptos account balance");
7272
let movement_aptos_account_balance = movement_aptos_rest_client
73-
.get_account_balance(movement_aptos_account_address)
73+
.view_apt_account_balance(movement_aptos_account_address)
7474
.await
7575
.map_err(|e| {
7676
CriterionError::Internal(format!("Failed to get account: {:?}", e).into())
7777
})?
7878
.into_inner();
7979

8080
info!("Comparing balances");
81-
if movement_account_balance.coin.value != movement_aptos_account_balance.coin.value {
81+
if u64::from(movement_account_balance.coin.value) != movement_aptos_account_balance {
8282
return Err(CriterionError::Unsatisfied(
8383
format!("movement and aptos account balances have different values: {:?} != {:?}", movement_account_balance, movement_aptos_account_balance).into(),
8484
));

0 commit comments

Comments
 (0)