use fehler::throws;
use program_client;
use trdelnik_client::{anyhow::Result, *};
#[throws]
#[fixture]
async fn init_fixture() -> Fixture {
let mut fixture = Fixture::new();
fixture.deploy().await?;
fixture
}
#[trdelnik_test]
async fn test_happy_path(#[future] init_fixture: Result<Fixture>) {
let default_fixture = Fixture::new();
let fixture = init_fixture.await?;
assert_eq!(fixture.program, default_fixture.program);
}
struct Fixture {
client: Client,
program: Keypair,
state: Keypair,
}
impl Fixture {
fn new() -> Self {
Fixture {
client: Client::new(system_keypair(0)),
program: program_keypair(1),
state: keypair(42),
}
}
#[throws]
async fn deploy(&mut self) {
self.client
.airdrop(self.client.payer().pubkey(), 5_000_000_000)
.await?;
}
}