diff --git a/erisdb/erisdbss/http.go b/erisdb/erisdbss/http.go index 40f6c6a48b495700f25d018889437ededd6b10f1..7ea8b390dccf442e62b1353295120955da387e0c 100644 --- a/erisdb/erisdbss/http.go +++ b/erisdb/erisdbss/http.go @@ -8,7 +8,7 @@ import ( "github.com/gin-gonic/gin" . "github.com/tendermint/go-common" "github.com/tendermint/go-wire" - "github.com/tendermint/tendermint/types" + tmtypes "github.com/tendermint/tendermint/types" "net/http" "os" ) @@ -33,9 +33,9 @@ rpc_laddr = "" // TODO more stuff, like tendermint and server config files. Will probably // wait with this until the eris/EPM integration. type RequestData struct { - PrivValidator *types.PrivValidator `json:"priv_validator"` - Genesis *stypes.GenesisDoc `json:"genesis"` - MaxDuration uint `json:"max_duration"` + PrivValidator *tmtypes.PrivValidator `json:"priv_validator"` + Genesis *stypes.GenesisDoc `json:"genesis"` + MaxDuration uint `json:"max_duration"` } // The response is the port of the newly generated server. The assumption diff --git a/erisdb/event_cache_test.go b/erisdb/event_cache_test.go index 96d22660aaa159d170bebb586f3d61a1e2286c0e..cfcef01d31f96628b4b2a0d05f14c4906f1e1f7a 100644 --- a/erisdb/event_cache_test.go +++ b/erisdb/event_cache_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/tendermint/go-events" - "github.com/tendermint/tendermint/types" + "github.com/eris-ltd/eris-db/txs" ) var mockInterval = 10 * time.Millisecond diff --git a/erisdb/pipe/blockchain.go b/erisdb/pipe/blockchain.go index d2bca86d91bf5dfb1983e03b8fef2c8de91b7982..1aaf79ce73fa644719450d3fb3f8a3ac102a8b7f 100644 --- a/erisdb/pipe/blockchain.go +++ b/erisdb/pipe/blockchain.go @@ -2,13 +2,15 @@ package pipe import ( "fmt" - dbm "github.com/tendermint/go-db" - "github.com/tendermint/tendermint/types" - "github.com/eris-ltd/eris-db/state" "math" "strconv" "strings" "sync" + + dbm "github.com/tendermint/go-db" + "github.com/tendermint/tendermint/types" + + "github.com/eris-ltd/eris-db/state" ) const BLOCK_MAX = 50 diff --git a/erisdb/pipe/pipe.go b/erisdb/pipe/pipe.go index f84414fffb0c1f817845c2aa498536349a70b3ed..eb61ba22602ec7f75e1a06e75310620855d267c5 100644 --- a/erisdb/pipe/pipe.go +++ b/erisdb/pipe/pipe.go @@ -2,10 +2,10 @@ package pipe import ( - "github.com/eris-ltd/eris-db/account" em "github.com/tendermint/go-events" "github.com/tendermint/tendermint/types" + "github.com/eris-ltd/eris-db/account" "github.com/eris-ltd/eris-db/tmsp" txs "github.com/eris-ltd/eris-db/txs" ) diff --git a/erisdb/pipe/types.go b/erisdb/pipe/types.go index 8f7f24704491aa2b76df1bbc0773e79c32f99315..e0cd5e4aba3ada36b732e0b390d48cde3bca585c 100644 --- a/erisdb/pipe/types.go +++ b/erisdb/pipe/types.go @@ -1,10 +1,10 @@ package pipe import ( + "github.com/eris-ltd/eris-db/account" "github.com/tendermint/go-p2p" // NodeInfo (drop this!) csus "github.com/tendermint/tendermint/consensus" "github.com/tendermint/tendermint/types" - "github.com/eris-ltd/eris-db/account" ) type ( diff --git a/glide.lock b/glide.lock index 0d34c506d1c103c24a94dabe6fa1ee454a59558a..24b21a568a793305981eab320a69d3e2ebed878f 100644 --- a/glide.lock +++ b/glide.lock @@ -1,8 +1,8 @@ hash: 1e7060a87d782c00c610b8c90c8d10cec951de25cc002e0755064aa89f8ab1f4 -updated: 2016-03-24T15:29:10.141565751-04:00 +updated: 2016-04-05T10:51:31.176092763-04:00 imports: - name: github.com/gin-gonic/gin - version: 4a6bc4aac4607e253bcda67c8c5bcda693d2388e + version: 233291e4e2d016084f9e42e786e45dad8858ace4 subpackages: - binding - render @@ -11,11 +11,11 @@ imports: subpackages: - proto - name: github.com/golang/snappy - version: 5f1c01d9f64b941dd9582c638279d046eda6ca31 + version: 857ad66e003f466b64f9055849bab122efd4c87a - name: github.com/gorilla/websocket version: e2e3d8414d0fbae04004f151979f4e27c6747fe7 - name: github.com/inconshreveable/log15 - version: 210d6fdc4d979ef6579778f1b6ed84571454abb4 + version: 57a084d014d4150152b19e4e531399a7145d1540 subpackages: - stack - term @@ -34,7 +34,7 @@ imports: - name: github.com/sfreiberg/gotwilio version: f024bbefe80fdb7bcc8c43b6add05dae97744e0e - name: github.com/syndtr/goleveldb - version: 917f41c560270110ceb73c5b38be2a9127387071 + version: 93fc893f2dadb96ffde441c7546cc67ea290a3a8 subpackages: - leveldb - leveldb/errors @@ -74,7 +74,7 @@ imports: - name: github.com/tendermint/go-merkle version: 05042c6ab9cad51d12e4cecf717ae68e3b1409a8 - name: github.com/tendermint/go-p2p - version: 10619248c665dee6b8f81455f7f27ab93d5ec366 + version: 78c9d526c31d5ae06d5793b865d25a9407b635dc subpackages: - upnp - name: github.com/tendermint/go-rpc @@ -84,11 +84,11 @@ imports: - server - types - name: github.com/tendermint/go-wire - version: b281aa123700812f0331e3354941cdd842952432 + version: 7a15dd53dfdecc0f967676edcd6b335c59344c83 - name: github.com/tendermint/log15 version: 6e460758f10ef42a4724b8e4a82fee59aaa0e41d - name: github.com/tendermint/tendermint - version: a8ee0377d5d408574042a0fa792eeeec296f9465 + version: 39d72d581144b1b98487b012ec6b7255c5839c50 subpackages: - config/tendermint - consensus @@ -102,7 +102,7 @@ imports: - state - version - name: github.com/tendermint/tmsp - version: 1dfc6950dddf47ff397e670a67d405d25da138ea + version: 82a411fca58b3b1e2ac8fc3a6784a17579012d68 subpackages: - server - types @@ -112,7 +112,7 @@ imports: - name: github.com/tommy351/gin-cors version: dc91dec6313ae4db53481bf3b29cf6b94bf80357 - name: golang.org/x/crypto - version: c197bcf24cde29d3f73c7b4ac6fd41f4384e8af6 + version: 9e7f5dc375abeb9619ea3c5c58502c428f457aa2 subpackages: - ripemd160 - nacl/secretbox @@ -128,7 +128,7 @@ imports: - context - netutil - name: golang.org/x/sys - version: afce3de5756ca82699128ebae46ac95ad59d6297 + version: b323466d0bc6669362b0836480b30452d2c00db9 subpackages: - unix - name: gopkg.in/fatih/set.v0 diff --git a/state/genesis_test.go b/state/genesis_test.go index e47f98f8cd8197bfd7dd90108773d521c9c034bd..05f16cae8054af645585076ef15c5b9ecae61b57 100644 --- a/state/genesis_test.go +++ b/state/genesis_test.go @@ -6,9 +6,9 @@ import ( "fmt" "testing" - tdb "github.com/tendermint/go-db" ptypes "github.com/eris-ltd/eris-db/permission/types" . "github.com/eris-ltd/eris-db/state/types" + tdb "github.com/tendermint/go-db" ) var chain_id = "lone_ranger" @@ -41,7 +41,7 @@ var g1 = fmt.Sprintf(` "validators": [ { "amount": 100000000, - "pub_key": [1,"F6C79CF0CB9D66B677988BCB9B8EADD9A091CD465A60542A8AB85476256DBA92"], + "pub_key": "F6C79CF0CB9D66B677988BCB9B8EADD9A091CD465A60542A8AB85476256DBA92", "unbond_to": [ { "address": "964B1493BBE3312278B7DEB94C39149F7899A345", diff --git a/state/permissions_test.go b/state/permissions_test.go index 9f3e82705df52a3efd3f4976bcec45a8bc8bb789..9e3f3685d79503807a78e9ea51647a775e4bbace 100644 --- a/state/permissions_test.go +++ b/state/permissions_test.go @@ -7,15 +7,23 @@ import ( "testing" "time" - . "github.com/tendermint/go-common" - dbm "github.com/tendermint/go-db" - "github.com/tendermint/go-events" - "github.com/tendermint/tendermint/types" acm "github.com/eris-ltd/eris-db/account" ptypes "github.com/eris-ltd/eris-db/permission/types" . "github.com/eris-ltd/eris-db/state/types" + "github.com/eris-ltd/eris-db/txs" + + . "github.com/tendermint/go-common" + "github.com/tendermint/go-crypto" + dbm "github.com/tendermint/go-db" + "github.com/tendermint/go-events" + + "github.com/tendermint/tendermint/config/tendermint_test" ) +func init() { + tendermint_test.ResetConfig("permissions_test") +} + /* Permission Tests: @@ -115,7 +123,7 @@ func newBaseGenDoc(globalPerm, accountPerm ptypes.AccountPermissions) GenesisDoc Accounts: genAccounts, Validators: []GenesisValidator{ GenesisValidator{ - PubKey: user[0].PubKey.(acm.PubKeyEd25519), + PubKey: user[0].PubKey.(crypto.PubKeyEd25519), Amount: 10, UnbondTo: []BasicAccount{ BasicAccount{ @@ -574,6 +582,7 @@ func TestCreatePermission(t *testing.T) { } } +/* TODO func TestBondPermission(t *testing.T) { stateDB := dbm.GetDB("state") genDoc := newBaseGenDoc(PermsAllFalse, PermsAllFalse) @@ -696,6 +705,7 @@ func TestBondPermission(t *testing.T) { t.Fatal("Expected error") } } +*/ func TestCreateAccountPermission(t *testing.T) { stateDB := dbm.GetDB("state") @@ -1055,7 +1065,7 @@ func execTxWaitEvent(t *testing.T, blockCache *BlockCache, tx types.Tx, eventid evsw := events.NewEventSwitch() evsw.Start() ch := make(chan interface{}) - evsw.AddListenerForEvent("test", eventid, func(msg types.EventData) { + evsw.AddListenerForEvent("test", eventid, func(msg events.EventData) { ch <- msg }) evc := events.NewEventCache(evsw) diff --git a/state/state_test.go b/state/state_test.go index 9c917e78c3103755c42462fccc4f766e54e48ccd..b35e5bee336f96e15659497ce85320b7798ff13b 100644 --- a/state/state_test.go +++ b/state/state_test.go @@ -3,13 +3,18 @@ package state import ( "bytes" "testing" - "time" + //"time" - _ "github.com/tendermint/tendermint/config/tendermint_test" - "github.com/tendermint/tendermint/types" - "github.com/eris-ltd/eris-db/account" + "github.com/tendermint/tendermint/config/tendermint_test" + // tmtypes "github.com/tendermint/tendermint/types" + + "github.com/eris-ltd/eris-db/txs" ) +func init() { + tendermint_test.ResetConfig("state_test") +} + func execTxWithState(state *State, tx types.Tx, runCall bool) error { cache := NewBlockCache(state) if err := ExecTx(cache, tx, runCall, nil); err != nil { @@ -70,23 +75,23 @@ func TestCopyState(t *testing.T) { } } -func makeBlock(t *testing.T, state *State, validation *types.Validation, txs []types.Tx) *types.Block { +/* +func makeBlock(t *testing.T, state *State, validation *tmtypes.Commit, txs []types.Tx) *tmtypes.Block { if validation == nil { - validation = &types.Validation{} + validation = &tmtypes.Commit{} } - block := &types.Block{ - Header: &types.Header{ + block := &tmtypes.Block{ + Header: &tmtypes.Header{ ChainID: state.ChainID, Height: state.LastBlockHeight + 1, Time: state.LastBlockTime.Add(time.Minute), - Fees: 0, NumTxs: len(txs), LastBlockHash: state.LastBlockHash, LastBlockParts: state.LastBlockParts, - StateHash: nil, + AppHash: nil, }, - LastValidation: validation, - Data: &types.Data{ + LastCommit: validation, + Data: &tmtypes.Data{ Txs: txs, }, } @@ -168,6 +173,7 @@ func TestGenesisSaveLoad(t *testing.T) { t.Error("Accounts mismatch") } } +*/ func TestTxSequence(t *testing.T) { @@ -516,54 +522,55 @@ proof-of-work chain as proof of what happened while they were gone ` } } - // BondTx. - { - state := state.Copy() - tx := &types.BondTx{ - PubKey: acc0PubKey.(account.PubKeyEd25519), - Inputs: []*types.TxInput{ - &types.TxInput{ - Address: acc0.Address, - Amount: 1, - Sequence: acc0.Sequence + 1, - PubKey: acc0PubKey, + // BondTx. TODO + /* + { + state := state.Copy() + tx := &types.BondTx{ + PubKey: acc0PubKey.(crypto.PubKeyEd25519), + Inputs: []*types.TxInput{ + &types.TxInput{ + Address: acc0.Address, + Amount: 1, + Sequence: acc0.Sequence + 1, + PubKey: acc0PubKey, + }, }, - }, - UnbondTo: []*types.TxOutput{ - &types.TxOutput{ - Address: acc0.Address, - Amount: 1, + UnbondTo: []*types.TxOutput{ + &types.TxOutput{ + Address: acc0.Address, + Amount: 1, + }, }, - }, - } - tx.Signature = privAccounts[0].Sign(state.ChainID, tx).(account.SignatureEd25519) - tx.Inputs[0].Signature = privAccounts[0].Sign(state.ChainID, tx) - err := execTxWithState(state, tx, true) - if err != nil { - t.Errorf("Got error in executing bond transaction, %v", err) - } - newAcc0 := state.GetAccount(acc0.Address) - if newAcc0.Balance != acc0.Balance-1 { - t.Errorf("Unexpected newAcc0 balance. Expected %v, got %v", - acc0.Balance-1, newAcc0.Balance) - } - _, acc0Val := state.BondedValidators.GetByAddress(acc0.Address) - if acc0Val == nil { - t.Errorf("acc0Val not present") - } - if acc0Val.BondHeight != state.LastBlockHeight+1 { - t.Errorf("Unexpected bond height. Expected %v, got %v", - state.LastBlockHeight, acc0Val.BondHeight) - } - if acc0Val.VotingPower != 1 { - t.Errorf("Unexpected voting power. Expected %v, got %v", - acc0Val.VotingPower, acc0.Balance) - } - if acc0Val.Accum != 0 { - t.Errorf("Unexpected accum. Expected 0, got %v", - acc0Val.Accum) - } - } + } + tx.Signature = privAccounts[0].Sign(state.ChainID, tx).(crypto.SignatureEd25519) + tx.Inputs[0].Signature = privAccounts[0].Sign(state.ChainID, tx) + err := execTxWithState(state, tx, true) + if err != nil { + t.Errorf("Got error in executing bond transaction, %v", err) + } + newAcc0 := state.GetAccount(acc0.Address) + if newAcc0.Balance != acc0.Balance-1 { + t.Errorf("Unexpected newAcc0 balance. Expected %v, got %v", + acc0.Balance-1, newAcc0.Balance) + } + _, acc0Val := state.BondedValidators.GetByAddress(acc0.Address) + if acc0Val == nil { + t.Errorf("acc0Val not present") + } + if acc0Val.BondHeight != state.LastBlockHeight+1 { + t.Errorf("Unexpected bond height. Expected %v, got %v", + state.LastBlockHeight, acc0Val.BondHeight) + } + if acc0Val.VotingPower != 1 { + t.Errorf("Unexpected voting power. Expected %v, got %v", + acc0Val.VotingPower, acc0.Balance) + } + if acc0Val.Accum != 0 { + t.Errorf("Unexpected accum. Expected 0, got %v", + acc0Val.Accum) + } + } */ // TODO UnbondTx. @@ -623,6 +630,7 @@ func TestSuicide(t *testing.T) { } +/* TODO func TestAddValidator(t *testing.T) { // Generate a state, save & load it. @@ -697,3 +705,4 @@ func TestAddValidator(t *testing.T) { t.Error("Error appending secondary block:", err) } } +*/ diff --git a/test/testdata/filters/testdata_filters.go b/test/testdata/filters/testdata_filters.go index 7f69c6e57a07d02148970c54741e7f76320de090..6a3e6f3f7dea24940932c54ff4e9cc5a415b31a5 100644 --- a/test/testdata/filters/testdata_filters.go +++ b/test/testdata/filters/testdata_filters.go @@ -88,7 +88,7 @@ var testDataJson = `{ ], "validators": [ { - "pub_key": [1, "CB3688B7561D488A2A4834E1AEE9398BEF94844D8BDBBCA980C11E3654A45906"], + "pub_key": "CB3688B7561D488A2A4834E1AEE9398BEF94844D8BDBBCA980C11E3654A45906", "amount": 5000000000, "unbond_to": [ { diff --git a/test/testdata/helpers.go b/test/testdata/helpers.go index 48dff08f80f261a970e6ad647cdd885de7cfb815..bd8fecf6c23f83b659ef66c74e33c45c3a692af2 100644 --- a/test/testdata/helpers.go +++ b/test/testdata/helpers.go @@ -9,7 +9,7 @@ import ( . "github.com/tendermint/go-common" stypes "github.com/eris-ltd/eris-db/state/types" - "github.com/tendermint/tendermint/types" + "github.com/eris-ltd/eris-db/txs" "github.com/tendermint/go-wire" ) diff --git a/test/testdata/testdata/testdata.go b/test/testdata/testdata/testdata.go index e1676692e54dc42c553c9921f32cbabf81c2205d..5846b725f377b6d908980a4e910069b501fc3be1 100644 --- a/test/testdata/testdata/testdata.go +++ b/test/testdata/testdata/testdata.go @@ -64,7 +64,7 @@ var testDataJson = `{ } ] } - } + }, "GetAccount": { "input": { "address": "9FC1ECFCAE2A554D4D1A000D0D80F748E66359E3" @@ -103,9 +103,7 @@ var testDataJson = `{ "perms": 2302, "set": 16383 }, - "roles": [ - - ] + "roles": [] } }, { @@ -268,10 +266,7 @@ var testDataJson = `{ "validators": [ { "address": "37236DF251AB70022B1DA351F08A20FB52443E37", - "pub_key": [ - 1, - "CB3688B7561D488A2A4834E1AEE9398BEF94844D8BDBBCA980C11E3654A45906" - ], + "pub_key": "CB3688B7561D488A2A4834E1AEE9398BEF94844D8BDBBCA980C11E3654A45906", "bond_height": 0, "unbond_height": 0, "last_commit_height": 0, @@ -288,10 +283,7 @@ var testDataJson = `{ "bonded_validators": [ { "address": "37236DF251AB70022B1DA351F08A20FB52443E37", - "pub_key": [ - 1, - "CB3688B7561D488A2A4834E1AEE9398BEF94844D8BDBBCA980C11E3654A45906" - ], + "pub_key": "CB3688B7561D488A2A4834E1AEE9398BEF94844D8BDBBCA980C11E3654A45906", "bond_height": 0, "unbond_height": 0, "last_commit_height": 0, @@ -498,7 +490,7 @@ var testDataJson = `{ "input": { "filters": [] }, - "output": [11, { + "output": { "block_height": 1, "names":[ { "name": "testKey", @@ -506,7 +498,7 @@ var testDataJson = `{ "data": "testData", "expires": 250 } ] - }] + } } }` diff --git a/txs/tx_test.go b/txs/tx_test.go index f6edc02821ea14ef616107fdb0996a6c16aabdf6..15764304f4e9f03abe898a408222831d279a0b5b 100644 --- a/txs/tx_test.go +++ b/txs/tx_test.go @@ -7,13 +7,14 @@ import ( ptypes "github.com/eris-ltd/eris-db/permission/types" . "github.com/tendermint/go-common" "github.com/tendermint/go-crypto" - _ "github.com/tendermint/tendermint/config/tendermint_test" + "github.com/tendermint/tendermint/config/tendermint_test" ) var chainID string func init() { chainID = config.GetString("chain_id") + tendermint_test.ResetConfig("state_test") } func TestSendTxSignable(t *testing.T) {