#include #include #include #include // External functions from our CUDA implementation extern "C" void RinHash( const uint32_t* version, const uint32_t* prev_block, const uint32_t* merkle_root, const uint32_t* timestamp, const uint32_t* bits, const uint32_t* nonce, uint8_t* output ); extern "C" void RinHash_mine( const uint32_t* version, const uint32_t* prev_block, const uint32_t* merkle_root, const uint32_t* timestamp, const uint32_t* bits, uint32_t start_nonce, uint32_t num_nonces, uint32_t* found_nonce, uint8_t* target_hash, uint8_t* best_hash ); void print_hex(const char* label, const uint8_t* data, size_t len) { printf("%s: ", label); for (size_t i = 0; i < len; i++) { printf("%02x", data[i]); } printf("\n"); } int main(int argc, char* argv[]) { printf("RinHash CUDA Miner Test\n"); printf("=======================\n\n"); // Initialize CUDA cudaError_t cudaStatus = cudaSetDevice(0); if (cudaStatus != cudaSuccess) { fprintf(stderr, "cudaSetDevice failed! Do you have a CUDA-capable GPU?\n"); return 1; } // Test data - sample block header uint32_t version = 0x20000000; uint32_t prev_block[8] = { 0x12345678, 0x9abcdef0, 0x12345678, 0x9abcdef0, 0x12345678, 0x9abcdef0, 0x12345678, 0x9abcdef0 }; uint32_t merkle_root[8] = { 0xabcdef12, 0x34567890, 0xabcdef12, 0x34567890, 0xabcdef12, 0x34567890, 0xabcdef12, 0x34567890 }; uint32_t timestamp = 0x5f123456; uint32_t bits = 0x1d00ffff; uint32_t nonce = 0x12345678; uint8_t output[32]; printf("Testing single hash...\n"); RinHash(&version, prev_block, merkle_root, ×tamp, &bits, &nonce, output); print_hex("Hash result", output, 32); printf("\nTesting mining (trying 1000 nonces)...\n"); uint32_t found_nonce; uint8_t target_hash[32]; uint8_t best_hash[32]; // Set a target (easier than difficulty) memset(target_hash, 0xff, 32); RinHash_mine(&version, prev_block, merkle_root, ×tamp, &bits, 0, 1000, &found_nonce, target_hash, best_hash); printf("Found nonce: 0x%08x\n", found_nonce); print_hex("Best hash", best_hash, 32); printf("\nTest completed successfully!\n"); return 0; }