refactor: use system faucet and vaults to supply accounts from genesis

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
Daniil Polyakov
2026-05-15 01:34:01 +03:00
co-authored by Copilot
parent 89d1b95738
commit 9075f30f19
71 changed files with 992 additions and 726 deletions
@@ -1,9 +1,10 @@
use std::time::Duration;
use anyhow::Result;
use common::transaction::NSSATransaction;
use integration_tests::{TIME_TO_WAIT_FOR_BLOCK_SECONDS, TestContext, public_mention};
use log::info;
use nssa::program::Program;
use nssa::{SYSTEM_FAUCET_ACCOUNT_ID, program::Program, public_transaction};
use sequencer_service_rpc::RpcClient as _;
use tokio::test;
use wallet::{
@@ -344,3 +345,90 @@ async fn successful_transfer_using_to_label() -> Result<()> {
Ok(())
}
#[test]
async fn cannot_transfer_funds_from_system_faucet_account() -> Result<()> {
let ctx = TestContext::new().await?;
let recipient = ctx.existing_public_accounts()[0];
let recipient_balance_before = ctx
.sequencer_client()
.get_account_balance(recipient)
.await?;
let faucet_balance_before = ctx
.sequencer_client()
.get_account_balance(SYSTEM_FAUCET_ACCOUNT_ID)
.await?;
let amount = 1_u128;
let message = public_transaction::Message::try_new(
Program::authenticated_transfer_program().id(),
vec![SYSTEM_FAUCET_ACCOUNT_ID, recipient],
vec![],
authenticated_transfer_core::Instruction::Transfer { amount },
)?;
let tx = nssa::PublicTransaction::new(
message,
nssa::public_transaction::WitnessSet::from_raw_parts(vec![]),
);
let tx_hash = ctx
.sequencer_client()
.send_transaction(NSSATransaction::Public(tx))
.await?;
info!("Waiting for next block creation");
tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await;
let recipient_balance_after = ctx
.sequencer_client()
.get_account_balance(recipient)
.await?;
let faucet_balance_after = ctx
.sequencer_client()
.get_account_balance(SYSTEM_FAUCET_ACCOUNT_ID)
.await?;
let tx_on_chain = ctx.sequencer_client().get_transaction(tx_hash).await?;
assert_eq!(recipient_balance_after, recipient_balance_before);
assert_eq!(faucet_balance_after, faucet_balance_before);
assert!(tx_on_chain.is_none());
Ok(())
}
#[test]
async fn can_transfer_funds_to_system_faucet_account() -> Result<()> {
let mut ctx = TestContext::new().await?;
let sender = ctx.existing_public_accounts()[0];
let sender_balance_before = ctx.sequencer_client().get_account_balance(sender).await?;
let faucet_balance_before = ctx
.sequencer_client()
.get_account_balance(SYSTEM_FAUCET_ACCOUNT_ID)
.await?;
let amount = 100_u128;
let command = Command::AuthTransfer(AuthTransferSubcommand::Send {
from: public_mention(sender),
to: Some(public_mention(SYSTEM_FAUCET_ACCOUNT_ID)),
to_npk: None,
to_vpk: None,
to_identifier: Some(0),
amount,
});
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;
let sender_balance_after = ctx.sequencer_client().get_account_balance(sender).await?;
let faucet_balance_after = ctx
.sequencer_client()
.get_account_balance(SYSTEM_FAUCET_ACCOUNT_ID)
.await?;
assert_eq!(sender_balance_after, sender_balance_before - amount);
assert_eq!(faucet_balance_after, faucet_balance_before + amount);
Ok(())
}
+4 -4
View File
@@ -125,9 +125,9 @@ fn indexer_test_run_ffi() -> Result<()> {
let last_block_indexer_ffi = unsafe { *last_block_indexer_ffi_res.value };
info!("Last block on ind ffi now is {last_block_indexer_ffi}");
info!("Last block on indexer FFI now is {last_block_indexer_ffi}");
assert!(last_block_indexer_ffi > 1);
assert!(last_block_indexer_ffi > 0);
Ok(())
}
@@ -149,9 +149,9 @@ fn indexer_ffi_block_batching() -> Result<()> {
let last_block_indexer = unsafe { *last_block_indexer_ffi_res.value };
info!("Last block on ind now is {last_block_indexer}");
info!("Last block on indexer FFI now is {last_block_indexer}");
assert!(last_block_indexer > 1);
assert!(last_block_indexer > 0);
let before_ffi = FfiOption::<u64>::from_none();
let limit = 100;
+3 -3
View File
@@ -28,7 +28,7 @@ use nssa_core::{
account::{AccountWithMetadata, Nonce, data::Data},
encryption::ViewingPublicKey,
};
use sequencer_core::config::GenesisTransaction;
use sequencer_core::config::GenesisAction;
use sequencer_service_rpc::RpcClient as _;
use tokio::test;
@@ -94,10 +94,10 @@ impl TpsTestManager {
/// Generates a sequencer configuration with initial balance in a number of public accounts.
/// The transactions generated with the function `build_public_txs` will be valid in a node
/// started with the config from this method.
fn generate_genesis(&self) -> Vec<GenesisTransaction> {
fn generate_genesis(&self) -> Vec<GenesisAction> {
self.public_keypairs
.iter()
.map(|(_, account_id)| GenesisTransaction::SupplyPublicAccount {
.map(|(_, account_id)| GenesisAction::SupplyAccount {
account_id: *account_id,
balance: 10,
})