@@ -3,6 +3,7 @@ package baseapp
33import (
44 "bytes"
55 "encoding/binary"
6+ "encoding/json"
67 "fmt"
78 "io/ioutil"
89 "math/rand"
@@ -1821,17 +1822,34 @@ func TestListSnapshots(t *testing.T) {
18211822 require .NoError (t , err )
18221823 defer teardown ()
18231824
1825+ expected := abci.ResponseListSnapshots {Snapshots : []* abci.Snapshot {
1826+ {Height : 4 , Format : 1 , Chunks : 2 },
1827+ {Height : 2 , Format : 1 , Chunks : 1 },
1828+ }}
1829+
18241830 resp := app .ListSnapshots (abci.RequestListSnapshots {})
1825- for _ , s := range resp .Snapshots {
1831+ queryResponse := app .Query (abci.RequestQuery {
1832+ Path : "/app/snapshots" ,
1833+ })
1834+
1835+ queryListSnapshotsResp := abci.ResponseListSnapshots {}
1836+ err = json .Unmarshal (queryResponse .Value , & queryListSnapshotsResp )
1837+ require .NoError (t , err )
1838+
1839+ for i , s := range resp .Snapshots {
1840+ querySnapshot := queryListSnapshotsResp .Snapshots [i ]
1841+ // we check that the query snapshot and function snapshot are equal
1842+ // Then we check that the hash and metadata are not empty. We atm
1843+ // do not have a good way to generate the expected value for these.
1844+ assert .Equal (t , * s , * querySnapshot )
18261845 assert .NotEmpty (t , s .Hash )
18271846 assert .NotEmpty (t , s .Metadata )
1847+ // Set hash and metadata to nil, so we can check the other snapshot
1848+ // fields against expected
18281849 s .Hash = nil
18291850 s .Metadata = nil
18301851 }
1831- assert .Equal (t , abci.ResponseListSnapshots {Snapshots : []* abci.Snapshot {
1832- {Height : 4 , Format : 1 , Chunks : 2 },
1833- {Height : 2 , Format : 1 , Chunks : 1 },
1834- }}, resp )
1852+ assert .Equal (t , expected , resp )
18351853}
18361854
18371855func TestSnapshotWithPruning (t * testing.T ) {
0 commit comments