|
| 1 | +#!/usr/bin/env zx |
| 2 | + |
| 3 | +// Firedancer conformance testing of the Core BPF Config program against its |
| 4 | +// original builtin implementation. |
| 5 | +// |
| 6 | +// Note: This script can only be run on Ubuntu. |
| 7 | + |
| 8 | +import 'zx/globals'; |
| 9 | +import { getProgramId, getProgramSharedObjectPath, workingDirectory } from '../utils.mjs'; |
| 10 | + |
| 11 | +// Clone the conformance harness. |
| 12 | +const harnessPath = path.join(workingDirectory, 'solana-conformance'); |
| 13 | +await $`git clone -b core-bpf https://github.com/buffalojoec/solana-conformance.git`; |
| 14 | + |
| 15 | +// Clone the test vectors. |
| 16 | +const testVectorsPath = path.join(harnessPath, 'impl', 'test-vectors'); |
| 17 | +await $`git clone https://github.com/firedancer-io/test-vectors.git ${testVectorsPath}`; |
| 18 | + |
| 19 | +// Clone the SolFuzz-Agave harness. |
| 20 | +const solFuzzAgavePath = path.join(harnessPath, 'impl', 'solfuzz-agave'); |
| 21 | +await $`git clone -b agave-v2.1.0 http://github.com/firedancer-io/solfuzz-agave.git ${solFuzzAgavePath}`; |
| 22 | + |
| 23 | +// Fetch protobuf files. |
| 24 | +await $`make -j -C ${solFuzzAgavePath} fetch_proto` |
| 25 | + |
| 26 | +// Move into the conformance harness. |
| 27 | +cd(harnessPath); |
| 28 | + |
| 29 | +// Build the environment. |
| 30 | +await $`bash install_ubuntu_lite.sh`; |
| 31 | + |
| 32 | +const solFuzzAgaveManifestPath = path.join(solFuzzAgavePath, 'Cargo.toml'); |
| 33 | +const solFuzzAgaveTargetPath = path.join( |
| 34 | + solFuzzAgavePath, |
| 35 | + 'target', |
| 36 | + 'x86_64-unknown-linux-gnu', |
| 37 | + 'release', |
| 38 | + 'libsolfuzz_agave.so', |
| 39 | +); |
| 40 | + |
| 41 | +const testTargetsDir = path.join(harnessPath, 'impl', 'lib'); |
| 42 | +await $`mkdir -p ${testTargetsDir}`; |
| 43 | + |
| 44 | +// Build the Agave target with the builtin version. |
| 45 | +const testTargetPathBuiltin = path.join(testTargetsDir, 'builtin.so'); |
| 46 | +await $`cargo build --manifest-path ${solFuzzAgaveManifestPath} \ |
| 47 | + --lib --release --target x86_64-unknown-linux-gnu`; |
| 48 | +await $`mv ${solFuzzAgaveTargetPath} ${testTargetPathBuiltin}`; |
| 49 | + |
| 50 | +// Build the Agave target with the BPF version. |
| 51 | +const testTargetPathCoreBpf = path.join(testTargetsDir, 'core_bpf.so'); |
| 52 | +await $`CORE_BPF_PROGRAM_ID=${getProgramId('program')} \ |
| 53 | + CORE_BPF_TARGET=${getProgramSharedObjectPath('program')} \ |
| 54 | + FORCE_RECOMPILE=true \ |
| 55 | + cargo build --manifest-path ${solFuzzAgaveManifestPath} \ |
| 56 | + --lib --release --target x86_64-unknown-linux-gnu --features core-bpf`; |
| 57 | +await $`mv ${solFuzzAgaveTargetPath} ${testTargetPathCoreBpf}`; |
| 58 | + |
| 59 | +// Run the tests. |
| 60 | +const fixturesPath = path.join(testVectorsPath, 'instr', 'fixtures', 'config'); |
| 61 | +await $`source test_suite_env/bin/activate && \ |
| 62 | + solana-test-suite run-tests \ |
| 63 | + -i ${fixturesPath} -s ${testTargetPathBuiltin} -t ${testTargetPathCoreBpf}`; |
| 64 | + |
| 65 | +// Assert conformance. |
| 66 | +// There should be no `failed_protobufs` directory. |
| 67 | +if (fs.existsSync('test_results/failed_protobufs')) { |
| 68 | + throw new Error(`Error: mismatches detected.`); |
| 69 | +} else { |
| 70 | + console.log('All tests passed.'); |
| 71 | +} |
0 commit comments