11"use strict" ;
22const assert = require ( "node:assert/strict" ) ;
33const fs = require ( "node:fs" ) ;
4+ const os = require ( "node:os" ) ;
45const path = require ( "node:path" ) ;
56const { spawnSync } = require ( "node:child_process" ) ;
67const test = require ( "node:test" ) ;
@@ -9,6 +10,28 @@ const DEPLOYMENT_DIR = path.join(__dirname, "..", "..", "deployment");
910const COMMON_PATH = path . join ( DEPLOYMENT_DIR , "common.bash" ) ;
1011const ENTRYPOINTS = [ "deploy.bash" , "leaf.bash" ] ;
1112
13+ test ( "Tari config patch disables read-ahead and remains idempotent" , ( ) => {
14+ const shim = fs . readFileSync ( path . join ( __dirname , "common" , "container_shim.sh" ) , "utf8" ) ;
15+ const fixture = shim . match ( / c o n s t c o n f i g T o m l = S t r i n g .r a w ` ( [ \s \S ] * ?) ` ; / ) [ 1 ] ;
16+ const dir = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , "tari-config-test-" ) ) ;
17+ try {
18+ const config = path . join ( dir , "config.toml" ) ;
19+ fs . writeFileSync ( config , fixture ) ;
20+ const args = [ path . join ( DEPLOYMENT_DIR , "patch-tari-config.sh" ) , config ,
21+ "--external-ip" , "127.0.0.1" , "--no-backup" ] ;
22+ const first = runBash ( args ) ;
23+ assert . equal ( first . status , 0 , first . stderr ) ;
24+ const contents = fs . readFileSync ( config , "utf8" ) ;
25+ assert . match ( contents , / \[ b a s e _ n o d e \. l m d b \] \s + n o _ r e a d _ a h e a d = t r u e / ) ;
26+ assert . match ( contents , / p r u n i n g _ h o r i z o n = 1 0 0 0 0 / ) ;
27+ const second = runBash ( args ) ;
28+ assert . equal ( second . status , 0 , second . stderr ) ;
29+ assert . equal ( fs . readFileSync ( config , "utf8" ) , contents ) ;
30+ } finally {
31+ fs . rmSync ( dir , { recursive : true , force : true } ) ;
32+ }
33+ } ) ;
34+
1235function runBash ( args , options = { } ) {
1336 return spawnSync ( "bash" , args , {
1437 cwd : path . join ( __dirname , ".." , ".." ) ,
0 commit comments