|
|
|
@ -74,6 +74,16 @@ func TestGetBlockByHashArgs(t *testing.T) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestGetBlockByHashEmpty(t *testing.T) { |
|
|
|
|
input := `[]` |
|
|
|
|
|
|
|
|
|
args := new(GetBlockByHashArgs) |
|
|
|
|
err := json.Unmarshal([]byte(input), &args) |
|
|
|
|
if err == nil { |
|
|
|
|
t.Error("Expected error but didn't get one") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestGetBlockByNumberArgs(t *testing.T) { |
|
|
|
|
input := `["0x1b4", false]` |
|
|
|
|
expected := new(GetBlockByNumberArgs) |
|
|
|
@ -94,6 +104,16 @@ func TestGetBlockByNumberArgs(t *testing.T) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestGetBlockByNumberEmpty(t *testing.T) { |
|
|
|
|
input := `[]` |
|
|
|
|
|
|
|
|
|
args := new(GetBlockByNumberArgs) |
|
|
|
|
err := json.Unmarshal([]byte(input), &args) |
|
|
|
|
if err == nil { |
|
|
|
|
t.Error("Expected error but didn't get one") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestNewTxArgs(t *testing.T) { |
|
|
|
|
input := `[{"from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155", |
|
|
|
|
"to": "0xd46e8dd67c5d32be8058bb8eb970870f072445675", |
|
|
|
@ -139,6 +159,16 @@ func TestNewTxArgs(t *testing.T) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestNewTxArgsEmpty(t *testing.T) { |
|
|
|
|
input := `[]` |
|
|
|
|
|
|
|
|
|
args := new(NewTxArgs) |
|
|
|
|
err := json.Unmarshal([]byte(input), &args) |
|
|
|
|
if err == nil { |
|
|
|
|
t.Error("Expected error but didn't get one") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestGetStorageArgs(t *testing.T) { |
|
|
|
|
input := `["0x407d73d8a49eeb85d32cf465507dd71d507100c1", "latest"]` |
|
|
|
|
expected := new(GetStorageArgs) |
|
|
|
@ -163,6 +193,16 @@ func TestGetStorageArgs(t *testing.T) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestGetStorageEmptyArgs(t *testing.T) { |
|
|
|
|
input := `[]` |
|
|
|
|
|
|
|
|
|
args := new(GetStorageArgs) |
|
|
|
|
err := json.Unmarshal([]byte(input), &args) |
|
|
|
|
if err == nil { |
|
|
|
|
t.Error("Expected error but didn't get one") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestGetStorageAtArgs(t *testing.T) { |
|
|
|
|
input := `["0x407d73d8a49eeb85d32cf465507dd71d507100c1", "0x0", "0x2"]` |
|
|
|
|
expected := new(GetStorageAtArgs) |
|
|
|
@ -192,6 +232,16 @@ func TestGetStorageAtArgs(t *testing.T) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestGetStorageAtEmptyArgs(t *testing.T) { |
|
|
|
|
input := `[]` |
|
|
|
|
|
|
|
|
|
args := new(GetStorageAtArgs) |
|
|
|
|
err := json.Unmarshal([]byte(input), &args) |
|
|
|
|
if err == nil { |
|
|
|
|
t.Error("Expected error but didn't get one") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestGetTxCountArgs(t *testing.T) { |
|
|
|
|
input := `["0x407d73d8a49eeb85d32cf465507dd71d507100c1", "latest"]` |
|
|
|
|
expected := new(GetTxCountArgs) |
|
|
|
@ -216,6 +266,16 @@ func TestGetTxCountArgs(t *testing.T) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestGetTxCountEmptyArgs(t *testing.T) { |
|
|
|
|
input := `[]` |
|
|
|
|
|
|
|
|
|
args := new(GetTxCountArgs) |
|
|
|
|
err := json.Unmarshal([]byte(input), &args) |
|
|
|
|
if err == nil { |
|
|
|
|
t.Error("Expected error but didn't get one") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestGetDataArgs(t *testing.T) { |
|
|
|
|
input := `["0xd5677cf67b5aa051bb40496e68ad359eb97cfbf8", "latest"]` |
|
|
|
|
expected := new(GetDataArgs) |
|
|
|
@ -240,6 +300,16 @@ func TestGetDataArgs(t *testing.T) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestGetDataEmptyArgs(t *testing.T) { |
|
|
|
|
input := `[]` |
|
|
|
|
|
|
|
|
|
args := new(GetDataArgs) |
|
|
|
|
err := json.Unmarshal([]byte(input), &args) |
|
|
|
|
if err == nil { |
|
|
|
|
t.Error("Expected error but didn't get one") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestFilterOptions(t *testing.T) { |
|
|
|
|
input := `[{ |
|
|
|
|
"fromBlock": "0x1", |
|
|
|
@ -286,6 +356,56 @@ func TestFilterOptions(t *testing.T) { |
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestFilterOptionsWords(t *testing.T) { |
|
|
|
|
input := `[{ |
|
|
|
|
"fromBlock": "latest", |
|
|
|
|
"toBlock": "pending" |
|
|
|
|
}]` |
|
|
|
|
expected := new(FilterOptions) |
|
|
|
|
expected.Earliest = 0 |
|
|
|
|
expected.Latest = -1 |
|
|
|
|
|
|
|
|
|
args := new(FilterOptions) |
|
|
|
|
if err := json.Unmarshal([]byte(input), &args); err != nil { |
|
|
|
|
t.Error(err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if expected.Earliest != args.Earliest { |
|
|
|
|
t.Errorf("Earliest shoud be %#v but is %#v", expected.Earliest, args.Earliest) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if expected.Latest != args.Latest { |
|
|
|
|
t.Errorf("Latest shoud be %#v but is %#v", expected.Latest, args.Latest) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestFilterOptionsNums(t *testing.T) { |
|
|
|
|
input := `[{ |
|
|
|
|
"fromBlock": 2, |
|
|
|
|
"toBlock": 3 |
|
|
|
|
}]` |
|
|
|
|
|
|
|
|
|
args := new(FilterOptions) |
|
|
|
|
err := json.Unmarshal([]byte(input), &args) |
|
|
|
|
switch err.(type) { |
|
|
|
|
case *DecodeParamError: |
|
|
|
|
break |
|
|
|
|
default: |
|
|
|
|
t.Errorf("Should have *DecodeParamError but instead have %T", err) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestFilterOptionsEmptyArgs(t *testing.T) { |
|
|
|
|
input := `[]` |
|
|
|
|
|
|
|
|
|
args := new(FilterOptions) |
|
|
|
|
err := json.Unmarshal([]byte(input), &args) |
|
|
|
|
if err == nil { |
|
|
|
|
t.Error("Expected error but didn't get one") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestDbArgs(t *testing.T) { |
|
|
|
|
input := `["0x74657374","0x6b6579","0x6d79537472696e67"]` |
|
|
|
|
expected := new(DbArgs) |
|
|
|
|