Skip to content
Snippets Groups Projects
Unverified Commit 8cdf76d7 authored by Silas Davis's avatar Silas Davis
Browse files

Fix remaining rpc tests, try to sure up integration tests stability

parent 3468810c
No related branches found
No related tags found
No related merge requests found
......@@ -41,7 +41,11 @@ test:
- cd $GOPATH_REPO && go install ./cmd/eris-db
override:
# We only wish to test our packages not vendored ones
- echo "Running unit tests..."
- cd $GOPATH_REPO && glide novendor | xargs go test -v
- echo "Running integration tests..."
- cd $GOPATH_REPO && glide novendor | xargs go test -v -tags integration
deployment:
master:
......
......@@ -67,3 +67,9 @@ func NewTendermintWebsocketServer(config *server.ServerConfig,
listeners: listeners,
}, nil
}
func (tmServer *TendermintWebsocketServer) Shutdown() {
for _, listener := range tmServer.listeners {
listener.Close()
}
}
......@@ -18,42 +18,32 @@ func TestHTTPStatus(t *testing.T) {
testStatus(t, "HTTP")
}
// TODO: test has been disabled and needs to be re-enabled; tracked in issue
// https://github.com/eris-ltd/eris-db/issues/238
func testHTTPGetAccount(t *testing.T) {
func TestHTTPGetAccount(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode.")
}
testGetAccount(t, "HTTP")
}
// TODO: test has been disabled and needs to be re-enabled; tracked in issue
// https://github.com/eris-ltd/eris-db/issues/238
func testHTTPBroadcastTx(t *testing.T) {
func TestHTTPBroadcastTx(t *testing.T) {
testBroadcastTx(t, "HTTP")
}
// TODO: test has been disabled and needs to be re-enabled; tracked in issue
// https://github.com/eris-ltd/eris-db/issues/238
func testHTTPGetStorage(t *testing.T) {
func TestHTTPGetStorage(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode.")
}
testGetStorage(t, "HTTP")
}
// TODO: test has been disabled and needs to be re-enabled; tracked in issue
// https://github.com/eris-ltd/eris-db/issues/238
func testHTTPCallCode(t *testing.T) {
func TestHTTPCallCode(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode.")
}
testCallCode(t, "HTTP")
}
// TODO: test has been disabled and needs to be re-enabled; tracked in issue
// https://github.com/eris-ltd/eris-db/issues/238
func testHTTPCallContract(t *testing.T) {
func TestHTTPCallContract(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode.")
}
......@@ -99,9 +89,7 @@ func TestJSONCallCode(t *testing.T) {
testCallCode(t, "JSONRPC")
}
// TODO: test has been disabled and needs to be re-enabled; tracked in issue
// https://github.com/eris-ltd/eris-db/issues/238
func testJSONCallContract(t *testing.T) {
func TestJSONCallContract(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode.")
}
......
......@@ -218,7 +218,7 @@ func TestWSCallCall(t *testing.T) {
receipt = broadcastTx(t, wsTyp, tx)
contractAddr2 := receipt.ContractAddr
// susbscribe to the new contracts
// subscribe to the new contracts
amt = int64(10001)
eid := txs.EventStringAccCall(contractAddr1)
subId := subscribeAndGetSubscriptionId(t, wsc, eid)
......@@ -244,4 +244,3 @@ func TestWSCallCall(t *testing.T) {
func TestSubscribe(t *testing.T) {
testSubscribe(t)
}
......@@ -2,6 +2,7 @@ package test
import (
"github.com/eris-ltd/eris-db/test/fixtures"
rpc_core "github.com/eris-ltd/eris-db/rpc/tendermint/core"
"testing"
)
......@@ -19,7 +20,14 @@ func TestWrapper(runner func() int) int {
// start a node
ready := make(chan error)
go newNode(ready)
server := make(chan *rpc_core.TendermintWebsocketServer)
defer func(){
// Shutdown -- make sure we don't hit a race on ffs.RemoveAll
tmServer := <-server
tmServer.Shutdown()
}()
go newNode(ready, server)
err = <-ready
if err != nil {
......
......@@ -9,6 +9,7 @@ import (
"github.com/eris-ltd/eris-db/core"
core_types "github.com/eris-ltd/eris-db/core/types"
edbcli "github.com/eris-ltd/eris-db/rpc/tendermint/client"
rpc_core "github.com/eris-ltd/eris-db/rpc/tendermint/core"
rpc_types "github.com/eris-ltd/eris-db/rpc/tendermint/core/types"
"github.com/eris-ltd/eris-db/server"
"github.com/eris-ltd/eris-db/test/fixtures"
......@@ -102,10 +103,12 @@ func makeUsers(n int) []*acm.PrivAccount {
return accounts
}
func newNode(ready chan error) {
func newNode(ready chan error,
tmServer chan *rpc_core.TendermintWebsocketServer) {
// Run the 'tendermint' rpc server
_, err := testCore.NewGatewayTendermint(config)
server, err := testCore.NewGatewayTendermint(config)
ready <- err
tmServer <- server
}
func saveNewPriv() {
......
......@@ -91,22 +91,19 @@ func testGetStorage(t *testing.T, typ string) {
amt, gasLim, fee := int64(1100), int64(1000), int64(1000)
code := []byte{0x60, 0x5, 0x60, 0x1, 0x55}
// Call with nil address will create a contract
tx := makeDefaultCallTx(t, typ, nil, code, amt, gasLim, fee)
receipt := broadcastTx(t, typ, tx)
if receipt.CreatesContract == 0 {
t.Fatal("This tx creates a contract")
}
if len(receipt.TxHash) == 0 {
t.Fatal("Failed to compute tx hash")
receipt, err := broadcastTxAndWaitForBlock(t, typ, wsc, tx)
if err != nil {
t.Fatalf("Problem broadcasting transaction: %v", err)
}
assert.Equal(t, uint8(1), receipt.CreatesContract, "This transaction should"+
" create a contract")
assert.NotEqual(t, 0, len(receipt.TxHash), "Receipt should contain a"+
" transaction hash")
contractAddr := receipt.ContractAddr
if len(contractAddr) == 0 {
t.Fatal("Creates contract but resulting address is empty")
}
// allow it to get mined
waitForEvent(t, wsc, eid, func() {}, doNothing)
mempoolCount = 0
assert.NotEqual(t, 0, len(contractAddr), "Transactions claims to have"+
" created a contract but the contract address is empty")
v := getStorage(t, typ, contractAddr, []byte{0x1})
got := tm_common.LeftPadWord256(v)
......@@ -151,22 +148,17 @@ func testCall(t *testing.T, typ string) {
amt, gasLim, fee := int64(6969), int64(1000), int64(1000)
code, _, _ := simpleContract()
tx := makeDefaultCallTx(t, typ, nil, code, amt, gasLim, fee)
receipt := broadcastTx(t, typ, tx)
if receipt.CreatesContract == 0 {
t.Fatal("This tx creates a contract")
}
if len(receipt.TxHash) == 0 {
t.Fatal("Failed to compute tx hash")
receipt, err := broadcastTxAndWaitForBlock(t, typ, wsc, tx)
if err != nil {
t.Fatalf("Problem broadcasting transaction: %v", err)
}
assert.Equal(t, uint8(1), receipt.CreatesContract, "This transaction should"+
" create a contract")
assert.NotEqual(t, 0, len(receipt.TxHash), "Receipt should contain a"+
" transaction hash")
contractAddr := receipt.ContractAddr
if len(contractAddr) == 0 {
t.Fatal("Creates contract but resulting address is empty")
}
// allow it to get mined
waitForEvent(t, wsc, eid, func() {}, doNothing)
mempoolCount = 0
assert.NotEqual(t, 0, len(contractAddr), "Transactions claims to have"+
" created a contract but the contract address is empty")
// run a call through the contract
data := []byte{}
......@@ -226,9 +218,12 @@ func testNameReg(t *testing.T, typ string) {
tx.Sign(chainID, user[1])
_, err := broadcastTxAndWaitForBlock(t, typ, wsc, tx)
assert.Error(t, err, "Expected error when updating someone else's unexpired"+
" name registry entry")
// Wait a couple of blocks to make sure name registration expires
waitNBlocks(t, wsc, 2)
//now the entry should be expired, so we can update as non owner
const data2 = "this is not my beautiful house"
tx = txs.NewNameTxWithNonce(user[1].PubKey, name, data2, amt, fee,
......@@ -308,4 +303,3 @@ Subscribe:
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment