GithubHelp home page GithubHelp logo

mollusk's Introduction

Mollusk

Solana program testing tools.

Harness

The harness is designed to directly invoke the loaded executable program using the BPF Loader, bypassing any transaction sanitization and runtime checks, and instead directly processing the instruction with the BPF Loader.

Example:

let program_id = Pubkey::new_unique();
let key1 = Pubkey::new_unique();
let key2 = Pubkey::new_unique();

let instruction = Instruction::new_with_bytes(
    program_id,
    &[],
    vec![
        AccountMeta::new(key1, false),
        AccountMeta::new_readonly(key2, false),
    ],
);

let accounts = vec![
    (key1, AccountSharedData::new(10_000, 0, &system_program::id())),
    (key2, AccountSharedData::new(10_000, 0, &system_program::id())),
];

let mollusk = Mollusk::new(program_id, "my_program");

let result = mollusk.process_instruction(instruction, accounts);

Bencher

Mollusk also offers a compute unit usage bencher for profiling a program's compute unit usage.

Example:

MolluskComputeUnitBencher::new(mollusk)
    .benchmark(BENCHMARK_COMPUTE_UNITS)
    .bench("bench1", instruction1, accounts1)
    .bench("bench2", instruction2, accounts2)
    .bench("bench3", instruction3, accounts3)
    .iterations(100)
    .must_pass(true)
    .out_dir("../target/benches")
    .execute();

You can invoke this benchmark test with cargo bench.

Mollusk will output bench details to the output directory in both JSON and Markdown.

Markdown example:

Name Median Mark Delta
bench1 579 +129
bench2 1,204 +754
bench3 2,811 +2,361

mollusk's People

Contributors

buffalojoec avatar waitfreemaxi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.