|
| 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 fs from 'node:fs'; |
| 10 | +import { workingDirectory } from '../utils.mjs'; |
| 11 | + |
| 12 | +// Clone the conformance harness. |
| 13 | +const harnessPath = path.join(workingDirectory, 'solana-conformance'); |
| 14 | +await $`git clone -b core-bpf https://github.com/buffalojoec/solana-conformance.git`; |
| 15 | + |
| 16 | +// Clone the test vectors. |
| 17 | +const testVectorsPath = path.join(harnessPath, 'impl', 'test-vectors'); |
| 18 | +await $`git clone https://github.com/firedancer-io/test-vectors.git ${testVectorsPath}`; |
| 19 | + |
| 20 | +// Clone the SolFuzz-Agave harness. |
| 21 | +const solFuzzAgavePath = path.join(harnessPath, 'impl', 'agave-v2.1.0'); |
| 22 | +await $`git clone -b agave-v2.1.0 http://github.com/firedancer-io/solfuzz-agave.git ${solFuzzAgavePath}`; |
| 23 | + |
| 24 | +// Move into the conformance harness. |
| 25 | +cd(harnessPath); |
| 26 | + |
| 27 | +// Build the environment. |
| 28 | +await $`bash install_ubuntu_lite.sh`; |
| 29 | + |
| 30 | +// // Build the Agave target with the builtin version. |
| 31 | +// await $`make -j -C impl lib/libsolfuzz_agave_v2.0.so`; |
| 32 | +// const builtinTargetPath = path.join( |
| 33 | +// harnessPath, |
| 34 | +// 'impl', |
| 35 | +// 'lib', |
| 36 | +// 'libsolfuzz_agave_v2.0.so', |
| 37 | +// ); |
| 38 | + |
| 39 | +// // Build the Agave target with the BPF version. |
| 40 | +// await $`PROGRAM="config" make -j -C impl lib/libsolfuzz_agave_v2.0_core_bpf.so`; |
| 41 | +// const bpfTargetPath = path.join( |
| 42 | +// harnessPath, |
| 43 | +// 'impl', |
| 44 | +// 'lib', |
| 45 | +// 'libsolfuzz_agave_core_bpf_config.so', |
| 46 | +// ); |
| 47 | + |
| 48 | +// // Run the tests. |
| 49 | +// const fixturesPath = path.join( |
| 50 | +// harnessPath, |
| 51 | +// 'test-vectors', |
| 52 | +// 'instr', |
| 53 | +// 'fixtures', |
| 54 | +// 'config', |
| 55 | +// ); |
| 56 | +// await $`solana-test-suite run-tests -i ${fixturesPath} -s ${builtinTargetPath} -t ${bpfTargetPath}`; |
| 57 | + |
| 58 | +// // Find the results files. |
| 59 | +// function findResultFile(dirPath) { |
| 60 | +// const files = fs.readdir(dirPath); |
| 61 | +// const resultFile = files.find(file => file.endsWith('.txt')); |
| 62 | +// if (!resultFile) throw new Error(`No result file found in ${dirPath}`); |
| 63 | +// return path.join(dirPath, resultFile); |
| 64 | +// } |
| 65 | + |
| 66 | +// const builtinResultsPath = findResultFile(path.join( |
| 67 | +// harnessPath, |
| 68 | +// 'test_results', |
| 69 | +// 'libsolfuzz_agave_v2.0', |
| 70 | +// )); |
| 71 | + |
| 72 | +// const bpfResultsPath = findResultFile(path.join( |
| 73 | +// harnessPath, |
| 74 | +// 'test_results', |
| 75 | +// 'libsolfuzz_agave_core_bpf_config', |
| 76 | +// )); |
| 77 | + |
| 78 | +// // Assert conformance. |
| 79 | +// const [builtinResults, bpfResults] = await Promise.all([ |
| 80 | +// fs.readFile(builtinResultsPath, 'utf-8'), |
| 81 | +// fs.readFile(bpfResultsPath, 'utf-8'), |
| 82 | +// ]); |
| 83 | + |
| 84 | +// if (builtinResults !== bpfResults) { |
| 85 | +// throw new Error(`Error: mismatches detected.`); |
| 86 | +// } else { |
| 87 | +// console.log('All tests passed.'); |
| 88 | +// } |
0 commit comments