Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into ci-no-fail-fast
- Loading branch information
Showing
21 changed files
with
522 additions
and
45 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
102 changes: 102 additions & 0 deletions
102
src/vit-testing/integration-tests/src/integration/from_snapshot_to_vit_servicing_station.rs
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 |
---|---|---|
@@ -0,0 +1,102 @@ | ||
use crate::common::mainnet_wallet_ext::MainnetWalletExtension; | ||
use crate::common::snapshot::mock; | ||
use crate::common::MainnetWallet; | ||
use assert_fs::TempDir; | ||
use mainnet_lib::{MainnetNetworkBuilder, MainnetWalletStateBuilder}; | ||
use snapshot_lib::SnapshotInfo; | ||
use snapshot_trigger_service::config::JobParameters; | ||
use vit_servicing_station_tests::common::data::ArbitraryValidVotingTemplateGenerator; | ||
use vit_servicing_station_tests::common::raw_snapshot::RawSnapshotBuilder; | ||
use vit_servicing_station_tests::common::snapshot::VotingPower; | ||
use vitup::config::VoteBlockchainTime; | ||
use vitup::config::{Block0Initials, ConfigBuilder}; | ||
use vitup::testing::spawn_network; | ||
use vitup::testing::vitup_setup; | ||
|
||
#[test] | ||
pub fn put_raw_snapshot() { | ||
let testing_directory = TempDir::new().unwrap().into_persistent(); | ||
let stake = 10_000; | ||
let alice_wallet = MainnetWallet::new(stake); | ||
let bob_wallet = MainnetWallet::new(stake); | ||
let clarice_wallet = MainnetWallet::new(stake); | ||
|
||
let (db_sync, _reps) = MainnetNetworkBuilder::default() | ||
.with(alice_wallet.as_direct_voter()) | ||
.with(bob_wallet.as_direct_voter()) | ||
.with(clarice_wallet.as_direct_voter()) | ||
.build(&testing_directory); | ||
|
||
let job_params = JobParameters::fund("fund9"); | ||
let snapshot_result = | ||
mock::do_snapshot(&db_sync, job_params.clone(), &testing_directory).unwrap(); | ||
|
||
let vote_timing = VoteBlockchainTime { | ||
vote_start: 1, | ||
tally_start: 2, | ||
tally_end: 3, | ||
slots_per_epoch: 30, | ||
}; | ||
|
||
let config = ConfigBuilder::default() | ||
.block0_initials(Block0Initials(vec![ | ||
alice_wallet.as_initial_entry(), | ||
bob_wallet.as_initial_entry(), | ||
clarice_wallet.as_initial_entry(), | ||
])) | ||
.vote_timing(vote_timing.into()) | ||
.slot_duration_in_seconds(2) | ||
.proposals_count(3) | ||
.voting_power(100) | ||
.private(false) | ||
.build(); | ||
|
||
let mut template_generator = ArbitraryValidVotingTemplateGenerator::new(); | ||
let (mut controller, vit_parameters, network_params) = | ||
vitup_setup(&config, testing_directory.path().to_path_buf()).unwrap(); | ||
|
||
let (_nodes, vit_station, _wallet_proxy) = spawn_network( | ||
&mut controller, | ||
vit_parameters, | ||
network_params, | ||
&mut template_generator, | ||
) | ||
.unwrap(); | ||
|
||
let registrations = snapshot_result.registrations().clone(); | ||
|
||
let raw_snapshot = RawSnapshotBuilder::default() | ||
.with_voting_registrations(registrations) | ||
.with_tag(job_params.tag.as_ref().unwrap()) | ||
.build(); | ||
|
||
assert!(vit_station.check_running()); | ||
|
||
vit_station.put_raw_snapshot(&raw_snapshot).unwrap(); | ||
|
||
assert_eq!( | ||
vec![job_params.tag.unwrap()], | ||
vit_station.snapshot_tags().unwrap(), | ||
"expected tags vs tags taken from REST API" | ||
); | ||
|
||
let snapshot_infos: Vec<SnapshotInfo> = raw_snapshot.clone().try_into().unwrap(); | ||
|
||
for snapshot_info in snapshot_infos.iter() { | ||
let voting_power = VotingPower::from(snapshot_info.clone()); | ||
let voter_info = vit_station | ||
.voter_info(&raw_snapshot.tag, &snapshot_info.hir.voting_key.to_hex()) | ||
.unwrap(); | ||
assert_eq!( | ||
vec![voting_power], | ||
voter_info.voter_info, | ||
"wrong data for entry: {:?}", | ||
snapshot_info | ||
); | ||
assert_eq!( | ||
raw_snapshot.content.update_timestamp, voter_info.last_updated, | ||
"wrong timestamp for entry: {:?}", | ||
snapshot_info | ||
); | ||
} | ||
} |
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,3 +1,4 @@ | ||
mod from_snapshot_to_catalyst_toolbox; | ||
mod from_snapshot_to_merge; | ||
mod from_snapshot_to_vit_servicing_station; | ||
mod from_snapshot_to_vitup; |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[ | ||
{ | ||
"voting_key": "ed25519_pk19t8y8xl43uy99ywngpfcfsaklw76h48m965y5cszt5phmj2uv4psucdev9", | ||
"voting_power": "1", | ||
"group": "g1" | ||
}, | ||
{ | ||
"voting_key": "ed25519_pk158t34dk8qmjs0mcwgsa5hg75qrg00wl2mejgt45vkelhf22d0wwqf22u0v", | ||
"voting_power": "3", | ||
"group": "g1" | ||
}, | ||
{ | ||
"voting_key": "ed25519_pk1fht207rmf0wqfdx59n4fa4dskvqq0w88rh2hgnava0g825lspcmsctw8t2", | ||
"voting_power": "4", | ||
"group": "g1" | ||
} | ||
] | ||
|
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
Oops, something went wrong.