fix(lez/indexer): initialize testnet with the correct state.

This commit is contained in:
Sergio Chouhy 2026-07-01 16:19:34 -03:00
parent a58fbce2ff
commit c6c9049586
5 changed files with 47 additions and 3 deletions

View File

@ -9,7 +9,7 @@ use std::time::Duration;
use anyhow::{Context as _, Result};
use integration_tests::{
TIME_TO_WAIT_FOR_BLOCK_SECONDS, TestContext, private_mention, public_mention,
verify_commitment_is_in_state,
verify_commitment_is_in_state, wait_for_indexer_to_catch_up,
};
use log::info;
use sequencer_service_rpc::RpcClient as _;
@ -164,6 +164,41 @@ async fn claim_pinata_to_existing_public_account() -> Result<()> {
Ok(())
}
#[test]
async fn claim_pinata_indexer_keeps_up() -> Result<()> {
let mut ctx = TestContext::new().await?;
let command = Command::Pinata(PinataProgramAgnosticSubcommand::Claim {
to: public_mention(ctx.existing_public_accounts()[0]),
});
wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?;
info!("Waiting for next block creation");
tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await;
info!("Waiting for indexer to parse blocks");
wait_for_indexer_to_catch_up(&ctx).await?;
let winner_ind_state = indexer_service_rpc::RpcClient::get_account(
&**ctx.indexer_client(),
ctx.existing_public_accounts()[0].into(),
)
.await
.unwrap();
let winner_seq_state = sequencer_service_rpc::RpcClient::get_account(
ctx.sequencer_client(),
ctx.existing_public_accounts()[0],
)
.await?;
assert_eq!(winner_ind_state, winner_seq_state.into());
info!("Indexer correctly indexed the pinata claim");
Ok(())
}
#[test]
async fn claim_pinata_to_existing_private_account() -> Result<()> {
let mut ctx = TestContext::new().await?;

View File

@ -7,6 +7,10 @@ license = { workspace = true }
[lints]
workspace = true
[features]
default = []
testnet = []
[dependencies]
common.workspace = true
logos-blockchain-zone-sdk.workspace = true

View File

@ -23,7 +23,12 @@ impl IndexerStore {
/// Starting database at the start of new chain.
/// Creates files if necessary.
pub fn open_db(location: &Path) -> Result<Self> {
#[cfg(not(feature = "testnet"))]
let initial_state = testnet_initial_state::initial_state();
#[cfg(feature = "testnet")]
let initial_state = testnet_initial_state::initial_state_testnet();
let dbio = RocksDBIO::open_or_create(location, &initial_state)?;
let current_state = dbio.final_state()?;

View File

@ -6,7 +6,7 @@ version = "0.1.0"
[dependencies]
lee.workspace = true
indexer_core.workspace = true
indexer_core = { workspace = true, features = ["testnet"] }
indexer_service_protocol = { workspace = true, features = ["convert"] }
env_logger.workspace = true

View File

@ -10,7 +10,7 @@ workspace = true
[dependencies]
indexer_service_protocol = { workspace = true, features = ["convert"] }
indexer_service_rpc = { workspace = true, features = ["server"] }
indexer_core.workspace = true
indexer_core = { workspace = true, features = ["testnet"] }
clap = { workspace = true, features = ["derive"] }
anyhow.workspace = true