@@ -34,61 +34,58 @@ const SNAPSHOT_PATH = `${__dirname}/../../../../snapshot/`;
3434describe ( "Snapshot for Tendermint with Dynamic Validator" , function ( ) {
3535 const promiseExpect = new PromiseExpect ( ) ;
3636 const snapshotValidators = validators . slice ( 0 , 3 ) ;
37+ const { nodes } = withNodes ( this , {
38+ promiseExpect,
39+ overrideParams : {
40+ maxNumOfValidators : 3
41+ } ,
42+ validators : snapshotValidators . map ( ( signer , index ) => ( {
43+ signer,
44+ delegation : 5000 ,
45+ deposit : 10_000_000 - index // tie-breaker
46+ } ) ) ,
47+ modify : ( ) => {
48+ mkdirp . sync ( SNAPSHOT_PATH ) ;
49+ const snapshotPath = fs . mkdtempSync ( SNAPSHOT_PATH ) ;
50+ return {
51+ additionalArgv : [
52+ "--snapshot-path" ,
53+ snapshotPath ,
54+ "--config" ,
55+ SNAPSHOT_CONFIG
56+ ] ,
57+ nodeAdditionalProperties : {
58+ snapshotPath
59+ }
60+ } ;
61+ }
62+ } ) ;
3763
38- describe ( "Snapshot" , async function ( ) {
39- const { nodes } = withNodes ( this , {
40- promiseExpect,
41- overrideParams : {
42- maxNumOfValidators : 3
43- } ,
44- validators : snapshotValidators . map ( ( signer , index ) => ( {
45- signer,
46- delegation : 5000 ,
47- deposit : 10_000_000 - index // tie-breaker
48- } ) ) ,
49- modify : ( ) => {
50- mkdirp . sync ( SNAPSHOT_PATH ) ;
51- const snapshotPath = fs . mkdtempSync ( SNAPSHOT_PATH ) ;
52- return {
53- additionalArgv : [
54- "--snapshot-path" ,
55- snapshotPath ,
56- "--config" ,
57- SNAPSHOT_CONFIG
58- ] ,
59- nodeAdditionalProperties : {
60- snapshotPath
61- }
62- } ;
63- }
64+ it ( "should be exist after some time" , async function ( ) {
65+ const termWaiter = setTermTestTimeout ( this , {
66+ terms : 1
67+ } ) ;
68+ const termMetadata = await termWaiter . waitNodeUntilTerm ( nodes [ 0 ] , {
69+ target : 2 ,
70+ termPeriods : 1
6471 } ) ;
6572
66- it ( "should be exist after some time" , async function ( ) {
67- const termWaiter = setTermTestTimeout ( this , {
68- terms : 1
69- } ) ;
70- const termMetadata = await termWaiter . waitNodeUntilTerm ( nodes [ 0 ] , {
71- target : 2 ,
72- termPeriods : 1
73- } ) ;
74-
75- const blockHash = ( await nodes [ 0 ] . sdk . rpc . chain . getBlockHash (
76- termMetadata . lastTermFinishedBlockNumber
77- ) ) ! ;
78- const stateRoot = ( await nodes [ 0 ] . sdk . rpc . chain . getBlock (
79- blockHash
80- ) ) ! . stateRoot ;
81- expect (
82- fs . existsSync (
83- path . join (
84- nodes [ 0 ] . snapshotPath ,
85- blockHash . toString ( ) ,
86- stateRoot . toString ( )
87- )
73+ const blockHash = ( await nodes [ 0 ] . sdk . rpc . chain . getBlockHash (
74+ termMetadata . lastTermFinishedBlockNumber
75+ ) ) ! ;
76+ const stateRoot = ( await nodes [ 0 ] . sdk . rpc . chain . getBlock ( blockHash ) ) !
77+ . stateRoot ;
78+ expect (
79+ fs . existsSync (
80+ path . join (
81+ nodes [ 0 ] . snapshotPath ,
82+ blockHash . toString ( ) ,
83+ stateRoot . toString ( )
8884 )
89- ) . to . be . true ;
90- } ) ;
85+ )
86+ ) . to . be . true ;
9187 } ) ;
88+
9289 afterEach ( async function ( ) {
9390 promiseExpect . checkFulfilled ( ) ;
9491 } ) ;
0 commit comments