@@ -702,24 +702,33 @@ func TestABCI_CreateQueryContext(t *testing.T) {
702702 require .NoError (t , err )
703703
704704 testCases := []struct {
705- name string
706- height int64
707- prove bool
708- expErr bool
705+ name string
706+ height int64
707+ headerHeight int64
708+ prove bool
709+ expErr bool
709710 }{
710- {"valid height" , 2 , true , false },
711- {"future height" , 10 , true , true },
712- {"negative height, prove=true" , - 1 , true , true },
713- {"negative height, prove=false" , - 1 , false , true },
711+ {"valid height" , 2 , 2 , true , false },
712+ {"valid height with different initial height" , 2 , 1 , true , false },
713+ {"future height" , 10 , 10 , true , true },
714+ {"negative height, prove=true" , - 1 , - 1 , true , true },
715+ {"negative height, prove=false" , - 1 , - 1 , false , true },
714716 }
715717
716718 for _ , tc := range testCases {
717719 t .Run (tc .name , func (t * testing.T ) {
718- _ , err := app .CreateQueryContext (tc .height , tc .prove )
720+ if tc .headerHeight != tc .height {
721+ _ , err := app .InitChain (& abci.RequestInitChain {
722+ InitialHeight : tc .headerHeight ,
723+ })
724+ require .NoError (t , err )
725+ }
726+ ctx , err := app .CreateQueryContext (tc .height , tc .prove )
719727 if tc .expErr {
720728 require .Error (t , err )
721729 } else {
722730 require .NoError (t , err )
731+ require .Equal (t , tc .height , ctx .BlockHeight ())
723732 }
724733 })
725734 }
0 commit comments