newTestProtocolManager creates a new protocol manager for testing purposes, with the given number of blocks already known, and potential notification channels for different events.
(blocks int, generator func(int, *core.BlockGen), newtx chan<- []*types.Transaction)
| 32 | // with the given number of blocks already known, and potential notification |
| 33 | // channels for different events. |
| 34 | func newTestProtocolManager(blocks int, generator func(int, *core.BlockGen), newtx chan<- []*types.Transaction) (*ProtocolManager, *database.MemDatabase, error) { |
| 35 | var ( |
| 36 | evmux = new(event.TypeMux) |
| 37 | db = database.NewMemDatabase() |
| 38 | remoteDB = database.NewIpfsDbWithAdapter(database.NewFakeIpfsAdapter()) |
| 39 | ) |
| 40 | gspec := core.DefaultGenesisBlock() |
| 41 | gspec.Alloc = core.GenesisAlloc{testBank: {Balance: big.NewInt(1000000)}} |
| 42 | genesis := gspec.MustCommit(db) |
| 43 | |
| 44 | engine := dpor.NewFaker(configs.ChainConfigInfo().Dpor, db) |
| 45 | |
| 46 | chain, _ := core.GenerateChain(gspec.Config, genesis, engine, db, remoteDB, blocks, generator) |
| 47 | blockchain, _ := core.NewBlockChain(db, nil, gspec.Config, engine, vm.Config{}, remoteDB, nil) |
| 48 | |
| 49 | if _, err := blockchain.InsertChain(chain); err != nil { |
| 50 | panic(err) |
| 51 | } |
| 52 | |
| 53 | pm, err := NewProtocolManager(gspec.Config, DefaultConfig.NetworkId, evmux, &testTxPool{added: newtx}, engine, blockchain, db, common.Address{}, DefaultConfig.SyncMode) |
| 54 | if err != nil { |
| 55 | return nil, nil, err |
| 56 | } |
| 57 | pm.Start(1000) |
| 58 | StartSyncerLoop <- "startLoop" |
| 59 | return pm, db, nil |
| 60 | } |
| 61 | |
| 62 | // newTestProtocolManagerMust creates a new protocol manager for testing purposes, |
| 63 | // with the given number of blocks already known, and potential notification |
no test coverage detected