You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.8 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
new pubsub package comment out failing consensus tests for now rewrite rpc httpclient to use new pubsub package import pubsub as tmpubsub, query as tmquery make event IDs constants EventKey -> EventTypeKey rename EventsPubsub to PubSub mempool does not use pubsub rename eventsSub to pubsub new subscribe API fix channel size issues and consensus tests bugs refactor rpc client add missing discardFromChan method add mutex rename pubsub to eventBus remove IsRunning from WSRPCConnection interface (not needed) add a comment in broadcastNewRoundStepsAndVotes rename registerEventCallbacks to broadcastNewRoundStepsAndVotes See https://dave.cheney.net/2014/03/19/channel-axioms stop eventBuses after reactor tests remove unnecessary Unsubscribe return subscribe helper function move discardFromChan to where it is used subscribe now returns an err this gives us ability to refuse to subscribe if pubsub is at its max capacity. use context for control overflow cache queries handle err when subscribing in replay_test rename testClientID to testSubscriber extract var set channel buffer capacity to 1 in replay_file fix byzantine_test unsubscribe from single event, not all events refactor httpclient to return events to appropriate channels return failing testReplayCrashBeforeWriteVote test fix TestValidatorSetChanges refactor code a bit fix testReplayCrashBeforeWriteVote add comment fix TestValidatorSetChanges fixes from Bucky's review update comment [ci skip] test TxEventBuffer update changelog fix TestValidatorSetChanges (2nd attempt) only do wg.Done when no errors benchmark event bus create pubsub server inside NewEventBus only expose config params (later if needed) set buffer capacity to 0 so we are not testing cache new tx event format: key = "Tx" plus a tag {"tx.hash": XYZ} This should allow to subscribe to all transactions! or a specific one using a query: "tm.events.type = Tx and tx.hash = '013ABF99434...'" use TimeoutCommit instead of afterPublishEventNewBlockTimeout TimeoutCommit is the time a node waits after committing a block, before it goes into the next height. So it will finish everything from the last block, but then wait a bit. The idea is this gives it time to hear more votes from other validators, to strengthen the commit it includes in the next block. But it also gives it time to hear about new transactions. waitForBlockWithUpdatedVals rewrite WAL crash tests Task: test that we can recover from any WAL crash. Solution: the old tests were relying on event hub being run in the same thread (we were injecting the private validator's last signature). when considering a rewrite, we considered two possible solutions: write a "fuzzy" testing system where WAL is crashing upon receiving a new message, or inject failures and trigger them in tests using something like https://github.com/coreos/gofail. remove sleep no cs.Lock around wal.Save test different cases (empty block, non-empty block, ...) comments add comments test 4 cases: empty block, non-empty block, non-empty block with smaller part size, many blocks fixes as per Bucky's last review reset subscriptions on UnsubscribeAll use a simple counter to track message for which we panicked also, set a smaller part size for all test cases
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. package state
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/require"
  5. "github.com/tendermint/abci/example/dummy"
  6. crypto "github.com/tendermint/go-crypto"
  7. "github.com/tendermint/tendermint/proxy"
  8. "github.com/tendermint/tendermint/types"
  9. dbm "github.com/tendermint/tmlibs/db"
  10. "github.com/tendermint/tmlibs/log"
  11. )
  12. var (
  13. privKey = crypto.GenPrivKeyEd25519FromSecret([]byte("execution_test"))
  14. chainID = "execution_chain"
  15. testPartSize = 65536
  16. nTxsPerBlock = 10
  17. )
  18. func TestApplyBlock(t *testing.T) {
  19. cc := proxy.NewLocalClientCreator(dummy.NewDummyApplication())
  20. proxyApp := proxy.NewAppConns(cc, nil)
  21. err := proxyApp.Start()
  22. require.Nil(t, err)
  23. defer proxyApp.Stop()
  24. state := state()
  25. state.SetLogger(log.TestingLogger())
  26. // make block
  27. block := makeBlock(1, state)
  28. err = state.ApplyBlock(types.NopEventBus{}, proxyApp.Consensus(), block, block.MakePartSet(testPartSize).Header(), types.MockMempool{})
  29. require.Nil(t, err)
  30. // TODO check state and mempool
  31. }
  32. //----------------------------------------------------------------------------
  33. // make some bogus txs
  34. func makeTxs(blockNum int) (txs []types.Tx) {
  35. for i := 0; i < nTxsPerBlock; i++ {
  36. txs = append(txs, types.Tx([]byte{byte(blockNum), byte(i)}))
  37. }
  38. return txs
  39. }
  40. func state() *State {
  41. s, _ := MakeGenesisState(dbm.NewMemDB(), &types.GenesisDoc{
  42. ChainID: chainID,
  43. Validators: []types.GenesisValidator{
  44. {privKey.PubKey(), 10000, "test"},
  45. },
  46. AppHash: nil,
  47. })
  48. return s
  49. }
  50. func makeBlock(num int, state *State) *types.Block {
  51. prevHash := state.LastBlockID.Hash
  52. prevParts := types.PartSetHeader{}
  53. valHash := state.Validators.Hash()
  54. prevBlockID := types.BlockID{prevHash, prevParts}
  55. block, _ := types.MakeBlock(num, chainID, makeTxs(num), new(types.Commit),
  56. prevBlockID, valHash, state.AppHash, testPartSize)
  57. return block
  58. }