diff options
author | obscuren <geffobscura@gmail.com> | 2014-08-04 22:25:53 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2014-08-04 22:25:53 +0800 |
commit | 342cc122b43f01301d0188de1e333c32ed64ae8c (patch) | |
tree | a8bfb3288a5866de2a315319124e7a6b908f7bd3 /ethpipe/pipe_test.go | |
parent | 03ce15df4c7ef51d4373233ab5c3766282b31771 (diff) | |
download | go-tangerine-342cc122b43f01301d0188de1e333c32ed64ae8c.tar.gz go-tangerine-342cc122b43f01301d0188de1e333c32ed64ae8c.tar.zst go-tangerine-342cc122b43f01301d0188de1e333c32ed64ae8c.zip |
Added general Pipe API
Diffstat (limited to 'ethpipe/pipe_test.go')
-rw-r--r-- | ethpipe/pipe_test.go | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/ethpipe/pipe_test.go b/ethpipe/pipe_test.go new file mode 100644 index 000000000..d0b8ef948 --- /dev/null +++ b/ethpipe/pipe_test.go @@ -0,0 +1,57 @@ +package ethpipe + +import ( + "testing" + + "github.com/ethereum/eth-go/ethcrypto" + "github.com/ethereum/eth-go/ethstate" + "github.com/ethereum/eth-go/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) + // 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) + } +} |