mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
Add filter API test
This commit is contained in:
parent
cf2039fe62
commit
5b4438d6bb
2 changed files with 23 additions and 8 deletions
|
|
@ -29,6 +29,8 @@ func TestUnmarshalJSONNewFilterArgs(t *testing.T) {
|
|||
var (
|
||||
fromBlock rpc.BlockNumber = 0x123435
|
||||
toBlock rpc.BlockNumber = 0xabcdef
|
||||
fromBlockHash = common.HexToHash("ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1ca3")
|
||||
toBlockHash = common.HexToHash("084a792d2f8b16a62b882fd56f7860c07bf5fa91dd8a2ae7e809e5180fef0b39")
|
||||
address0 = common.HexToAddress("70c87d191324e6712a591f304b4eedef6ad9bb9d")
|
||||
address1 = common.HexToAddress("9b2055d370f73ec7d8a03e965129118dc8f5bf83")
|
||||
topic0 = common.HexToHash("3ac225168df54212a25c1c01fd35bebfea408fdac2e31ddd6f80a4bbf9a5f1ca")
|
||||
|
|
@ -182,4 +184,17 @@ func TestUnmarshalJSONNewFilterArgs(t *testing.T) {
|
|||
if len(test7.Topics[2]) != 0 {
|
||||
t.Fatalf("expected 0 topics, got %d topics", len(test7.Topics[2]))
|
||||
}
|
||||
|
||||
// from, to block hash
|
||||
var test8 FilterCriteria
|
||||
vector = fmt.Sprintf(`{"fromBlock":"%s","toBlock":"%s"}`, fromBlockHash.Hex(), toBlockHash.Hex())
|
||||
if err := json.Unmarshal([]byte(vector), &test8); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if *test8.FromBlockHash != fromBlockHash {
|
||||
t.Fatalf("expected FromBlock %s, got %s", fromBlockHash.Hex(), test8.FromBlockHash.Hex())
|
||||
}
|
||||
if *test8.ToBlockHash != toBlockHash {
|
||||
t.Fatalf("expected ToBlock %s, got %s", toBlockHash.Hex(), test8.ToBlockHash.Hex())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ func (bnh *BlockNumberOrHash) UnmarshalJSON(data []byte) error {
|
|||
|
||||
// IsHash returns true iff the value is a block hash.
|
||||
func (bnh BlockNumberOrHash) IsHash() bool {
|
||||
return bnh[0] == '"' && bnh[len(bnh)-1] == '"' && len(bnh) == 44
|
||||
return bnh[0] == '"' && bnh[len(bnh)-1] == '"' && len(bnh) == 68
|
||||
}
|
||||
|
||||
// Hash returns the hash value, or nil if the value is not a hash.
|
||||
|
|
|
|||
Loading…
Reference in a new issue