mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 03:16:45 +01:00
Merge pull request #127 from hermeznetwork/feature/txsel-txsselection-v0
TxSelector GetL2TxSelection & GetL1L2TxSelection integrated with dbs
This commit is contained in:
13
test/l2db.go
Normal file
13
test/l2db.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package test
|
||||
|
||||
import "github.com/jmoiron/sqlx"
|
||||
|
||||
// CleanL2DB deletes 'tx_pool' and 'account_creation_auth' from the given DB
|
||||
func CleanL2DB(db *sqlx.DB) {
|
||||
if _, err := db.Exec("DELETE FROM tx_pool"); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if _, err := db.Exec("DELETE FROM account_creation_auth"); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ func GenerateTestTxs(t *testing.T, instructions Instructions) ([][]*common.L1Tx,
|
||||
var coordinatorL1Txs [][]*common.L1Tx
|
||||
var poolL2Txs [][]*common.PoolL2Tx
|
||||
idx := 1
|
||||
for _, inst := range instructions.Instructions {
|
||||
for i, inst := range instructions.Instructions {
|
||||
switch inst.Type {
|
||||
case common.TxTypeCreateAccountDeposit:
|
||||
tx := common.L1Tx{
|
||||
@@ -98,7 +98,7 @@ func GenerateTestTxs(t *testing.T, instructions Instructions) ([][]*common.L1Tx,
|
||||
}
|
||||
|
||||
tx := common.PoolL2Tx{
|
||||
// TxID: nil,
|
||||
TxID: common.TxID([]byte{byte(i)}), // TODO this is for the moment, once TxID Hash is implemented use it
|
||||
FromIdx: accounts[idxTokenIDToString(inst.From, inst.TokenID)].Idx,
|
||||
ToIdx: accounts[idxTokenIDToString(inst.To, inst.TokenID)].Idx,
|
||||
ToEthAddr: accounts[idxTokenIDToString(inst.To, inst.TokenID)].Addr,
|
||||
@@ -109,7 +109,7 @@ func GenerateTestTxs(t *testing.T, instructions Instructions) ([][]*common.L1Tx,
|
||||
Nonce: accounts[idxTokenIDToString(inst.From, inst.TokenID)].Nonce,
|
||||
State: common.PoolL2TxStatePending,
|
||||
Timestamp: time.Now(),
|
||||
BatchNum: 0,
|
||||
BatchNum: common.BatchNum(0),
|
||||
RqToEthAddr: accounts[idxTokenIDToString(inst.To, inst.TokenID)].Addr,
|
||||
RqToBJJ: accounts[idxTokenIDToString(inst.To, inst.TokenID)].BJJ.Public(),
|
||||
Type: common.TxTypeTransfer,
|
||||
|
||||
Reference in New Issue
Block a user