@@ -761,7 +761,7 @@ func TestTraceFilter(t *testing.T) {
761
761
blockTime := 100 * time .Millisecond
762
762
client , _ , ens := kit .EnsembleMinimal (t , kit .MockProofs (), kit .ThroughRPC ())
763
763
764
- ens .InterconnectAll ().BeginMining (blockTime )
764
+ bms := ens .InterconnectAll ().BeginMining (blockTime )
765
765
766
766
ctx , cancel := context .WithTimeout (context .Background (), time .Minute )
767
767
defer cancel ()
@@ -844,7 +844,7 @@ func TestTraceFilter(t *testing.T) {
844
844
require .NotNil (t , tracesAddressFilter )
845
845
require .NotEmpty (t , tracesAddressFilter )
846
846
847
- //we should only get our contract deploy transaction
847
+ // we should only get our contract deploy transaction
848
848
require .Len (t , tracesAddressFilter , 1 )
849
849
require .Equal (t , 1 , tracesAddressFilter [0 ].TransactionPosition )
850
850
require .Equal (t , hash , tracesAddressFilter [0 ].TransactionHash )
@@ -864,8 +864,32 @@ func TestTraceFilter(t *testing.T) {
864
864
require .NotNil (t , traces )
865
865
require .NotEmpty (t , traces )
866
866
867
- //we should only get the last two results from the first trace query
867
+ // we should only get the last two results from the first trace query
868
868
require .Len (t , tracesAfterCount , 2 )
869
869
require .Equal (t , traces [1 ].TransactionHash , tracesAfterCount [0 ].TransactionHash )
870
870
require .Equal (t , traces [2 ].TransactionHash , tracesAfterCount [1 ].TransactionHash )
871
+
872
+ // make sure we have null rounds in the chain
873
+ bms [0 ].InjectNulls (2 )
874
+ ch , err := client .ChainNotify (ctx )
875
+ require .NoError (t , err )
876
+ hc := <- ch // current
877
+ require .Equal (t , store .HCCurrent , hc [0 ].Type )
878
+ beforeNullHeight := hc [0 ].Val .Height ()
879
+ hc = <- ch // wait for next block
880
+ require .Equal (t , store .HCApply , hc [0 ].Type )
881
+ afterNullHeight := hc [0 ].Val .Height ()
882
+ require .Greater (t , afterNullHeight , beforeNullHeight + 1 )
883
+ hc = <- ch // one more, so "latest" points to the block after nulls
884
+ require .Equal (t , store .HCApply , hc [0 ].Type )
885
+
886
+ // define filter criteria that spans a null round so it has to at lest consider it
887
+ toBlock = "latest"
888
+ filter = ethtypes.EthTraceFilterCriteria {
889
+ FromBlock : & fromBlock ,
890
+ ToBlock : & toBlock ,
891
+ }
892
+ traces , err = client .EthTraceFilter (ctx , filter )
893
+ require .NoError (t , err )
894
+ require .Len (t , traces , 3 ) // still the same traces as before
871
895
}
0 commit comments