forked from 0xPolygonHermez/zkevm-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
endpoints_web3_test.go
46 lines (34 loc) · 1.02 KB
/
endpoints_web3_test.go
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
43
44
45
46
package jsonrpc
import (
"encoding/json"
"testing"
"github.com/0xPolygonHermez/zkevm-node"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestClientVersion(t *testing.T) {
s, _, _ := newSequencerMockedServer(t)
defer s.Stop()
res, err := s.JSONRPCCall("web3_clientVersion")
require.NoError(t, err)
assert.Equal(t, float64(1), res.ID)
assert.Equal(t, "2.0", res.JSONRPC)
assert.Nil(t, res.Error)
var result string
err = json.Unmarshal(res.Result, &result)
require.NoError(t, err)
assert.Equal(t, zkevm.Version, result)
}
func TestSha3(t *testing.T) {
s, _, _ := newSequencerMockedServer(t)
defer s.Stop()
res, err := s.JSONRPCCall("web3_sha3", "0x68656c6c6f20776f726c64")
require.NoError(t, err)
assert.Equal(t, float64(1), res.ID)
assert.Equal(t, "2.0", res.JSONRPC)
assert.Nil(t, res.Error)
var result string
err = json.Unmarshal(res.Result, &result)
require.NoError(t, err)
assert.Equal(t, "0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad", result)
}