forked from 0LNetworkCommunity/libra-framework
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ac5c688
commit 9ed6ef0
Showing
8 changed files
with
59 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,45 @@ | ||
use std::path::PathBuf; | ||
|
||
use libra_backwards_compatibility::version_five::{ | ||
freezing_v5::FreezingBit, | ||
balance_v5::BalanceResourceV5, | ||
state_snapshot_v5::{ | ||
v5_read_from_snapshot_manifest, | ||
v5_accounts_from_snapshot_backup | ||
}}; | ||
use libra_types::move_resource::cumulative_deposits::LegacyBalanceResourceV6; | ||
balance_v5::BalanceResourceV5, | ||
freezing_v5::FreezingBit, | ||
state_snapshot_v5::{v5_accounts_from_snapshot_backup, v5_read_from_snapshot_manifest}, | ||
}; | ||
|
||
fn fixtures_path() -> PathBuf { | ||
let mut p = PathBuf::from(env!("CARGO_MANIFEST_DIR")); | ||
p.push("fixtures/v5/state_ver_119757649.17a8"); | ||
assert!(p.exists()); | ||
p | ||
let mut p = PathBuf::from(env!("CARGO_MANIFEST_DIR")); | ||
p.push("fixtures/v5/state_ver_119757649.17a8"); | ||
assert!(p.exists()); | ||
p | ||
} | ||
|
||
|
||
|
||
#[test] | ||
fn read_snapshot_manifest() { | ||
let mut p = fixtures_path(); | ||
p.push("state.manifest"); | ||
assert!(p.exists()); | ||
let mut p = fixtures_path(); | ||
p.push("state.manifest"); | ||
assert!(p.exists()); | ||
|
||
let res = v5_read_from_snapshot_manifest(&p).unwrap(); | ||
let res = v5_read_from_snapshot_manifest(&p).unwrap(); | ||
|
||
assert!(res.version == 119757649); | ||
assert!(res.version == 119757649); | ||
} | ||
|
||
#[tokio::test] | ||
async fn read_full_snapshot() -> anyhow::Result<()>{ | ||
let mut p = fixtures_path(); | ||
p.push("state.manifest"); | ||
async fn read_full_snapshot() -> anyhow::Result<()> { | ||
let mut p = fixtures_path(); | ||
p.push("state.manifest"); | ||
|
||
let man = v5_read_from_snapshot_manifest(&p)?; | ||
let archive_path = fixtures_path(); | ||
let accts = v5_accounts_from_snapshot_backup(man, &archive_path).await?; | ||
let man = v5_read_from_snapshot_manifest(&p)?; | ||
let archive_path = fixtures_path(); | ||
let accts = v5_accounts_from_snapshot_backup(man, &archive_path).await?; | ||
|
||
assert!(accts.len() == 17339); | ||
assert!(accts.len() == 17339); | ||
|
||
let first_account = accts[0].to_account_state()?; | ||
let f = first_account.get_resource::<FreezingBit>()?; | ||
assert!(f.is_frozen() == false); | ||
let b = first_account.get_resource::<BalanceResourceV5>()?; | ||
// assert!(f.is_frozen() == false); | ||
dbg!(&b); | ||
let first_account = accts[0].to_account_state()?; | ||
let f = first_account.get_resource::<FreezingBit>()?; | ||
assert!(!f.is_frozen()); | ||
let b = first_account.get_resource::<BalanceResourceV5>()?; | ||
assert!(b.coin() == 100135989588); | ||
|
||
Ok(()) | ||
Ok(()) | ||
} |