aboutsummaryrefslogtreecommitdiffstats
path: root/ethpipe/pipe_test.go
blob: 3b5dc5e4c47a5222736db311abb590a7e45bd284 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package ethpipe

import (
    "testing"

    "github.com/ethereum/go-ethereum/ethcrypto"
    "github.com/ethereum/go-ethereum/ethstate"
    "github.com/ethereum/go-ethereum/ethutil"
)

func Val(v interface{}) *ethutil.Value {
    return ethutil.NewValue(v)
}

func TestNew(t *testing.T) {
    pipe := New(nil)

    var addr, privy, recp, data []byte
    var object *ethstate.StateObject
    var key *ethcrypto.KeyPair

    world := pipe.World()
    world.Get(addr)
    world.Coinbase()
    world.IsMining()
    world.IsListening()
    world.State()
    peers := world.Peers()
    peers.Len()

    // Shortcut functions
    pipe.Balance(addr)
    pipe.Nonce(addr)
    pipe.Block(addr)
    pipe.Storage(addr, addr)
    pipe.ToAddress(privy)
    pipe.Exists(addr)
    // Doesn't change state
    pipe.Execute(addr, nil, Val(0), Val(1000000), Val(10))
    // Doesn't change state
    pipe.ExecuteObject(object, nil, Val(0), Val(1000000), Val(10))

    conf := world.Config()
    namereg := conf.Get("NameReg")
    namereg.Storage(addr)

    var err error
    // Transact
    err = pipe.Transact(key, recp, ethutil.NewValue(0), ethutil.NewValue(0), ethutil.NewValue(0), nil)
    if err != nil {
        t.Error(err)
    }
    // Create
    err = pipe.Transact(key, nil, ethutil.NewValue(0), ethutil.NewValue(0), ethutil.NewValue(0), data)
    if err != nil {
        t.Error(err)
    }
}