mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-06 19:06:42 +01:00
Add tests connecting TxSelector, BatchBuilder, ZKInputs, ProofServer
- Add tests connecting TxSelector, BatchBuilder, ZKInputs, ProofServer - Added test to check that the signatures of the PoolL2Txs from the L2DB pool can be verified, to check that the parameters of the PoolL2Tx match the original parameters signed before inserting them into the L2DB
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package batchbuilder
|
||||
|
||||
import (
|
||||
ethCommon "github.com/ethereum/go-ethereum/common"
|
||||
"github.com/hermeznetwork/hermez-node/common"
|
||||
"github.com/hermeznetwork/hermez-node/db/statedb"
|
||||
"github.com/hermeznetwork/hermez-node/txprocessor"
|
||||
@@ -18,19 +17,17 @@ type ConfigCircuit struct {
|
||||
// BatchBuilder implements the batch builder type, which contains the
|
||||
// functionalities
|
||||
type BatchBuilder struct {
|
||||
localStateDB *statedb.LocalStateDB
|
||||
configCircuits []ConfigCircuit
|
||||
localStateDB *statedb.LocalStateDB
|
||||
}
|
||||
|
||||
// ConfigBatch contains the batch configuration
|
||||
type ConfigBatch struct {
|
||||
ForgerAddress ethCommon.Address
|
||||
TxProcessorConfig txprocessor.Config
|
||||
}
|
||||
|
||||
// NewBatchBuilder constructs a new BatchBuilder, and executes the bb.Reset
|
||||
// method
|
||||
func NewBatchBuilder(dbpath string, synchronizerStateDB *statedb.StateDB, configCircuits []ConfigCircuit, batchNum common.BatchNum, nLevels uint64) (*BatchBuilder, error) {
|
||||
func NewBatchBuilder(dbpath string, synchronizerStateDB *statedb.StateDB, batchNum common.BatchNum, nLevels uint64) (*BatchBuilder, error) {
|
||||
localStateDB, err := statedb.NewLocalStateDB(dbpath, 128, synchronizerStateDB,
|
||||
statedb.TypeBatchBuilder, int(nLevels))
|
||||
if err != nil {
|
||||
@@ -38,8 +35,7 @@ func NewBatchBuilder(dbpath string, synchronizerStateDB *statedb.StateDB, config
|
||||
}
|
||||
|
||||
bb := BatchBuilder{
|
||||
localStateDB: localStateDB,
|
||||
configCircuits: configCircuits,
|
||||
localStateDB: localStateDB,
|
||||
}
|
||||
|
||||
err = bb.Reset(batchNum, true)
|
||||
@@ -56,8 +52,7 @@ func (bb *BatchBuilder) Reset(batchNum common.BatchNum, fromSynchronizer bool) e
|
||||
|
||||
// BuildBatch takes the transactions and returns the common.ZKInputs of the next batch
|
||||
func (bb *BatchBuilder) BuildBatch(coordIdxs []common.Idx, configBatch *ConfigBatch, l1usertxs,
|
||||
l1coordinatortxs []common.L1Tx, pooll2txs []common.PoolL2Tx,
|
||||
tokenIDs []common.TokenID) (*common.ZKInputs, error) {
|
||||
l1coordinatortxs []common.L1Tx, pooll2txs []common.PoolL2Tx) (*common.ZKInputs, error) {
|
||||
bbStateDB := bb.localStateDB.StateDB
|
||||
tp := txprocessor.NewTxProcessor(bbStateDB, configBatch.TxProcessorConfig)
|
||||
|
||||
|
||||
@@ -21,6 +21,6 @@ func TestBatchBuilder(t *testing.T) {
|
||||
bbDir, err := ioutil.TempDir("", "tmpBatchBuilderDB")
|
||||
require.Nil(t, err)
|
||||
defer assert.Nil(t, os.RemoveAll(bbDir))
|
||||
_, err = NewBatchBuilder(bbDir, synchDB, nil, 0, 32)
|
||||
_, err = NewBatchBuilder(bbDir, synchDB, 0, 32)
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user