| 39 | const io = new Transform({ |
| 40 | encoding: 'utf-8', |
| 41 | transform(chunk, encoding, respond) { |
| 42 | chunk = chunk.toString(); |
| 43 | if (checkpoints.has(step)) { |
| 44 | checkpointOutput += chunk; |
| 45 | } else { |
| 46 | checkpointOutput = ''; |
| 47 | } |
| 48 | // Uncomment to see CLI output during test |
| 49 | // process.stdout.write(chunk); |
| 50 | |
| 51 | const isStep = chunk.endsWith(OUTPUT_END_SEQ); |
| 52 | if (isStep) { |
| 53 | for (const input of stepInputs[step]) { |
| 54 | this.push(input); |
| 55 | } |
| 56 | if (checkpoints.has(step)) { |
| 57 | // Assert proposals output contains expected info for no pending proposals |
| 58 | assert.match(checkpointOutput, /No more proposals/); |
| 59 | } |
| 60 | step++; |
| 61 | } else if (chunk.includes('Error:')) { |
| 62 | return respond(chunk); |
| 63 | } |
| 64 | if (chunk.includes('👋')) { |
| 65 | child.stdin.end(); // send EOF to child so it can exit cleanly |
| 66 | } |
| 67 | respond(); |
| 68 | } |
| 69 | }); |
| 70 | const child = spawn('node', [CLI_EXEC, WALLETS.BTC.SINGLE_SIG, ...cmdOpts], CLI_OPTS); |
| 71 | child.stderr.pipe(process.stderr); |