aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/api/api_test.go
blob: f1a47944dbbc7ba4aac64505eed0031cfa9aee90 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package api

import (
    "testing"

    "github.com/ethereum/go-ethereum/rpc/codec"
)

func TestParseApiString(t *testing.T) {
    apis, err := ParseApiString("", codec.JSON, nil, nil)
    if err == nil {
        t.Errorf("Expected an err from parsing empty API string but got nil")
    }

    if len(apis) != 0 {
        t.Errorf("Expected 0 apis from empty API string")
    }

    apis, err = ParseApiString("eth", codec.JSON, nil, nil)
    if err != nil {
        t.Errorf("Expected nil err from parsing empty API string but got %v", err)
    }

    if len(apis) != 1 {
        t.Errorf("Expected 1 apis but got %d - %v", apis, apis)
    }

    apis, err = ParseApiString("eth,eth", codec.JSON, nil, nil)
    if err != nil {
        t.Errorf("Expected nil err from parsing empty API string but got \"%v\"", err)
    }

    if len(apis) != 2 {
        t.Errorf("Expected 2 apis but got %d - %v", apis, apis)
    }

    apis, err = ParseApiString("eth,invalid", codec.JSON, nil, nil)
    if err == nil {
        t.Errorf("Expected an err but got no err")
    }

}