Spin up a solana test validator and N bonsol prover nodes to be used in rust test
x86-64amddue to currentstark to snarkc++ constraint - virtualization will also not work here- ports
8899and8900must be free to be used by thesolana-test-validator - both
bonsol.soand your onchain program must be located in ______ .
- remove
figmenttoml deserializer and leverage a library that usesSerializationtrait for programmatic bonsol-node configs - pull bonsol-node docker image from a docker repository programmatically rather then having to build from the bonsol repository
- build dockerfile image within
https://github.com/bonsol-collective/bonsol/blob/main/Dockerfileas the imagebonsol-node/latestso you have working image that the test harness expects. the image must be namedbonsol-node/latest cargo add ctorand other required libraries
initiate the rust prover network harness with a ctor constructor before implementing tests.
then run your tests like: cargo test test_db -- --nocapture export PROVER_NETWORK_STATE="start|stop|fullcycle"
const BONSOL_PROVER_NODE_COUNT: usize = 1;
const SOLANA_RPC_URL: &'static str = "http://localhost:8899";
#[ctor::ctor]
fn init() {
let prover_network_state = ProverNetworkState::from_env().unwrap();
match prover_network_state {
ProverNetworkState::Start | ProverNetworkState::FullCycle => {
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async {
let upgrade_authority = solana_sdk::pubkey::new_rand().to_string();
let callback_program_address = solana_sdk::pubkey::new_rand().to_string();
bonsol::solana::start(
upgrade_authority.as_str(),
callback_program_address.as_str(),
)
.await
.unwrap();
bonsol::prover_network::start(BONSOL_PROVER_NODE_COUNT)
.await
.unwrap();
});
}
_ => return,
}
}
#[ctor::dtor]
fn end() {
let prover_network_state = ProverNetworkState::from_env().unwrap();
match prover_network_state {
ProverNetworkState::Stop | ProverNetworkState::FullCycle => {
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(async {
bonsol::solana::stop().await?;
bonsol::prover_network::stop(BONSOL_PROVER_NODE_COUNT).await?;
})
}
_ => return,
}
}
#[tokio::test]
async fn test_bonsol_test_1() -> anyhow::Result<()> {
/*
Implement test code here ...
*/
}
#[tokio::test]
async fn test_bonsol_final() -> anyhow::Result<()> {
/*
Implement test code here ... */
}