Skip to content

Commit c28238c

Browse files
authored
Merge pull request #365 from rsksmart/show-powpeg-node-jar-sha256
Shows powpeg node jar sha256 hash.
2 parents b8c7bbd + 701f53d commit c28238c

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ const colors = require('colors/safe');
44
const LineWrapper = require('stream-line-wrapper');
55
const expect = require('chai').expect;
66
const path = require('node:path');
7+
const crypto = require('node:crypto');
8+
const fs = require('node:fs');
79

810
const BitcoinRunner = require('./lib/bitcoin-runner').Runner;
911

@@ -112,6 +114,25 @@ function validateBitcoinRunnerConfig(bitcoinConf, configs){
112114
}
113115
};
114116

117+
async function printPowpegJarSha256() {
118+
const jarPath = process.env.POWPEG_NODE_JAR_PATH;
119+
if (!jarPath) return;
120+
try {
121+
console.log(`Computing sha256 for powpeg node jar (POWPEG_NODE_JAR_PATH): ${jarPath}...`);
122+
const hash = crypto.createHash('sha256');
123+
const stream = fs.createReadStream(jarPath);
124+
await new Promise((resolve, reject) => {
125+
stream.on('data', (chunk) => hash.update(chunk));
126+
stream.on('end', resolve);
127+
stream.on('error', reject);
128+
});
129+
console.log(`Powpeg node jar sha256: ${hash.digest('hex')}`);
130+
console.log("");
131+
} catch (e) {
132+
console.log(`Could not compute sha256 for powpeg node jar (${jarPath}): ${e.message}`);
133+
}
134+
}
135+
115136
process.on('SIGTERM', function() {
116137
process.stdout.write( "\nGracefully shutting down from SIGTERM." );
117138
shutdownHooks();
@@ -138,6 +159,8 @@ before(async () => {
138159
const runnersConfig = config.runners || {};
139160
const initConfig = config.init || {};
140161

162+
await printPowpegJarSha256();
163+
141164
// Start bitcoin daemon if needed
142165
if (runnersConfig.bitcoin == null) {
143166
const btcStderr = new LineWrapper({ prefix: BITCOIND_OUTPUT });

0 commit comments

Comments
 (0)