branching tests with registry and updating the configuration

This commit is contained in:
Godmode Galactus 2023-05-13 19:12:24 +02:00
parent 4e16fdff22
commit 2096e22555
No known key found for this signature in database
GPG Key ID: A04142C71ABB0DEA
6 changed files with 45 additions and 29 deletions

View File

@ -79,7 +79,7 @@ export class OpenbookConfigurator {
await this.program.methods.placeOrder(
side,
new BN(1000-1-i),
new BN(10000),
new BN(10),
new BN(1000000),
new BN(i),
placeOrder,
@ -112,7 +112,7 @@ export class OpenbookConfigurator {
new BN(1000+1+i),
new BN(10000),
new BN(1000000),
new BN(i),
new BN(i+nbOrders+1),
placeOrder,
false,
U64_MAX_BN,
@ -174,6 +174,21 @@ export class OpenbookConfigurator {
argument_sizes,
};
return [placeOrderCommand]
let consumeEvents = await this.program.methods.consumeEvents(
new BN(0),
).accounts(
{
eventQueue: PublicKey.default,
market: PublicKey.default,
}
).instruction();
let consumeEventsCommand : Command = {
instruction: Array.from(consumeEvents.data),
name: "consumeEvents",
argument_sizes: [8, 1]
}
return [placeOrderCommand, consumeEventsCommand]
}
}

View File

@ -56,7 +56,7 @@ export async function createMarket(program:Program<OpenbookV2>, anchorProvider:
confFilter: 0,
maxStalenessSlots: 100,
},
new BN(1000), new BN(1000), 0, 0, 0
new BN(1), new BN(1), 0, 0, 0
).accounts(
{
admin,

View File

@ -2,18 +2,19 @@ use std::{sync::Arc, time::Duration};
use clap::{command, Parser};
use futures::StreamExt;
use log::Log;
use solana_client::{nonblocking::pubsub_client::PubsubClient, rpc_config::RpcTransactionLogsConfig};
use solana_client::{
nonblocking::pubsub_client::PubsubClient, rpc_config::RpcTransactionLogsConfig,
};
use solana_rpc_client::nonblocking::rpc_client::RpcClient;
use solana_sdk::hash::Hash;
use tokio::sync::RwLock;
use solana_sdk::{hash::Hash, commitment_config::{CommitmentConfig, CommitmentLevel}};
use crate::{
openbook::simulate_place_orders::SimulateOpenbookV2PlaceOrder,
solana_runtime::{
accounts_fetching::AccountsFetchingTests, get_block::GetBlockTest, get_slot::GetSlotTest,
send_and_get_status_memo::SendAndConfrimTesting,
},
openbook::simulate_place_orders::SimulateOpenbookV2PlaceOrder,
test_registry::TestRegistry,
};
@ -63,27 +64,26 @@ impl Args {
let rpc_ws_addr = self.rpc_ws_addr.clone();
tokio::spawn(async move {
let pubsub_client = PubsubClient::new(&rpc_ws_addr).await.unwrap();
let res = pubsub_client.logs_subscribe(solana_client::rpc_config::RpcTransactionLogsFilter::All, RpcTransactionLogsConfig{
commitment: None
}).await;
let res = pubsub_client
.logs_subscribe(
solana_client::rpc_config::RpcTransactionLogsFilter::All,
RpcTransactionLogsConfig { commitment: None },
)
.await;
match res {
Ok(( mut stream, _)) => {
loop {
let log = stream.next().await;
match log {
Some(log) => {
for log_s in log.value.logs {
println!("{}", log_s);
}
},
None => {
Ok((mut stream, _)) => loop {
let log = stream.next().await;
match log {
Some(log) => {
for log_s in log.value.logs {
println!("{}", log_s);
}
}
None => {}
}
},
Err(e) => {
println!("error subscribing to the logs {}",e);
println!("error subscribing to the logs {}", e);
}
}
});
@ -96,7 +96,9 @@ impl Args {
}
if self.send_and_confirm_transaction || self.test_all {
test_registry.register(Box::new(SendAndConfrimTesting{block_hash: block_hash.clone()}));
test_registry.register(Box::new(SendAndConfrimTesting {
block_hash: block_hash.clone(),
}));
}
if self.get_slot || self.test_all {
@ -108,7 +110,7 @@ impl Args {
}
if self.simulate_openbook_v2 || self.test_all {
test_registry.register(Box::new(SimulateOpenbookV2PlaceOrder{block_hash} ));
test_registry.register(Box::new(SimulateOpenbookV2PlaceOrder { block_hash }));
}
test_registry

View File

@ -12,8 +12,8 @@ use anyhow::{bail, Context};
use clap::Parser;
use cli::Args;
use config::Config;
use tokio::sync::RwLock;
use solana_sdk::hash::Hash;
use tokio::sync::RwLock;
#[tokio::main(flavor = "multi_thread", worker_threads = 16)]
async fn main() -> anyhow::Result<()> {

View File

@ -27,7 +27,7 @@ struct Metric {
}
pub struct SendAndConfrimTesting {
pub block_hash: Arc<RwLock<Hash>>
pub block_hash: Arc<RwLock<Hash>>,
}
fn create_memo_tx(msg: &[u8], payer: &Keypair, blockhash: Hash) -> Transaction {

View File

@ -1,5 +1,5 @@
use async_trait::async_trait;
use crate::{cli::Args, config::Config};
use async_trait::async_trait;
#[async_trait]
pub trait TestingTask: Send + Sync {
@ -18,7 +18,6 @@ impl TestRegistry {
}
pub async fn start_testing(self, args: Args, config: Config) {
let tasks = self.tests.into_iter().map(|test| {
let args = args.clone();
let config = config.clone();