@ -363,7 +363,7 @@ func TestLogFilter(t *testing.T) {
// match all
0 : { FilterCriteria { } , allLogs , "" } ,
// match none due to no matching addresses
1 : { FilterCriteria { Addresses : [ ] common . Address { { } , notUsedAddress } , Topics : [ ] [ ] common . Hash { allLogs [ 0 ] . Topics } } , [ ] * types . Log { } , "" } ,
1 : { FilterCriteria { Addresses : [ ] common . Address { { } , notUsedAddress } , Topics : [ ] [ ] common . Hash { nil } } , [ ] * types . Log { } , "" } ,
// match logs based on addresses, ignore topics
2 : { FilterCriteria { Addresses : [ ] common . Address { firstAddr } } , allLogs [ : 2 ] , "" } ,
// match none due to no matching topics (match with address)
@ -384,6 +384,8 @@ func TestLogFilter(t *testing.T) {
10 : { FilterCriteria { FromBlock : big . NewInt ( 1 ) , ToBlock : big . NewInt ( 2 ) , Topics : [ ] [ ] common . Hash { { secondTopic } } } , allLogs [ 3 : 4 ] , "" } ,
// all "mined" and pending logs with topic firstTopic
11 : { FilterCriteria { FromBlock : big . NewInt ( rpc . LatestBlockNumber . Int64 ( ) ) , ToBlock : big . NewInt ( rpc . PendingBlockNumber . Int64 ( ) ) , Topics : [ ] [ ] common . Hash { { firstTopic } } } , expectedCase11 , "" } ,
// match all logs due to wildcard topic
12 : { FilterCriteria { Topics : [ ] [ ] common . Hash { nil } } , allLogs [ 1 : ] , "" } ,
}
)
@ -459,7 +461,7 @@ func TestPendingLogsSubscription(t *testing.T) {
firstTopic = common . HexToHash ( "0x1111111111111111111111111111111111111111111111111111111111111111" )
secondTopic = common . HexToHash ( "0x2222222222222222222222222222222222222222222222222222222222222222" )
thirdTopic = common . HexToHash ( "0x3333333333333333333333333333333333333333333333333333333333333333" )
forthTopic = common . HexToHash ( "0x4444444444444444444444444444444444444444444444444444444444444444" )
fou rthTopic = common . HexToHash ( "0x4444444444444444444444444444444444444444444444444444444444444444" )
notUsedTopic = common . HexToHash ( "0x9999999999999999999999999999999999999999999999999999999999999999" )
allLogs = [ ] core . PendingLogsEvent {
@ -471,7 +473,7 @@ func TestPendingLogsSubscription(t *testing.T) {
{ Logs : [ ] * types . Log {
{ Address : thirdAddress , Topics : [ ] common . Hash { firstTopic } , BlockNumber : 5 } ,
{ Address : thirdAddress , Topics : [ ] common . Hash { thirdTopic } , BlockNumber : 5 } ,
{ Address : thirdAddress , Topics : [ ] common . Hash { forthTopic } , BlockNumber : 5 } ,
{ Address : thirdAddress , Topics : [ ] common . Hash { fou rthTopic } , BlockNumber : 5 } ,
{ Address : firstAddr , Topics : [ ] common . Hash { firstTopic } , BlockNumber : 5 } ,
} } ,
}
@ -493,7 +495,7 @@ func TestPendingLogsSubscription(t *testing.T) {
// match all
{ FilterCriteria { } , convertLogs ( allLogs ) , nil , nil } ,
// match none due to no matching addresses
{ FilterCriteria { Addresses : [ ] common . Address { { } , notUsedAddress } , Topics : [ ] [ ] common . Hash { { } } } , [ ] * types . Log { } , nil , nil } ,
{ FilterCriteria { Addresses : [ ] common . Address { { } , notUsedAddress } , Topics : [ ] [ ] common . Hash { nil } } , [ ] * types . Log { } , nil , nil } ,
// match logs based on addresses, ignore topics
{ FilterCriteria { Addresses : [ ] common . Address { firstAddr } } , append ( convertLogs ( allLogs [ : 2 ] ) , allLogs [ 5 ] . Logs [ 3 ] ) , nil , nil } ,
// match none due to no matching topics (match with address)
@ -505,7 +507,7 @@ func TestPendingLogsSubscription(t *testing.T) {
// block numbers are ignored for filters created with New***Filter, these return all logs that match the given criteria when the state changes
{ FilterCriteria { Addresses : [ ] common . Address { firstAddr } , FromBlock : big . NewInt ( 2 ) , ToBlock : big . NewInt ( 3 ) } , append ( convertLogs ( allLogs [ : 2 ] ) , allLogs [ 5 ] . Logs [ 3 ] ) , nil , nil } ,
// multiple pending logs, should match only 2 topics from the logs in block 5
{ FilterCriteria { Addresses : [ ] common . Address { thirdAddress } , Topics : [ ] [ ] common . Hash { { firstTopic , forthTopic } } } , [ ] * types . Log { allLogs [ 5 ] . Logs [ 0 ] , allLogs [ 5 ] . Logs [ 2 ] } , nil , nil } ,
{ FilterCriteria { Addresses : [ ] common . Address { thirdAddress } , Topics : [ ] [ ] common . Hash { { firstTopic , fou rthTopic } } } , [ ] * types . Log { allLogs [ 5 ] . Logs [ 0 ] , allLogs [ 5 ] . Logs [ 2 ] } , nil , nil } ,
}
)